Click here to Skip to main content
15,913,584 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I heard that we can generate a dyanamic query using XML can we do that if we can do that how can we do that plz let me know

Thanks in Advance,
Vinay
Posted
Comments
Herman<T>.Instance 4-Aug-11 7:46am    
what have you tried?
any code to show?
wizardzz 4-Aug-11 12:29pm    
Every try using a stored procedure? Logic fits right in there.

You can try the Following Query Which takes the Table name and Columns name Dynamaically

SQL
DECLARE @sqlCommand varchar(1000)
DECLARE @columnList varchar(75)
DECLARE @table varchar(75)
SET @columnList = 'ExceptionTime,ExceptionMessage'
SET @table = 'ExceptionLog'
SET @sqlCommand = 'SELECT ' + @columnList + ' FROM ' + @table
print(@sqlCommand)
EXEC (@sqlCommand)
 
Share this answer
 
Hi,

Check the following links...

Execute Dynamic SQL commands in SQL Server[^]
dynamic SQL (Dynamic Structured Query Language)[^]

and check in "Codeproject" Articles

Regards,
GVPrabu
 
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