Kamil Lach
Kamil Lach

Reputation: 4629

Get XML schema used by sql column

I want to select xml schema assigned to a xml column in my SQL Server database, from a SQL statement.

I am stuck, I've looked in information_schema.columns with no luck, I can just alter it.

In Management Studio, in column properties under Xml Type Specification I can set (scheme collection) I want to simply select this from SQL statement.

Thanks for your help.

Upvotes: 4

Views: 1219

Answers (1)

Mikael Eriksson
Mikael Eriksson

Reputation: 138960

Something like this should do it.

select C2.name
from sys.columns as C1
  inner join sys.xml_schema_collections as C2
    on C1.xml_collection_id = C2.xml_collection_id
where C1.object_id = object_id('TableName') and
      C1.name = 'ColumnName'

Upvotes: 4

Related Questions