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 |
|
Sep410
Posting Yak Master
117 Posts |
Posted - 2008-07-22 : 16:38:19
|
| Hi,I don't know what is wrong with this Cursor. Please help me:create procedure SP_Cityas set nocount ondeclare @Des as varchar(50)create table temp(Desci varchar(50))declare SP_City CURSOR FORSELECT TOP 100 PERCENT Description FROM Csms.dbo.tbl_City ORDER BY Description open SP_CityFetch next from SP_Cityinto @DesWhile(@@FETCH_Status=0 )insert Into Temp(Desci) values (@Des)Fetch next from SP_City into @DesEnd Close SP_CityDeallocate SP_CityGoHere is an error I get:Server: Msg 156, Level 15, State 1, Procedure SP_City, Line 13Incorrect syntax near the keyword 'End'.Thanks,Sep |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2008-07-22 : 16:45:19
|
The real problem is that you are not simply doing this:insert into Temp(Desci)select descriptionfrom Cms.dbo.tbl_Cityorder by description Another problem might be that you are using a "temporary" table called Temp, when you probably don't need it ....- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
Sep410
Posting Yak Master
117 Posts |
Posted - 2008-07-22 : 16:48:50
|
| Thanks JeffSep |
 |
|
|
|
|
|