|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Pass datetime as parameter to SPmy SP like this
CREATE PROCEDURE dbo.sel_apinv_nonsettle @cocode varchar(10), @billcode varchar(10), @issuedate datetime, @branchid varchar(10), @accttype varchar(10) IN SQL Analyzer, exec sel_apinv_nonsettle 'CNC','CNC',getdate,'HLSHK','APINV' and i got this error "Server: Msg 8114, Level 16, State 4, Procedure sel_apinv_nonsettle, Line 0 Error converting data type nvarchar to datetime." What's wrong ?? Hi
Probably you need to put it this way IN SQL Analyzer, exec sel_apinv_nonsettle 'CNC','CNC',getdate(),'HLSHK','APINV' getdate() is a function -- Show quotebest Regards, Chandra http://chanduas.blogspot.com/ http://www.developersdex.com/gurus/default.asp?p=4223 --------------------------------------- "Agnes" wrote: > my SP like this > CREATE PROCEDURE dbo.sel_apinv_nonsettle > @cocode varchar(10), > @billcode varchar(10), > @issuedate datetime, > @branchid varchar(10), > @accttype varchar(10) > > IN SQL Analyzer, > exec sel_apinv_nonsettle 'CNC','CNC',getdate,'HLSHK','APINV' > > and i got this error "Server: Msg 8114, Level 16, State 4, Procedure > sel_apinv_nonsettle, Line 0 > Error converting data type nvarchar to datetime." > > What's wrong ?? > > > Stored Proc Parameters can only be constants, or T-SQL Variables... You cnnot
directly pass an expression, or a function, to a stored proc... And even if you could, the function getdate would require the open closed parenethses at the end -- getdate()... What you need to do is create a T-SQL Variable, set it to be equal to getdate(), and then pass that variable. Declare @GDT DateTime Set @GDT = getdate() -- ("Current_TimeStamp" is ANSI-SQL Standard) exec sel_apinv_nonsettle 'CNC','CNC',@GDT,'HLSHK','APINV' exec sel_apinv_nonsettle 'CNC','CNC',getdate,'HLSHK','APINV' Show quote "Agnes" wrote: > my SP like this > CREATE PROCEDURE dbo.sel_apinv_nonsettle > @cocode varchar(10), > @billcode varchar(10), > @issuedate datetime, > @branchid varchar(10), > @accttype varchar(10) > > IN SQL Analyzer, > exec sel_apinv_nonsettle 'CNC','CNC',getdate,'HLSHK','APINV' > > and i got this error "Server: Msg 8114, Level 16, State 4, Procedure > sel_apinv_nonsettle, Line 0 > Error converting data type nvarchar to datetime." > > What's wrong ?? > > > |
|||||||||||||||||||||||