Dynamiclly creating dynamic tables that have varing amounts of columns
MySQL
1
Posts
1
Posters
6
Views
1
Watching
-
In MS Sql Server 2005 I want to create a Stored procedure that will generate a report. However I don't want to have to recreate or update stored procedures when the number of columns increase or decrease. Here is what I am needing. I need to create a dynamic table that will increase the number of columns in that table based on the results of the select statement. Sample: Select PartName from Parts --PartName will return anywhere between 5 to 200 results or more. DECLARE @ToolsTrackingBoard as TABLE ( JobNumber int, [Job Name] [nvarchar](100) ...All the additional column names are the names from the (Select partname from Parts) query. ) select * from @ToolsTrackingBoard How can I do this? I have been hunting for days.