为什么在SQL中创建视图时使用了TOP后就不能指定CHECK OPTION了?
2个回答
展开全部
SQL SERVER中可以在存储过程中创建视图,但要用动态SQL来执行。
create view view_name
as
...
不能直接使用, 可以改为exec('create view view_name
as
...').
你的可以改成
create proc ### as
begin
if exists (select * from sysobjects where name='***'and xtyp='v')
drop view ***;
exec('create view *** as
select A.xh,A.xm,sum(case when A.zy =B.value then B.code else 0) code
from A,B group by A.xh,A.xm
')
end
这样改应该也可以
create proc ### as
declare @sqlstr varchar(255)
select @sqlstr='
if exists (select * from sysobjects where name=''***''and xtyp=''v'')
drop view ***;
create view *** as
select A.xh,A.xm,sum(case when A.zy =B.value then B.code else 0) code
from A,B group by A.xh,A.xm
'
exec(@sqlstr)
go
create view view_name
as
...
不能直接使用, 可以改为exec('create view view_name
as
...').
你的可以改成
create proc ### as
begin
if exists (select * from sysobjects where name='***'and xtyp='v')
drop view ***;
exec('create view *** as
select A.xh,A.xm,sum(case when A.zy =B.value then B.code else 0) code
from A,B group by A.xh,A.xm
')
end
这样改应该也可以
create proc ### as
declare @sqlstr varchar(255)
select @sqlstr='
if exists (select * from sysobjects where name=''***''and xtyp=''v'')
drop view ***;
create view *** as
select A.xh,A.xm,sum(case when A.zy =B.value then B.code else 0) code
from A,B group by A.xh,A.xm
'
exec(@sqlstr)
go
网易云信
2023-12-06 广告
2023-12-06 广告
UIkit是一套轻量级、模块化且易于使用的开源UI组件库,由YOOtheme团队开发。它提供了丰富的界面元素,包括按钮、表单、表格、对话框、滑块、下拉菜单、选项卡等等,适用于各种类型的网站和应用程序。UIkit还支持响应式设计,可以根据不同...
点击进入详情页
本回答由网易云信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询