I need to insert a datetime value into datetime column in SQL Server 2005
I am passing DateTime variable from the .aspx page
Which needs to be inserted in the column.
Example:
Table(date datetime)
@sql = 'insert into Table (date) values('+@datetime+')'
exec(@sql)
getting conversion failed message.
Any idea how to do this.
Very Urgent.
Thanks.
You need string delimiters – in T-SQL this is doubled-up single quotes.
However it still might fail, depending on the format of the string. Any reason you’re building a SQL string, prone to SQL injection, instead of just saying:
?