June 3, 2013 at 1:06 pm
While passing parameters in exec statement can we use CAST or not.
I am getting error while using CAST to pass the parameters.
Example:
EXEC dbo.abc CAST(0 as bit), null
NOTE: I need to pass just two parameters..
Thanks in advance.
June 3, 2013 at 1:25 pm
monilps (6/3/2013)
While passing parameters in exec statement can we use CAST or not.I am getting error while using CAST to pass the parameters.
Example:
EXEC dbo.abc CAST(0 as bit), null
NOTE: I need to pass just two parameters..
Thanks in advance.
You can't use cast like in your example, but in your example you don't need to cast it anyway.
EXEC dbo.abc 0, null
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
June 3, 2013 at 1:41 pm
I was just using example.
I want date datatype to converted into datetimeoffset datatype while passing parameter.
Thanks for your help.
June 3, 2013 at 1:54 pm
monilps (6/3/2013)
I was just using example.I want date datatype to converted into datetimeoffset datatype while passing parameter.
Thanks for your help.
You shouldn't need to do any explicit conversion for that. It will do an implicit conversion.
create procedure testProc
(
@dt datetimeoffset
)
as select @dt
go
declare @someDate datetime = getdate()
exec testProc @someDate
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply