sql server - Please help correct this cursor SQL -


 declare @abc varchar(max);  declare @useipdtaskdeadline int = 1;   declare tocreatetaskcursor cursor              totaltask (             select  abc table1        )        select abc totaltask  read  open tocreatetaskcursor fetch tocreatetaskcursor @abc  while @@fetch_status = 0 begin -- @@fetch_status = 0     print ''      begin transaction;      if (@useipdtaskdeadline = 1)          print 'updates completed'; end  if (@useipdtaskdeadline = 0)      print 'updates completed'; end;  commit transaction;      fetch tocreatetaskcursor @abc end -- @@fetch_status = 0  close tocreatetaskcursor deallocate tocreatetaskcursor 

this throws errors:

msg 102, level 15, state 1, line 117
incorrect syntax near ';'.

msg 156, level 15, state 1, line 126
incorrect syntax near keyword 'close'.

please tell me incorrect ? have tried lot cannot make work. there issue if else syntax ? using sql server.

i have tried many if else syntaxes cannot make work.

if (@useipdtaskdeadline = 1) begin   print 'updates completed'; end if (@useipdtaskdeadline = 0) begin  print 'updates completed'; end 

issue if not using begin ,end properly


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -