在赋值上两者等价,但select可以同时给多个变量复制赋值,另外select 可以在查询中给变量赋值--各多个变量赋值
select @a=1,@b=2,@c=3--查询语句中赋值
select @a=count(1) from 表

解决方案 »

  1.   

    你试下就知道了.请看下面测试语句:
    use pubs
    go
    declare @s1 varchar(10),@s2 varchar(10)
    set @s1=10
    set @s2=10
    select @s1=au_lname from authors where 1=2
    set @s2=(select au_lname from authors where 1=2)
    select @s1,@s2
      

  2.   

    use pubs
    go
    declare @s1 varchar(10),@s2 varchar(10)
    set @s1=10
    set @s2=10
    select @s1=au_lname from authors where 1=2
    set @s2=(select au_lname from authors where 1=2)
    select @s1 as 'select',@s2 as 'set'
    /*
    select     set        
    ---------- ---------- 
    10         NULL(所影响的行数为 1 行)
    */
      

  3.   

    同意 vivianfdlpw() 的观点
      

  4.   

    http://community.csdn.net/Expert/TopicView3.asp?id=4152055--这个帖子的Eric2000说:
    select 可以实现 set的赋值功能;
    在用select 进行赋值操作时,会产生系统输出,而set则不会产生输出,因此在SQL2000 中建议不要使用select进行赋值而用set进行赋值.
    不过我没有看到官方的说法