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 2005 Forums
 Transact-SQL (2005)
 Dynamically select columns based on value in table

Author  Topic 

mossbs
Starting Member

11 Posts

Posted - 2013-10-30 : 07:24:09
***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

52326 Posts

Posted - 2013-10-30 : 08:16:30
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
   

- Advertisement -