如何判断一个数据是否存在
参数@name   varchar(50) 
 插入数据时用存储过程,先判断表中是否已存在这个数据(函数或存储过程实现);若已存在,不操作;不存在,插入数据 
 没有设置唯一性约束   
 求SQL语句,谢谢~~
------解决方案--------------------表结构不清,建议一语句: 
 Insert table TA(ID,....) 
 select @ID,.... where @ID not in (Select ID from TA)
------解决方案--------------------create function f_ifexists(@name varchar(50)) 
 returns int 
 as 
 begin 
 declare @i int 
 set @i=0 
 if exists(select 1 from 表 where 字段=@name) 
 set @i=1 
 return @i 
 end
------解决方案--------------------if not exists(select 1 from ta where name=@name) 
 insert ta values(@name) 
 else  
 print  '存在了  '
------解决方案--------------------create proc sp_check 
 ( 
 	@name varchar(50) 
 ) 
 if not exists (select * from 表 where username=@name) 
 	insert into ..   
 go
------解决方案--------------------create proc prExistData(@name varchar(50)) 
 as 
 begin 
   if exists(select * from test where a = @name) 
     print  'Data Exist! ' 
   else 
     insert test(列名) select @name 
 end 
 --测试 
 exec prExistData  '实际数据 '