视图中的类型转换问题

jacbey 2005-10-09 12:13:43
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

















ALTER view v_Mmtying as
SELECT
Ming.*,
[suc] = (
SELECT count(*) FROM [Mmtyed] Med
where Med.[mmtying_id] = Ming.[ID_Mmtying]
and sent = 1 and time_go is not null),
[fmty] = (
SELECT count(*) FROM [Mmtyed] Med
where Med.[mmtying_id] = Ming.[ID_Mmtying]
and sent = 0 and time_go is not null),
[total] = (
SELECT count(*) FROM [users] U
where U.[state] in (Ming.[mSQL])
) --其中(Ming.[mSQL])为VARCHAR,值类似'2,3,4',但是执行说转换为int出错,怎么解决?
FROM [Mmtying] Ming

...全文
119 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zlp321002 2005-10-09
  • 打赏
  • 举报
回复
--try

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

ALTER view v_Mmtying as
SELECT
Ming.*,
[suc] = (
SELECT count(*) FROM [Mmtyed] Med
where Med.[mmtying_id] = Ming.[ID_Mmtying]
and sent = 1 and time_go is not null),
[fmty] = (
SELECT count(*) FROM [Mmtyed] Med
where Med.[mmtying_id] = Ming.[ID_Mmtying]
and sent = 0 and time_go is not null),
[total] = (
SELECT count(*) FROM [users] U
where charindex(','+convert(varchar(10),U.[state])+',',','+Ming.[mSQL]+',')>0
) --其中(Ming.[mSQL])为VARCHAR,值类似'2,3,4',但是执行说转换为int出错,怎么解决?
FROM [Mmtying] Ming

34,587

社区成员

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

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