为什么在SQL中创建视图时使用了TOP后就不能指定CHECK OPTION了?
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
温馨提示:答案为网友推荐,仅供参考
第1个回答 2010-12-10
zixkanxia