sql server - set date in create view -


i trying create view in sql server 2008 r2. need enter current date date import done. here have:

set nocount on; declare @sql varchar(4000)         --@cd date  --set @cd = convert(varchar(30), cast(getdate() date), 110)       -- insert statements procedure here set @sql = 'create view vw_gcs_export         select division, [primary image id],[item number], [brand name],[marketing description],     [colours]as colors,[live date],[sample type],substring([filename],charindex('+ char(39) + '_' + char(39) +',[filename],1)+1,charindex('+ char(39) + '.' + char(39) +',[filename],1)-5) batchid,     '+ char(39) + '670' + char(39) +' status, [primary image id] + '+ char(39) + '_p' + char(39) +' [shot name],     cast(null varchar(50))as [swatch/variation],cast(null varchar(50))as [alternate shot],[username],' + cast(convert(date,sysdatetime(),110)as varchar(10)) + ' [import date],     cast(null varchar(50))as [return instructions],cast(null varchar(50))as [rush request]     sheet1$'   exec (@sql) select * vw_gcs_export 

when results field importdate returned 2008. hoping 04/01/2013 or similar. need current date inserted field.

i have tried several cast , convert combinations , function returns current date , time no luck.

date literals need surrounded single quotes, need modify @sql escaped quotes surrounding date expression:

select ''' + cast(convert(date,sysdatetime(),110)as varchar(10)) + ''' [import date]' 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -