sql - Issue with stored procedure -
i have sybase stored procedure having issue.
here if use insert statement directly insert works shown:
insert dbo.studentdata ( studid , studletters , studcode , studtelecast , studname , monthcode , reportdate , starttime , endtime , startdatetime , enddatetime , cost , duration , creationtime ) values ( 113 , 'abcd' , 222 , 333 , 'one' , 02 , getdate() , getdate() , getdate() , getdate() , getdate() , 999 , 11 , getdate() ) ;
but if use stored proc i'm getting following error :
[exec - 0 row(s), 0.000 secs] [error code: 102, sql state: 42000] incorrect syntax near ')'. exec dbo.sp_loadstuddata(113, 'abcd', 222, 333, 'one', 02, getdate(), getdate(), getdate(), getdate(), getdate(), 999, 11, getdate() )
i not able find out issue stored proc got created without errors. stored proc foll:
create proc dbo.sp_loadstuddata ( @studid int, @studletters varchar(255), @studcode int, @studtelecast int, @studname varchar(25), @monthcode int, @reportdate datetime, @starttime datetime, @endtime datetime, @startdatetime datetime, @enddatetime datetime, @cost int, @duration int, @creationtime datetime ) begin set nocount on insert dbo.studentdata(studid,studletters,studcode ,studtelecast ,studname ,monthcode,reportdate,starttime,endtime,startdatetime,enddatetime,cost,duration,creationtime) values(@studid,@studletters,@studcode ,@studtelecast ,@studname ,@monthcode,@reportdate,@starttime,@endtime,@startdatetime,@enddatetime,@cost,@duration,@creationtime) end go exec sp_procxmode 'dbo.sp_loadstuddata', 'unchained' go if object_id('dbo.sp_loadstuddata') not null print '<<< created procedure dbo.sp_loadstuddata >>>' else print '<<< failed creating procedure dbo.sp_loadstuddata >>>' go grant execute on dbo.sp_loadstuddata developers go grant execute on dbo.sp_loadstuddata web_group go grant execute on dbo.sp_loadstuddata crd_group go grant execute on dbo.sp_loadstuddata wd_group go
i'm no expert on sybase in sql server need store getdate() return value in variable first.
i.e. cant...
exec myproc getdate(), getdate(), getdate()
but can
declare @now datetime set @now = getdate() exec myproc @now, @now, @now