|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Problem with a stored procedure
I am using a stored procedure and executing it from a string, to make it easy to modify. I am passing is a select as varchar(max) as well as a date as datetime, when I rune my execute(sp); I get an error "Conversion failed when converting datetime from character string.". if anyone has any suggestions they will be much appreciated, thanks.
|
|
#2
|
||||
|
||||
|
can you post your stored procedure? please also post how and where you call it?
this will make it easier to help you. |
|
#3
|
|||
|
|||
|
I figured out what I needed to do:
Code:
'query . . . WHERE (date = ''' + cast(@today as nvarchar(50)) + ''') . . . query continued'. thanks for your help. |
|
#4
|
|||
|
|||
|
Check what your default DateFormat is
My Server defaults to American style mm/dd/yyyy, but I typically write the UK dd/mm/yyyy so when using strings as dates I often get the conversion error. I have to put SET DATEFORMAT DMY somewhere before the command using the date (ie at the start of the stored procedures). |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Problem with a stored procedure |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|