开发者

Check for existence of an XML Schema Collection?

开发者 https://www.devze.com 2022-12-11 04:36 出处:网络
writing scripts for Sql Server 2005. I am registering a schema with CREATE XML SCHEMA COLLECTION [dbo].[MySchema] AS N\'<xsd:schema ... >\'

writing scripts for Sql Server 2005. I am registering a schema with

CREATE XML SCHEMA COLLECTION [dbo].[MySchema] AS N'<xsd:schema ... >'

Now, as I make changes, I would like to drop it, say with a call to

DROP XML SCHEMA COLLECTION [dbo].[MySchema]

I run this stuff fairly frequently as I am developing, like

DROP ...
CREATE ... 

but this presents problems on a first-run where the Schema does not exist. I would like to do something similar to

IF OBJECT_ID ('MySchema') IS NOT NULL
    DROP ...
CREATE ...

but OBJECT_ID ('MySchema') just returns NULL. Is there a proper way to test for existence of a registered Xml Schema Colle开发者_如何学Goction in Sql Server 2005?

muchos gracias mis amigos :)


Check sys.xml_schema_collections:

IF EXISTS (SELECT * FROM sys.xml_schema_collections WHERE name = 'MySchema')
0

精彩评论

暂无评论...
验证码 换一张
取 消