问题详情

存储过程1)请创建一存储过程 getDetailByName,通过输入参数学生姓名(如“章山"),在“学生”表中查询该学生的基本信息。若“姓名”列不存在此姓名,用SELECT输出信息“不存在此学生”。2)写出调用此存储过程的语句,查询“李四”的基本信息。


时间:2021-07-17 23:12 关键词:

答案解析

<p class="MsoNormal" style="text-indent:15.0pt;mso-char-indent-count:1.5"><span style="font-size:10.0pt;font-family:宋体;mso-ascii-font-family:&quot;Courier New&quot;; mso-hansi-font-family:&quot;Courier New&quot;;mso-bidi-font-family:&quot;Courier New&quot;; mso-font-kerning:0pt;mso-no-proof:yes">1)(10分)参考答案不唯一,下面列出两种</span><span lang="EN-US"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left:21.0pt;mso-para-margin-left:2.0gd"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-font-kerning: 0pt;mso-no-proof:yes">Create procedure getDetailByName<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left:21.0pt;mso-para-margin-left:2.0gd"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-font-kerning: 0pt;mso-no-proof:yes">@name nvarchar(10)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left:21.0pt;mso-para-margin-left:2.0gd"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-font-kerning: 0pt;mso-no-proof:yes">AS<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left:21.0pt;mso-para-margin-left:2.0gd; text-indent:25.0pt;mso-char-indent-count:2.5"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-font-kerning:0pt; mso-no-proof:yes">IF exists(SELECT * FROM </span><span style="mso-bidi-font-size: 10.5pt;font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;">学生</span> <span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-font-kerning: 0pt;mso-no-proof:yes">Where</span><span style="mso-bidi-font-size:10.5pt; font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;mso-hansi-font-family: &quot;Times New Roman&quot;">姓名</span><span lang="EN-US" style="font-size:10.0pt; font-family:&quot;Courier New&quot;;mso-font-kerning:0pt;mso-no-proof:yes">= @Name) <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left:21.0pt;mso-para-margin-left:2.0gd; text-indent:50.0pt;mso-char-indent-count:5.0"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-font-kerning:0pt; mso-no-proof:yes">SELECT * FROM </span><span style="mso-bidi-font-size:10.5pt; font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;">学生</span> <span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-font-kerning: 0pt;mso-no-proof:yes">Where</span><span style="mso-bidi-font-size:10.5pt; font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;mso-hansi-font-family: &quot;Times New Roman&quot;">姓名</span><span lang="EN-US" style="font-size:10.0pt; font-family:&quot;Courier New&quot;;mso-font-kerning:0pt;mso-no-proof:yes">= @Name<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left:21.0pt;mso-para-margin-left:2.0gd; text-indent:25.0pt;mso-char-indent-count:2.5"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-font-kerning:0pt; mso-no-proof:yes">ELSE<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left:21.0pt;mso-para-margin-left:2.0gd; text-indent:49.9pt;mso-char-indent-count:4.99"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-font-kerning:0pt; mso-no-proof:yes">SELECT '</span><span style="font-size:10.0pt;font-family: 宋体;mso-ascii-font-family:&quot;Courier New&quot;;mso-hansi-font-family:&quot;Courier New&quot;; mso-bidi-font-family:&quot;Courier New&quot;;mso-font-kerning:0pt;mso-no-proof:yes">不存在此学生</span><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-font-kerning: 0pt;mso-no-proof:yes">'<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left:21.0pt;mso-para-margin-left:2.0gd; text-indent:25.0pt;mso-char-indent-count:2.5"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-font-kerning:0pt; mso-no-proof:yes"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" style="margin-left:21.0pt;mso-para-margin-left:2.0gd; text-indent:.3pt;mso-char-indent-count:.03"><span style="font-size:10.0pt; font-family:宋体;mso-ascii-font-family:&quot;Courier New&quot;;mso-hansi-font-family:&quot;Courier New&quot;; mso-bidi-font-family:&quot;Courier New&quot;;mso-font-kerning:0pt;mso-no-proof:yes">参考答案</span><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-font-kerning: 0pt;mso-no-proof:yes">2</span><span style="font-size:10.0pt;font-family:宋体; mso-ascii-font-family:&quot;Courier New&quot;;mso-hansi-font-family:&quot;Courier New&quot;; mso-bidi-font-family:&quot;Courier New&quot;;mso-font-kerning:0pt;mso-no-proof:yes">:</span><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-font-kerning: 0pt;mso-no-proof:yes"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left:21.0pt;mso-para-margin-left:2.0gd"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-font-kerning: 0pt;mso-no-proof:yes">Create procedure getDetailByName<o:p></o:p><