Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: SQL
Expertise: Intermediate
Mar 22, 2018



Application Security Testing: An Integral Part of DevOps

Print All Table Column Definitions in an Entire Database

The following script can be used to print all column definitions for all the tables in your database.


sys.schemas.name + '.' + sys.objects.name AS TableName,

sys.columns.name as ColumnName
WHEN sys.types.name IN ('char','varchar') THEN sys.types.name+'('+CASE WHEN sys.columns.max_length<0 then="" max="" else="" convert="" varchar="" 10="" sys="" columns="" max_length="" end="" when="" types="" name="" in="" nvarchar="" nchar="" case="" 0="" 2="" numeric="" precision="" scale="" as="" datatype="" is_nullable="1" null="" not="" nullable="" from="" inner="" join="" t="" on="" system_type_id="sys.types.user_type_id" and="" is_user_defined="0" objects="" o="" object_id="sys.objects.object_id" schemas="" schema_id="sys.schemas.schema_id" where="" select="" table_name="" information_schema="" tables="" order="" by="" column_id="" code="">
Hannes du Preez
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date