Answer Posted / divya mahendra sikarwar
Execute queries:
CREATE TABLE dbo.Test1 (
[ID] [int] ,
[FirstName] [varchar](25),
[LastName] [varchar](25)
) ON [PRIMARY]
INSERT INTO Test1 VALUES(1, ‘Bob’,'Smith’)
INSERT INTO Test1 VALUES(2, ‘Dave’,'Jones’)
INSERT INTO Test1 VALUES(3, ‘Karen’,'White’)
INSERT INTO Test1 VALUES(1, ‘Bob’,'Smith’)
INSERT INTO Test1 VALUES(4, ‘Bobby’,'Smita’)
select identity(int,1,1) as SlNo,* into #temp from Test1
DELETE
FROM #temp
WHERE SlNo NOT IN
(
SELECT MAX(SlNo)
FROM #temp
GROUP BY ID,FirstName,lastname
)
drop table test1
select * into test1 from #temp
alter table test1 drop column SlNo
select * from test1 order by id
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
Differentiate between mongodb vs. Sql server?
What are the advantages dts has over bcp?
Explain atomicity?
How to deploy the Report?
How to create a simple user defined function in ms sql server?
What is self contained sub query?
What is bcp? When does it used?
Why de-normalization required?
Explain about unique identifier data type in sql server?
What command would you use to create an index?
How to get a list of all tables with "sys.tables" view in ms sql server?
What is tempdb database? : SQL Server Architecture
How do database indexes work?
Explain different types of locks in sql server.
How to store and query spatial data?