• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • SQL Server對select語句返回多條記錄給變量賦值時的處理情況

    發表于:2007-07-13來源:作者:點擊數: 標簽:
    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打印出來的
    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字段值
      

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>