Skip to content

Instantly share code, notes, and snippets.

@lanekatris
Created November 12, 2015 13:03
Show Gist options
  • Select an option

  • Save lanekatris/0d61b065f59e10f47a77 to your computer and use it in GitHub Desktop.

Select an option

Save lanekatris/0d61b065f59e10f47a77 to your computer and use it in GitHub Desktop.
declare @schemaName nvarchar(100) = 'item'
declare @tableName nvarchar(100) = 'location'
declare @dataType nvarchar(100) = 'decimal'
select
s.name,
t.name,
c.name,
c.is_nullable,
st.name
from sys.columns c
inner join sys.tables t
on t.object_id = c.object_id
and t.name = @tableName
inner join sys.schemas s
on s.schema_id = t.schema_id
and s.name = @schemaName
inner join sys.types st
on st.system_type_id = c.system_type_id
and st.name = @dataType
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment