Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rushdib
Yak Posting Veteran
93 Posts |
Posted - 2004-03-12 : 09:56:55
|
| declare @sql nvarchar(1000)set @sql = 'select ' + getdate() + '' exec sp_executesql @sqlprint @sqlI am getting the following error:Syntax error converting datetime from character string.How do I fix this?Thank you,Rushdi |
|
|
raymondpeacock
Constraint Violating Yak Guru
367 Posts |
Posted - 2004-03-12 : 10:05:28
|
| You need to use either CAST or CONVERT around the GETDATE to encase it within the string. for exampleset @sql = 'select ' + convert(varchar(8), getdate(), 112) + '' exec sp_executesql @sqlprint @sqlRaymond |
 |
|
|
rushdib
Yak Posting Veteran
93 Posts |
Posted - 2004-03-12 : 12:08:53
|
| That worked, thank you |
 |
|
|
|
|
|