create function f_getGrop()
returns table
as
begin
declare @re table
set @re=(select * from selfcheck s where not exists(select idxnum from selfcheck where idxnum=(select parentid from indexs where idxnum=s.idxnum)))
return(select pid,sum(selfReal) from @re )
go
错误:服务器: 消息 156,级别 15,状态 1,过程 f_getGrop,行 6
在关键字 'set' 附近有语法错误。
服务器: 消息 137,级别 15,状态 1,过程 f_getGrop,行 7
必须声明变量 '@re'。
服务器: 消息 170,级别 15,状态 1,过程 f_getGrop,行 7
第 7 行: ')' 附近有语法错误。
请高手帮忙看一下
解决方案 »
- 默认值设置问题
- 新手上路,大哥,大姐请多多指教!
- 急求一条SQL语句。。。。。
- 在存储过程中这样的参数该如何处理?
- 简单的问题???
- 如何获取远程服务器上的备份文件名列表??
- 索引列上操作year()或convert()会导致索引不能起到优化作用吗
- INSERT INTO
- 菜鸟认为是超高难问题:请问用ado+sql server 2000做的c/s大程序的高手帮帮忙,我使用ado+sql server 2000做的c/s程序的网络情况比较复杂
- 文档管理
- 大家说说,根据Performance Counter如何来分析sql SERVER的性能?
- 我建立了这样的一个视图,但是打开搜索很慢,总是要超时,是不是我建错了,请指教
returns table
as
return (select pid,sum(selfReal) from selfcheck s where not exists
(select 1 from selfcheck where idxnum=(select parentid from indexs where idxnum=s.idxnum))
group by pid)
GO
------------------------这个地方既然是声明一个表变量,那么后面一点要加上表内定义的字段
returns table
as return
(
select
pid,
sum(selfReal) as selfReal
from (
select *
from selfcheck s
where not exists(select idxnum from selfcheck where idxnum=(select parentid from indexs where idxnum=s.idxnum))
) as T
group by pid)
go
create function f_getGrop()
returns table
as
begin return(select pid,sum(selfReal) from (select * from selfcheck s where not exists(select idxnum from selfcheck where idxnum=(select parentid from indexs where idxnum=s.idxnum))) v )
end