Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

Friday, June 26, 2009

How to get Duplicate records in a Table

Last day, I seamlessly entered into a situation where I want to list out all the repeating/duplicate records from a table. Though it sounds simple, its bit a tricky approach.

As a small example: consider a table say RepeatTest having 2 fields: Id and Url. To figure out the repeating Url records, you can write the query as:

   1:  
   2: SELECT Url, count(Url) FROM RepeatTest
   3:     GROUP BY Url
   4:         HAVING (COUNT(Url)>1)
   5:  

Sometimes you may also jump into sudden simple queries, as what I’d jumped into.

Update: This simple question was asked for the Huwaei International's written exam, held at Bangalore on July 2009.

Thursday, April 2, 2009

Inserting selected attribute values into a Table

Just imagine you’ve five fields (columns) in table & you only want to insert 2 values (say, in Col2 & Col3) of the table; then use as follows:

   1: INSERT INTO Table_Name (Col2_Name, Col3_Name)
   2:     VALUES (Col2_Value, Col3_Value)

Monday, February 16, 2009

cannot load file or assembly microsoft.sqlserver.management.sdk.sfc

The contents of this post has been moved here. Please follow the link to see the contents.

Sorry for the inconvenience.

Thanks.

 
Best viewed in Internet Explorer 8.