我一直在搜索所有网站和书籍。我的问题是,我是否需要将' @'当我在存储过程中声明游标时,符号到局部变量? 例如:
create procedure au_sales (@author_id id)
as
/* declare local variables used for fetch */
declare @title_id tid
declare @title varchar(80)
declare @ytd_sales int
declare @msg varchar(120)
/* declare the cursor to get each book written
by given author */
declare author_sales cursor for
select ta.title_id, t.title, t.total_sales
from titleauthor ta, titles t
where ta.title_id = t.title_id
and ta.au_id = @author_id
open author_sales
fetch author_sales
into @title_id, @title, @ytd_sales
if (@@sqlstatus = 2)
begin
我是SQL的新手。任何人都可以帮助我吗?