>Hi everybody!
>
> is it possible to use macro substitutions in SQL 7 in order to update a column, let me explain a little bit more:
>
> I have a table with next columns:
> Cell,year, W1, W2, W3, W4, W5, ... W52 (W = Week)
>
> And I need to update this columns with a single 'Update' statement but I can't figure out how can achieve this. In foxpro is very ease: using the macro (&) but the most similar function is COL_NAME but it can't be used in this statement.
>
>Any Idea
>
>Best Regards
>
Martin,
In SQL Server 7/2000, you can build a dynamic SQL statement and use the SP_EXECUTE stored produre. Ex.
declare @cSQL nvarchar(4000)
set @cSQL = N'update mytable set W' + convert(nvarchar(2),datepart(wk,getdate())) +
N' = somevalue where mytable.pk = somepk'
exec sp_executesql @cSQL
HTH.
Larry Miller
MCSD
LWMiller3@verizon.netAccumulate learning by study, understand what you learn by questioning. -- Mingjiao