如何实现:判断数据库中某表是否有记录,若为空,则插入一条记录。若不为空则查询某记录

select count(*) as num1 from table
if num1 = 0
insert into ...
else
select * from table....

SQL的过程如下:
Select top 1 * from table
if @@rowcount>0 --上一次影响条数
insert into Table --插入语
else
Select * from Table --查询
原文地址:https://www.cnblogs.com/watermarks/p/3360770.html