sql2000使用变量做表名的查询

德隆 德隆 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
declare @dianxin decimal(7,2),
@hipath decimal(7,2),
@xishu decimal(7,3)
declare @biao char(10)

set @biao='bill200903'

select @dianxin=je
from huizhong
where yf='2009-03'
and phone='86224888'

select @hipath=sum(charge)
from @biao

set @xishu=@dianxin/@hipath
print @xishu

if object_id('temp_1') is not null drop table temp_1

select phone,@xishu*sum(case when price=0.3 then charge else 0 end) changtu,@xishu*sum(case when price<>0.3 then charge else 0 end) shihua
from @biao



出错提示:

服务器: 消息 137,级别 15,状态 2,行 16
必须声明变量 '@biao'。
服务器: 消息 137,级别 15,状态 1,行 22
必须声明变量 '@biao'。
...全文
评论 11
收藏 已收藏
分享
返回顶部
德隆
MS-SQL Server 34,876 成员 254,635 内容