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