如何检查SQL Server中的表中是否存在特定记录?

我想检查用户表中是否存在id 10的记录.

我试图在sql中使用exists关键字,但是我无法确定使用exists来查看是否存在记录的正确语法.

我想要下面的东西

If ( exist (select id * from table where Id = id ) ) 
{

}

解决方法

使用Exist关键字非常简单,
我在下面写了正确的语法,看看
if exists (select * from  [dbo].[table] where id= [the id you want to check] ) 
select 'True'  
else 
select 'False' 
return

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...