📄 subject_42973.htm
字号:
<p>
序号:42973 发表者:baggio 发表日期:2003-06-07 10:57:37
<br>主题:问题,求助
<br>内容:我建了一个函数:<BR>create function tongji_3(@sum char(10))<BR>returns int<BR>as<BR>begin<BR>declare @ch as char<BR>set @ch=@sum+'%'<BR>return(select count(*) from aaa where 年龄 like @ch)<BR>end <BR>再调用:<BR>declare @a as char<BR>set @a='1'<BR>while @a>='1' and @a<='5'<BR>begin<BR>update tb_aaa2<BR>set tb_aaa2.shu=dbo.tongji_3(@a)<BR>where tb_aaa2.age=@a<BR>set @a=char(ascii(@a)+1)<BR>end<BR>为什么能执行,不能返回结果
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:kf 回复日期:2003-06-07 14:11:22
<br>内容:我调试出来了:<BR>将保存对应数据的表<BR>create table tb_aaa(shu int)<BR>go<BR>这里一个年龄表<BR>create table tb_age(age int)<BR>go<BR><BR>建一个存储过程<BR>create procedure tj_aaa_1<BR> as<BR> declare @a as int<BR> set @a=1<BR> while @a<'5'<BR> begin<BR> insert tb_aaa(shu)<BR> select administrator.tongji_2(@a)<BR> set @a=@a+1<BR> end<BR> go<BR>创建一个函数<BR>create function tongji_2(@sum int)<BR> returns int<BR> as<BR> begin<BR> return(select count(*) from tb_age where age/10 = @sum)<BR> end<BR> go<BR><BR>运行:<BR>tj_aaa_1<BR>go<BR><BR>需要注意的是我还没有向年龄表中插入数据,<BR>请你先插入数据以后运行就可以返回正确结果了<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -