Write a query to delete duplicate records in SQL SERVER
Answer Posted / bala_it243
using the following query u can delete the duplicate records.
but it is available only on SQL Server 2005.
with mytable as
(
select *, ROW_NUMBER() OVER(partition by id,myname order by
id desc) as RowNumber from test
)
delete from mytable where rownumber>1
"Have a Great Day"
Bala
| Is This Answer Correct ? | 16 Yes | 5 No |
Post New Answer View All Answers
Do you know what is normalization of database? What are its benefits?
Write a query to find 5th highest amount paid from the customer table.
what is a transaction and what are acid properties? : Sql server database administration
This question asked during interview, 2) At the end of each month, a new table is created for each bank that contains monthly metrics consolidated at the account level. The table naming convention is bankX_YYYYMM where X represents the numeric designation of the bank and YYYYMM indicates the 4 digit year and 2 digit month. The tables contain the following fields: name data type description account text account number registered boolean indicates whether the account is registered num_trans integer number of transactions made during the time period spend numeric(9,2) total spend during the time period a) Write a SQL query that will display the total number of transactions and total spend for "Bank1" during the 4th quarter of 2009. b) Write a SQL query that will display the total number of transactions and total spend at "Bank1" and "Bank2", broken out by registered vs. non-registered accounts, during January 2010 not sure what is correct answer and how to solve?
How do we know if any query is retrieving a large amount of data or very little data?
How to scale out a federation by Sql statement?
How does index makes search faster?
What is the difference between functions and stored procedures?
what is new philosophy for database devises for sql server 7.0? : Sql server database administration
You are designing a database for your human resources department in the employee table, there is a field for social security number, which cannot contain null values if no value is given, you want a value of unknown to be inserted in this field what is the best approach?
How to create a dml trigger using create trigger statements?
Can you import Microsoft Excel data to SSRS?
Explain the Ways to improve the performance of a sql azure database?
How do you debug a procedure in sql server?
What should be the fill factor for indexes created on tables? : sql server database administration