February 7, 2013 at 9:04 am
How can I display the resulting select statement from a dynamic SQL stored procedure? So I can see what @sql actually looks like?
Given this Stored procedure:
create PROCEDURE [dbo].[sp_UnionTables](@table1 varchar(100),
@table2 Varchar(100), @ColumnList varchar(1000) )
AS
declare @sql varchar(8000);
set @sql = 'SELECT ''' + @table1 + ''' AS TableName, ' + @ColumnList +
' FROM ' + @Table1 + ' UNION ALL SELECT ''' + @table2 + ''' As TableName, ' +
@ColumnList + ' FROM ' + @Table2
exec ( @sql)
Thanks
February 7, 2013 at 9:07 am
replace EXEC with either SELECT or PRINT, e.g. PRINT( @sql)
---------------------------------------------------------
It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens[/url]
Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
February 7, 2013 at 9:10 am
Working...
Thanks
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply