Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Checking of Data types

Author  Topic 

d3ng
Yak Posting Veteran

83 Posts

Posted - 2007-06-27 : 21:52:14


Hi SQL Experts, I would like to ask for some help. I would like to ask first if it's feasible to create a stored procedure that checks a data type property of a table from a 2 two different DATABASE. For example I would like to check the data types of all the fields of a table 'EXM_APE' from database_a and database_b and to compare the difference, instead of looking on a two opened database.

Darren Bernabe Blanco

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-27 : 22:09:01
yes. check out INFORMATION_SCHEMA.COLUMNS for each of the Db's.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-27 : 22:16:19
[code]SELECT TABLE_NAME = coalesce(a.TABLE_NAME, b.TABLE_NAME),
COLUMN_NAME = coalesce(a.COLUMN_NAME, b.COLUMN_NAME),
DATA_TYPE_A = a.DATA_TYPE,
DATA_TYPE_B = b.DATA_TYPE
FROM database_a.INFORMATION_SCHEMA.COLUMNS a FULL OUTER JOIN database_b.INFORMATION_SCHEMA.COLUMNS b
ON a.TABLE_NAME = b.TABLE_NAME
AND a.COLUMN_NAME = b.COLUMN_NAME
WHERE a.TABLE_NAME = 'EXM_APE'
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-27 : 22:17:58



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

d3ng
Yak Posting Veteran

83 Posts

Posted - 2007-06-27 : 22:28:04
Thanks guys...it works!

Darren Bernabe Blanco
Go to Top of Page
   

- Advertisement -