Skip to main content

Posts

Showing posts with the label sql server

8 Ways to Fine-tune your SQL Queries

In organizations that operate  without a data warehouse  or separate analytical database for reporting, the only source of the latest and up-to-date data may be in the live production database. When querying a production database, optimization is key. An inefficient query may pose a burden on the production database’s resources, and cause slow performance or loss of service for other users if the query contains errors. Hence it is important to optimize your queries for minimum impact on the database’s performance. 1. Define Business Requirements before Beginning In a previous article, we covered  best practices to define business requirements for BI . Those practices should be applied when optimizing  SQL queries , including: Identifying relevant stakeholders.  Make sure all involved parties are in the discussion of developing your query. When querying production databases, make sure the DBA team is included. Focusing on business outcomes.  Be sure...

Reset Identity column in SQL Server

How To: Reset Identity column in SQL Server This is one of those simple tip posts that may seem obvious and taken for granted by those of us who have been working with SQL Server for a while now but maybe a newbie or two out there will find this helpful. Every so often (just this morning!) I find myself resetting an identity column value back to 0 after I've deleted all the existing records so the table gets a fresh start at primary key 1. Yes, I know all about primary keys not changing and how the value in the primary key doesn't matter and so on. Sometimes I just like the primary keys starting at 1. The following line resets the Identity value for the Customer table to 0 so that the next record added starts at 1. DBCC CHECKIDENT('Customer', RESEED, 0)