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
 General SQL Server Forums
 New to SQL Server Programming
 Passing Column as Parameter

Author  Topic 

sqlr2
Starting Member

4 Posts

Posted - 2014-08-01 : 02:54:45
Hi all,

I have a table with month names as columns, below is the structure

CREATE TABLE [MonthlyTarget]
(
[Jan] [int] NULL,
[Feb] [int] NULL,
[March] [int] NULL,
[April] [int] NULL,
[May] [int] NULL,
[June] [int] NULL,
[July] [int] NULL,
[August] [int] NULL,
[September] [int] NULL,
[October] [int] NULL,
[November] [int] NULL,
[December] [int] NULL,
)

I will store some integer values in these columns,

I want to pass these column names as a parameter,and pull the data from the column.

How to do this..?

sample with code is appreciated.

Thank You

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-08-01 : 02:57:15
if you are looking to pull the data from the same table then use this
select * from MonthlyTarget
where December=yourvalue
if you want to pull the data from some other table you need to have a relation between your month table and the other table.

Javeed Ahmed
Go to Top of Page
   

- Advertisement -