SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Finding all data types in user tables

By Gaby Abed, 2008/12/04

Total article views: 797 | Views in the last 30 days: 16

This script queries sys.columns to get the entire list of columns and tables existing in the current database, then maps the columns datatype with a name from sys.systypes. The where clause filters the results for user created databases, less 'sysdiagrams', or you can use the commented out where clause to target a specific table.

This is a great way to hunt down various data types and make sure different development teams are on the same page and don't do silly things like having the data types on their tables not matching other tables and causing frustrations in forgetting to cast the values.

By Gaby Abed, 2008/12/04

Total article views: 797 | Views in the last 30 days: 16
Your response
 
 
Related tags

columns     sys.columns    
Data Types     sys.systypes    
SQL Server 2005     sys.tables    
 
Related content

Upgrading SQL Server 2005

By Site Owners | Category: SQL Server 2005
(not yet rated) | 3,170 reads

Identity Columns

By Site Owners | Category: SQL Server 2005
(not yet rated) | 4,372 reads

SQL Server 2005

By ginni.sinha | Category: SQL Server 2005
(not yet rated) | 3,597 reads
 
Contribute
Like this? Try these...

Free registration required...

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Login (existing users)

Login

Email:   Password:   Remember me: Forgotten your password?

Register (new users)

Register

Email:   Password:
Confirm:

Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

Steve Jones
Editor, SQLServerCentral.com