Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 select field with variable

Author  Topic 

djokerss
Starting Member

28 Posts

Posted - 2004-12-28 : 21:13:40

i have a table with field n1 int,n2 int,....n12 int ,
that field related with month,

can i make a query according of the month,
i mean if this month=12,
so the command just like select n(month) from my_table

nr
SQLTeam MVY

12543 Posts

Posted - 2004-12-28 : 21:17:33
Terrible structure

declare @sql varchar(1000)
select @sql = 'select n' + convert(varchar(2),datepart(mm.getdate())) + ' from my_table'
exec (@sql)


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -