防止ADO连接SQLServer时的隐式连接
2007-11-11 05:19:14 来源:WEB开发网核心提示: declare @user nvarchar(20) select @user='user1' use countme /*判断用户是否存在*/ declare @userweek int select @userweek=[week] from base where userid=@user sel
declare @user nvarchar(20)
select @user='user1'
use countme
/*判断用户是否存在*/
declare @userweek int
select @userweek=[week] from base where userid=@user
select @@rowcount
if @@rowcount=0
return
select @userweek
最后的@userweek打印出来的结果就是记录用户名为user1的week字段的值
而当我们用下面的语句选择所有记录时(没有where限制)
declare @user nvarchar(20)
select @user='user1'
use countme
/*判断用户是否存在*/
declare @userweek int
select @userweek=[week] from base
select @@rowcount
if @@rowcount=0
return
select @userweek
最后@userweek打印出来的值是返回的所有记录中排名最后一条记录的week字段值
更多精彩
赞助商链接