create proc getTitleName_proc
@sort_name varchar(50)
as 
begin
set nocount on
select title_name from title 
where left(sort_id,3) in 
(select distinct sort_parentid from sort where sort_name=@sort_name)
set nocount off
end

解决方案 »

  1.   

    create proc getTitleName_proc
    @sort_name varchar(50)
    as 
    begin
    set nocount on
    select title_name from title 
    where sort_id in (select sort_id from sort where sort_name=@sort_name)
    set nocount off
    end
    ---------------------------------------
    exec getTitleName_proc, 'computer'
      

  2.   

    请问这个set nocount on起的作用是什么?一定要用set nocount on吗?
      

  3.   

    当 SET NOCOUNT 为 ON 时,将不给客户端发送存储过程中的每个语句的 DONE_IN_PROC 信息。当使用 Microsoft® SQL Server™ 提供的实用工具执行查询时,在 Transact-SQL 语句(如 SELECT、INSERT、UPDATE 和 DELETE)结束时将不会在查询结果中显示"nn rows affected"。如果存储过程中包含的一些语句并不返回许多实际的数据,则该设置由于大量减少了网络流量,因此可显著提高性能。