Posts Tagged SQL server 2005

SQL – Handling Null Values

1. A NULL value represents an UNKNOWN value 2. Under ANSI_NULLS ON, two NULL values will never be equal to each other because the two separate values are unknown. With ANSI_NULLS OFF, two separate NULL values will evaluate to equal values. IF OBJECT_ID('SalesHistory')>0 DROP TABLE SalesHistory;GOCREATE TABLE [dbo].[SalesHistory]( [SaleID] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY, [Product] [varchar](10) NULL, [S Read More

Tags:

Delete Duplicate Rows – SQL 2005

There are different methods to remove duplicates in SQL server 2005 where we do not have primary key defined for any table. In the example I have table with field names FirstName and LastName.  To remove duplicates in any table, replace the field names with the actual names. If we have more columns, then add those columns as well in the declaration part and in the select and where conditions in the query. Method 1 Read More

Tags: , ,

SQL DB shrink

To shrink the DB Transaction Log file,USE DatabaseNameGODBCC SHRINKFILE(<log file name>, 1) To find out the Log file details:USE DATABASENAMEexec sp_helpfile Bookmark on DeliciousDigg this post Recommend on FacebookShare with StumblersTweet about itSubscribe to the comments on this post Read More

Tags: ,