0

我正在寻找在 Microsoft SQL Server Management Studio R2 上提供以下操作的解决方案:

  • 从数据库中检索一些记录,表 EX
  • 如果查询没有返回记录,则在 MS SQL Server Management Studio 输出部分区域中显示一条消息。
4

1 回答 1

2

使用以下代码

declare @n int
set @n = (select ISNULL(count(*),0) from table_name)
if(@n=0)
print 'not result'
else
select * from table_name

或者

if(select count(*) from table_name)=0
print 'not result'
else
select * from table_name
于 2013-01-27T18:04:38.490 回答