Please start any new threads on our new site at 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
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  

Starting Member

11 Posts

Posted - 10/30/2013 :  07:24:09  Show Profile  Reply with Quote

(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!

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 10/30/2013 :  08:16:30  Show Profile  Reply with Quote
already replied in other thread

SQL Server MVP
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.02 seconds. Powered By: Snitz Forums 2000