出错了。!!!!!!!!!

立志做一个佳娃~ 2005-06-22 09:53:14
declare @ghy_table table
@ghy_table=select maxvalue=(case when ghy1>ghy4 then a end) from a as most

select * from @ghy_table
where @ghy_table.maxvalue is not null


服务器: 消息 170,级别 15,状态 1,行 2
第 2 行: '@ghy_table' 附近有语法错误。
服务器: 消息 137,级别 15,状态 1,行 2
必须声明变量 '@ghy_table'。

怎么改??帮忙
...全文
60 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
已经解决。。。
--------------------------------------------------------------------
declare @ghy_table table(maxvalue int)
insert @ghy_table
select maxvalue=(case when ghy1>ghy4 then a end) from a as most

select * from @ghy_table
where @ghy_table.maxvalue is not null
-----------------------------------------------------------------

改成:
select maxvalue=(case when ghy1>ghy4 then ghy1 end) from a as most

OK..
  • 打赏
  • 举报
回复
declare @ghy_table table(maxvalue int)
insert @ghy_table
select maxvalue=(case when ghy1>ghy4 then a end) from a as most

select * from @ghy_table
where @ghy_table.maxvalue is not null


是这条语句出错的,怎么办,
  • 打赏
  • 举报
回复
服务器: 消息 137,级别 15,状态 2,行 6
必须声明变量 '@ghy_table'。


出错啊,,

where A.maxvalue is not null在最后一条中出错的,怎么办啊??
hsj20041004 2005-06-22
  • 打赏
  • 举报
回复
declare @ghy_table varchar(1000)
declare @sql varchar(1000)
set @ghy_table='(select maxvalue=(case when ghy1>ghy4 then a end) from a ) AA'
set @sql='select * from '+ @ghy_table+' where AA.maxvalue is not null'

exec (@sql)
vivianfdlpw 2005-06-22
  • 打赏
  • 举报
回复
declare @ghy_table table(maxvalue int)
insert @ghy_table
select maxvalue=(case when ghy1>ghy4 then a end) from a as most

select * from @ghy_table A
where A.maxvalue is not null
vivianfdlpw 2005-06-22
  • 打赏
  • 举报
回复
declare @ghy_table table(maxvalue int)
insert @ghy_table
select maxvalue=(case when ghy1>ghy4 then a end) from a as most

select * from @ghy_table
where @ghy_table.maxvalue is not null


34,575

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧