sql server 2000 - How to concatenate month number into table name -
i concatenate month number text build table names. example, trying retreive data may 2013, select webproxylog5.
the following script
select * webproxylog + '' + cast(month(dateadd(m,-2,getdate())) varchar(2)) + ''
will result in following error messsage:
msg 170, level 15, state 1, line 4 line 4: incorrect syntax near '+'.
what wrong syntax?
thank you,
seyed
you need build dynamic sql that,
declare @sql varchar(200) set @sql= 'select * webproxylog + ' + cast(month(dateadd(m,-2,getdate())) varchar(2)) exec(@sql)
Comments
Post a Comment