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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Dynamically select columns based on value in table
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mossbs
Starting Member

11 Posts

Posted - 10/30/2013 :  07:24:09  Show Profile  Reply with Quote
***REPOST FROM 2012 TSQL FORUM**

(excuse the repost only just noticed I'd stuck it in the 2012 forum rather than the 2005 one)

Hi guys,

Is it possible to have a dynamically created select statement that selects columns based on a value in a table?

Basically I have a report script that does a count of how many times a certain job appears on quotes...this was fine when first launched but now new jobs can be added and old ones deactivated. Each job has a entry in a JobDefinition table with a 'Status' column showing 'ATV' (active) or 'INA' (inactive).

So... Is it possible to include a count for each of the jobs only where they are active?

Final format required is that each Job has its own column - as the results shall be grouped by dealer/company that raised them...

Cheers guys - any help much appreciated!

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 10/30/2013 :  08:16:30  Show Profile  Reply with Quote
already replied in other thread
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=189261

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000