Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Declare Query in Temp table in Sql Server.

SELECT @cols = COALESCE (@cols + ',[' + [Name] + '] INT', '[' + [Name] + '] INT')      
FROM    CaseTypeMaster      

Select  @cols then display below result 
[Employee Related] INT,[Customer Related] INT,[HR Related] INT,[Grievance Redressal] INT

which i want to insert dynamically into temptable parameter   
DECLARE @TempTable AS TABLE ([Employee Related] INT,[Customer Related] INT,[HR Related] INT,[Grievance Redressal] INT)

DECLARE @TempTable AS TABLE (@cols) 

It is possible or not ?

Any one to know the solution ?

Display CaseTypeMaster table record display in @TempTable Column.
Updated 20-Jul-12 23:47pm
Sandeep Mewara 18-Jul-12 14:50pm    
Not clear. You want to insert data in temptable?
ZurdoDev 18-Jul-12 16:26pm    
It looks like you copied this from something that has nothing to do with what you are asking. But then again, it is not clear what you are asking.
Tejas Vaishnav 19-Jul-12 2:04am    
what are your trying to do with this...?
not clear...
Sebastian T Xavier 20-Jul-12 12:53pm    
I don't understand your issue
Christian Graus 20-Jul-12 18:13pm    
Could people please stop asking this guy questions - he's clearly not answering

1 solution

INSERT INTO @TempTable (columnName)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900