首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

这一题哪一个正确,该怎么解决

2012-01-05 
这一题哪一个正确创建存储过程如下:CREATEprocedurebookproc@idint,@titlechar(20)OUTPUTasselect@titlet

这一题哪一个正确
创建存储过程如下:
CREATE   procedure   bookproc
  @id   int,   @title   char(20)   OUTPUT    
as
select   @title=title   from   book   where   id=   @id
执行该存储过程的方法正确的是(d)。(选择一项)

a)exec   bookproc   1,@title   output
print   @title
b)exec   bookproc   @id   =1,@title   output
print   @title
c)declare   @title   char(20)
exec   bookproc   1,@title   output
print   @title
d)declare   @title   char(20)
exec   bookproc   @id   =1,@title   output
print   @title


[解决办法]
c
[解决办法]
c
[解决办法]
c是对的

如果D写成这样也是对的
d)declare @title char(20)
exec bookproc @id =1,@title =@title output
print @title
[解决办法]
验证 C
[解决办法]
C
[解决办法]
c d

[解决办法]
更正:

只有c正确

[解决办法]
一旦使用了 '@name = value ' 形式之后,所有后续的参数就必须以 '@name = value ' 的形式传递。
[解决办法]
DECLARE@bookTitle nvarchar(50)

EXECbookproc
@bookID = 1,
@bookTitle = @bookTitle OUTPUT

SELECT@bookTitle as N '@bookTitle '


如果要 '@name = value '这么传递,那么上述可以解决问题。
[解决办法]
当然最后还是 print @bookTitle
[解决办法]
mark
[解决办法]
不试一下还真的不知道,只有C
D不行,报错“并以 '@name = value' 的形式传递后续的参数。一旦使用了 '@name = value' 形式之后,所有后续的参数就必须以 '@name = value' 的形式传递。”
[解决办法]
c
d 错误 @id 都没申明能这样用吗?? 
本人觉得不用讨论的
d) declare @title char(20) 
exec bookproc @id =1,@title output 
print @title

热点排行
Bad Request.