CREATE PROCEDURE ReFolderName @tableName text,@length int,@compareText text,@intResult int output
As
begin
if @tableName is null
select @intResult = 0
return
exec('Select * from '+ @tableName+ 'where left(path,'+@length+')='+@compareText)
if @@ROWCOUNT <= 0
select @intResult='0'
else
select @intResult='1'
end
GO
As
begin
if @tableName is null
select @intResult = 0
return
exec('Select * from '+ @tableName+ 'where left(path,'+@length+')='+@compareText)
if @@ROWCOUNT <= 0
select @intResult='0'
else
select @intResult='1'
end
GO
需要用到动态语句。
exec('Select * from '+ @tableName+ 'where left(path,'+@length+')='+convert(varchar(8000),@compareText))
参数没有加括号