Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions Links


SQL Server DBA Jobs

How to get the SQL View definition

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?



select schema_name(v.schema_id) as schemaName,
       object_name(c.object_id) as viewName,
       c.column_id as columnID, as columnName,
       type_name(user_type_id) as dataType,
       c.max_length as maxLength,
	   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,

Read more on SQL Views

GRANT VIEW DEFINITION to script out tables

Author: Tom Collins (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

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.


Post a comment on How to get the SQL View definition | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer