•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 426,187 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,827 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 15291 | Replies: 12 | Solved
![]() |
Well guys.. im new for MS SQL.. i have a solution & it worked perfectly with me.
while creating table just add an extra attribute using identity keyword:
so everytime you insert any row, it will increase 1. so there will a unique number for every row 
Regards!
while creating table just add an extra attribute using identity keyword:
attributename int identity(1,1)

Regards!
Last edited by puneetkay : Mar 6th, 2008 at 6:36 am.
•
•
Join Date: Nov 2007
Location: � Jogja �
Posts: 2,584
Reputation:
Rep Power: 11
Solved Threads: 235
mssql Syntax (Toggle Plain Text)
DELETE FROM emp e WHERE rowid>(SELECT MIN(ROWID) FROM emp WHERE e.empno=empno)
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Mar 2008
Location: Holland
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 1
Just solve the thing with a cursor
like
declare del_dups cursor
for
select * from <table_name>
group by column_name
having count(*) > 1
(column_name where the duplicates are)
open del_dups
fetch next from del_dups into ......
while @@fetch_status <> 0
begin
delete from table_name where current of cursor
fetch next from del_dups into ....
end
close del_dups
deallocate del_dups
For the update you should change te delete statement to
update table_name set ... = .... where current of cursor
like
declare del_dups cursor
for
select * from <table_name>
group by column_name
having count(*) > 1
(column_name where the duplicates are)
open del_dups
fetch next from del_dups into ......
while @@fetch_status <> 0
begin
delete from table_name where current of cursor
fetch next from del_dups into ....
end
close del_dups
deallocate del_dups
For the update you should change te delete statement to
update table_name set ... = .... where current of cursor
![]() |
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the MS SQL Forum
- Previous Thread: Database password authentication
- Next Thread: ctrl-m ??



Linear Mode