Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sabirulla
Starting Member
1 Post |
Posted - 2011-05-12 : 06:38:36
|
| PRINT '-------------------------------------------'PRINT 'Cursor To update the the Name with concatenate increment by 1'PRINT '-------------------------------------------'DECLARE @AgentName varchar(50)DECLARE @count intDECLARE GetAgentTotals CURSOR FORWARD_ONLY FOR SELECT name FROM tablenameOPEN GetAgentTotalsFETCH NEXT FROM GetAgentTotals INTO @AgentNameset @count=0WHILE @@FETCH_STATUS = 0 BEGIN --PRINT @AgentName set @count = @count+1 FETCH NEXT FROM GetAgentTotals INTO @AgentName --PRINT @count DECLARE @varcount varchar(50) DECLARE @name varchar(20) set @varcount = @count set @name = @AgentName PRINT @name+@varcount UPDATE tablename SET name=@name+@varcount where id=@count END CLOSE GetAgentTotalsDEALLOCATE GetAgentTotalssabirulla |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-05-12 : 06:49:21
|
what is your question ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
raghuveer125
Constraint Violating Yak Guru
285 Posts |
Posted - 2011-05-12 : 06:51:37
|
| Which Field you want to increase?In Love... With Me! |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-05-12 : 07:22:17
|
This one line will do the same:UPDATE tablename SET name=name+convert(varchar(10),id) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|