>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?
set @cmd= 'insert into ['+@server+'].['+@base+'].[dbo].[prubtrig]
([monto],[numero],[fecha])values('+@monto+','+@num+','''+CONVERT(varchar(8),@date,112)+''')'
exec (@cmd)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.