在sql中,可不可以用select语句取出某个列,并将该列赋值给一个变量
如果可以的话,该怎么写这条语句
参考答案:使用存储过程就可以!
CREATE PROCEDURE [dbo].[d_hotelsLogin]
@ID decimal =0 output,
@userID varchar(50),
@pwd varchar(50),
@log_ip varchar(50)
AS
begin
if not exists(select * from dbo.[hotels] where userID=@userID and pwd=@pwd)
begin
return 0
end
else
begin
select @ID = id from dbo.[hotels] where userID=@userID and pwd=@pwd
update dbo.[hotels] set log_time=getDate(),log_count=log_count+1,log_ip=@log_ip where id=@ID and dateDiff(d,log_time,getDate())<>0
return 1
end
end
GO