declare @StrTotalSQL nvarchar(3000)
SET @StrTotalSQL='select count(*) from table'
exec(@StrTotalSQL)
if select @StrTotalSQL<>0
begin
select '有记录'
end
go统计不出来结果呢!select @StrTotalSQL<>0 这里要怎么取出查询语句返回的结果啊!
SET @StrTotalSQL='select count(*) from table'
exec(@StrTotalSQL)
if select @StrTotalSQL<>0
begin
select '有记录'
end
go统计不出来结果呢!select @StrTotalSQL<>0 这里要怎么取出查询语句返回的结果啊!
SET @StrTotalSQL='(select count(*) from table)' --加括号
exec(@StrTotalSQL)
if select @StrTotalSQL<>0
begin
select '有记录'
end
go
if 后面怎么能跟这.select @StrTotalSQLfa返回的是select count(*) from table跟0肯定不相等啊
declare @RC intselect @RC = count(*) from table
if @RC <> 0
begin
select '有记录'
end
go
declare @StrTotalSQL nvarchar(3000)
declare @cnt int
SET @StrTotalSQL='select @cnt=count(*) from table'
exec sp_executesql @StrTotalSQL,N'@cnt int output',@cnt output
if @cnt<>0
begin
select '有记录'
end
go
declare @StrTotalSQL nvarchar(3000)select @StrTotalSQL=count(*) from layoutif @StrTotalSQL<>0
begin
select '有记录'
end
go
declare @intTotal as integerselect @intTotal = COUNT(*) from TABLE if @intTotal<>0 select '有记录'
SET @StrTotalSQL='(select count(*) from department)' --加括号
exec(@StrTotalSQL)
if @StrTotalSQL<>'0' --StrTotalSQL是nvarchar类型,将0加个单引号就可以了
begin
select '有记录'
end
go