General information
Forum:
Microsoft SQL Server
Title:
Convert string to datetime
Environment versions
SQL Server:
SQL Server 2000
Hello.
I have a question.
If I have something like this:
declare @cmd varchar (4000)
declare @server varchar(20),@base varchar (20)
declare @monto varchar(20)
declare @num varchar(20)
declare @date datetime
set @server='CPSI-SERVER'
set @base='reaseguro'
set @monto=123.456
set @num=22
set @date='20061212'--(select getdate())--'10/12/2006'
set @cmd= 'insert into ['+@server+'].['+@base+'].[dbo].[prubtrig]
([monto],[numero],[fecha])values('+@monto+','+@num+','+@date+')'
exec (@cmd)
where ([monto],[numero],[fecha]) are (decimal,int,datetime) and I need put this parameters whit variables.
But SQL say sintaxis error to convert a string in a datetime.
I can put [monto] and [numero] like varchar but [fecha] I can't.
How can I put the date?
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only