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
 Assistance with Select please

Author  Topic 

dnorman
Starting Member

2 Posts

Posted - 2009-12-30 : 13:25:32
Hello,

I am wondering if it is possible to do the following:

Get a result set from one select statement
eg:
A001
A002
A003
A004
etc

and then use them in another select statement as column names
eg:
SELECT A001WATER FROM.......


Any help is most appreciated.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-12-30 : 13:35:14
Search for "dynamic sql" on this site please.
Without dynamic sql it is not possible.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-31 : 04:29:30
www.sommarskog.se/dynamic_sql.html

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-12-31 : 04:31:08
might want to read this:
http://www.sommarskog.se/dynamic_sql.html

DAMN YOU madhivanan


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
[
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-31 : 04:49:25
quote:
Originally posted by Transact Charlie

might want to read this:
http://www.sommarskog.se/dynamic_sql.html

DAMN YOU madhivanan


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
[


You should be very fast

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

dnorman
Starting Member

2 Posts

Posted - 2009-12-31 : 13:55:36
Thank you very much for the help. After reading the material you guys led me too, I chose to re-design my data requirements. I appreciate the advice.

Thanx
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-04 : 01:48:44
quote:
Originally posted by dnorman

Thank you very much for the help. After reading the material you guys led me too, I chose to re-design my data requirements. I appreciate the advice.

Thanx


That's good and you are welcome

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -