可可:我不知道ID,我是根据另外一个字段Text来比较的 select id from tb where text = @text 然后呢?
create PROCEDURE dbo.TextExists ( @Text varchar(200), @ID bigint OUTPUT /* 如果存在返回ID,否则返回0 */ ) as if exists(select id from tb where text = @text) select @ID=id from tb where text=@text else set @ID=0 go
select id from tb where text = @text
然后呢?
(
@Text varchar(200),
@ID bigint OUTPUT /* 如果存在返回ID,否则返回0 */
)
as
if exists(select id from tb where text = @text)
select @ID=id from tb where text=@text
else
set @ID=0
go