快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

和记娱乐缅甸平台_机器人论坛



微软的SQL脚本天生令我伤透了心——我不停以为是我的法度榜样上的问题,或者我操作上的掉误,并且,客服职员屡屡埋怨我的法度榜样bug,多次测试之后,才发明,原本都是微软惹的祸……

Sql Server的脚本天生有不少破绽,常常由_art_center>它天生的脚本运行起来会有差错。下面举例阐明:

1. 并没有根据sysdenpends的依附关系天生SQL代码,而是根据所谓的“优先级”来天生。

比如:他觉得view的优先级就要比function高。

那么,我写了下面的测试法度榜样,形成如下的依附关系:fnT1_CODE>create function fnT1()

returns Integer

as

begin

return 123

end

go

create view vwT1

as

select aa=dbo.fnT1()

go

create function fnT2()

returns table

as

return (select * from vwT1)

go_CODE>

_NOBR>

运行到数据库之后,用Enterprise天生SQL代码。要留意选项不一样,天生的代码会有所不合,在这里我没有选数据库和用户。

_NOBR> _CODE>if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fnT1]') and xtype in (N'FN', N'IF', N'TF'))

drop function [dbo].[fnT1]

GO

if exists (select * from dbo.sysobjects where 和记娱乐缅甸平台id = object_id(N'[dbo].[fnT2]') and和记娱乐缅甸平台 xtype in (N'FN', N'IF', N'TF'))

drop和记娱乐缅甸平台 function [dbo].[fnT2]

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[vwT1]') and OBJECTPROPERTY(id, N'IsView') = 1)

drop view [dbo].[vwT1]

GO

SET QUOTED_IDENTIFIER ON

GO

SET ANSI_NULLS ON

GO

Create view vwT1

As

Select aa=dbo.fnT1()

GO

SET QUOTED_IDENTIFIER OFF

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDE和记娱乐缅甸平台NTIFIER ON

GO

SET ANSI_NULLS ON

GO

Create function fnT1()

R和记娱乐缅甸平台eturns Integer

As

begin

Return 123

end

GO

SET QUOTED_IDENTIFIER OFF

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

SET ANSI_NULLS ON

GO

Create function fnT2()

Returns Table

As

Return (Select * From vwT1)

GO

SET QUOTED_IDENTIFIER OFF

GO

SET ANSI_NULLS ON

GO_CODE>

_NOBR>

您可能还会对下面的文章感兴趣: