Created
December 5, 2016 15:15
-
-
Save matt40k/a49991e64b106a23889c4c6647eb0738 to your computer and use it in GitHub Desktop.
Oh, change the old source format will you. Well fine, I'll throw a view over the top with some basic casting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
'[' + c.name + '] = cast('+c.name+' as ' + ty.name + case when ty.name = 'varchar' then '(' + cast(c.[max_length] as varchar(4)) + '))' else ')' end | |
from | |
sys.[all_columns] c inner join sys.tables t on c.[object_id] = t.[object_id] inner join sys.types ty on c.[system_type_id] = ty.[system_type_id] where t.name = 'TABLE' and schema_name(t.schema_id) = 'SCHEMA' | |
order by | |
c.[column_id] asc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment