日期:2014-05-17 浏览次数:20535 次
ALTER PROCEDURE [dbo].[CreateResult]
@UserName varchar(50),
@TableName varchar(255),--表名
@StrWhere nvarchar(1000)='' , --查询条件
@resultTable varchar(50)
AS
declare @str nvarchar(4000)
declare @searchtable varchar(50)
set @searchtable=@UserName+'_searchTable'
if @StrWhere !=''
set @str='select * from '+@TableName +' where '+@StrWhere
else
set @str='select * from '+@TableName
set @str='insert into '+@resultTable+' '+@str+' update '+@searchtable+' set result=1 where resultTable='+@resulTable+''
exec (@str)
ALTER PROCEDURE [dbo].[CreateResult]
@UserName varchar(50),
@TableName varchar(255),--表名
@StrWhere nvarchar(1000)='' , --查询条件
@resultTable varchar(50)
AS
declare @str nvarchar(4000)
declare @searchtable varchar(50)
set @searchtable=@UserName+'_searchTable'
if @StrWhere !=''
set @str='select * from '+@TableName +' where '+@StrWhere
else
set @str='select * from '+@TableName
set @str='insert into '+@resultTable+' '+@str+'; update '+@searchtable+' set result=1 where resultTable='''+@resultTable+''''
exec (@str)
ALTER PROCEDURE [dbo].[CreateResult]
@UserName VARCHAR(50) ,
@TableName VARCHAR(255) ,--表名
@StrWhere NVARCHAR(1000) = '' , --查询条件
@resultTable VARCHAR(50)
AS
DECLARE @str NVARCHAR(4000)
DECLARE @searchtable VARCHAR(50)
SET @searchtable = @UserName + '_searchTable'
IF @StrWhere != '' SET @str = 'select * from ' + @TableName + ' where '
+ @StrWhere
ELSE
SET @str = 'select * from ' + @TableName
SET @str = 'insert into ' + @resultTable + ' ' + @str + ' update '
+ @searchtable + ' set result=1 where resultTable=' + @resultTable
+ ''
EXEC (@str)
在执行完这条语句的时候
set @str='select * from '+@TableName
把变量打印出来看一下,再执行一下打印出来的sql 看哪出问题了
如果没问题再打印下一条sql