Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Post Merged (destination) from stackoverflow.com/questions/7680971/…
added 6 characters in body
Source Link
Mikael Eriksson
  • 139.4k
  • 22
  • 223
  • 293

This is not a query but a delete statement. It will delete/remove duplicate rows from your table

;with C as ( select row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_IDNODE_EQ_NO) as rn from yourtable ) delete C where rn > 1 

If you are only interested in querying the table and get the non duplicates as a result you should use this instead.

;with C as ( select *, row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_IDNODE_EQ_NO) as rn from yourtable ) select * from C where rn = 1 

This is not a query but a delete statement. It will delete/remove duplicate rows from your table

;with C as ( select row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_ID) as rn from yourtable ) delete C where rn > 1 

If you are only interested in querying the table and get the non duplicates as a result you should use this instead.

;with C as ( select *, row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_ID) as rn from yourtable ) select * from C where rn = 1 

This is not a query but a delete statement. It will delete/remove duplicate rows from your table

;with C as ( select row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_EQ_NO) as rn from yourtable ) delete C where rn > 1 

If you are only interested in querying the table and get the non duplicates as a result you should use this instead.

;with C as ( select *, row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_EQ_NO) as rn from yourtable ) select * from C where rn = 1 
deleted 1 characters in body
Source Link
Mikael Eriksson
  • 139.4k
  • 22
  • 223
  • 293

This is not a query but a delete statement. It will delete/remove duplicate rows from your table

;with C as ( select row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_ID) as rn from yourtable ) delete C where rn > 1 

If you are only interested in querying the table and get the non duplicates as a result you should use this instead.

;with C as ( select *, row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_ID) as rn from @yourtableyourtable ) select * from C where rn = 1 

This is not a query but a delete statement. It will delete/remove duplicate rows from your table

;with C as ( select row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_ID) as rn from yourtable ) delete C where rn > 1 

If you are only interested in querying the table and get the non duplicates as a result you should use this instead.

;with C as ( select *, row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_ID) as rn from @yourtable ) select * from C where rn = 1 

This is not a query but a delete statement. It will delete/remove duplicate rows from your table

;with C as ( select row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_ID) as rn from yourtable ) delete C where rn > 1 

If you are only interested in querying the table and get the non duplicates as a result you should use this instead.

;with C as ( select *, row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_ID) as rn from yourtable ) select * from C where rn = 1 
added 367 characters in body
Source Link
Mikael Eriksson
  • 139.4k
  • 22
  • 223
  • 293

This is not a query but a delete statement. It will delete/remove duplicate rows from your table

;with C as ( select row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_ID) as rn from yourtable ) delete C where rn > 1 

If you are only interested in querying the table and get the non duplicates as a result you should use this instead.

;with C as ( select *, row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_ID) as rn from @yourtable ) select * from C where rn = 1 

This is not a query but a delete statement. It will delete/remove duplicate rows from your table

;with C as ( select row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_ID) as rn from yourtable ) delete C where rn > 1 

This is not a query but a delete statement. It will delete/remove duplicate rows from your table

;with C as ( select row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_ID) as rn from yourtable ) delete C where rn > 1 

If you are only interested in querying the table and get the non duplicates as a result you should use this instead.

;with C as ( select *, row_number() over(partition by DUPLICATE_VAARS_DECISION order by NODE_ID) as rn from @yourtable ) select * from C where rn = 1 
Source Link
Mikael Eriksson
  • 139.4k
  • 22
  • 223
  • 293
Loading