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 |
shubhada
Posting Yak Master
117 Posts |
Posted - 2006-08-02 : 06:57:43
|
I have table with Colum key likekey 123456i want to update this column like as below234567so I have write one procALTER proc cm__update_testasbegindeclare @TitleKey numeric(3,0)declare cm_cursor cursor forselect key from Table where key open cm_cursorfetch cm_cursor into @TitleKeywhile @@fetch_status = 0 begin update SecurityModule set ModKey = ModKey + 1 FETCH next from cm_cursor into @TitleKey endclose cm_cursordeallocate cm_cursorreturn endPlease tell me where I am wrongabove proc is nopt working properly |
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-08-02 : 07:02:42
|
you dont require cursor for this .. update SecurityModuleset ModKey = ModKey + 1I guess this should be fine for incrementing the column data by 1 Chirag |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2006-08-02 : 07:02:53
|
Don't use a cursor. simply update SecurityModule set ModKey = ModKey + 1For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2006-08-02 : 07:03:15
|
For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
|
|
shubhada
Posting Yak Master
117 Posts |
Posted - 2006-08-02 : 07:21:13
|
but suppose i want to update key from 3 key 123456Result should be124567SQLTeam |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-08-02 : 07:27:25
|
update SecurityModuleset ModKey = ModKey + 1where modkey >= 3Peter LarssonHelsingborg, Sweden |
|
|
|
|
|