09 November,2021 by Tom Collins
Question: I'm getting some errors in a BULK INSERT step - and I need to get the SQL View definition : including the schema name , column_id , column name , data type , max length ,precision and collation name
Do you have a query where I can return the View column details?
Answer:
select schema_name(v.schema_id) as schemaName, object_name(c.object_id) as viewName, c.column_id as columnID, c.name as columnName, type_name(user_type_id) as dataType, c.max_length as maxLength, c.precision, c.collation_name as collationName from sys.columns c join sys.views v on v.object_id = c.object_id where object_name(c.object_id) = 'my_view_name' order by viewName, column_id;
Read more on SQL Views
GRANT VIEW DEFINITION to script out tables
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |