문제

As a first step to adding our SQL objects to version control I've written a script that will query sys.objects, sys.modules to script out all objects as CREATEs. I used an example from here to script out my tables. The goal is to preserve the change history of our SQL objects and eventually automate SQL steps we currently achieve manually. Now I need to script out XMLSchemaCollections as a CREATE but I haven't had luck finding an example of how. I imagine it would include querying the several sys.xml_schema_* tables and piecing the XML together element by agonizing element. Does anyone have a working example of how to achieve this?

NOTE: The requirement is to achieve this through a SQL script, not a 3rd party component (i.e. RedGate) nor a Visual Studio Database Project.

도움이 되었습니까?

해결책

You can use the function xml_schema_namespace (Transact-SQL)

Reconstructs all the schemas or a specific schema in the specified XML schema collection.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top