Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract Just 1 data element from Every Table 1

Status
Not open for further replies.

MwTV

MIS
Mar 9, 2007
99
Don't know if this is possible.

Used the following sql script previously to obtain a "draft data dictionary" of the sql server database.

There are two separate sql server databases that are on different servers.

Is it possible for the sql script to be altered so that I can pull just one data element from each field within the tables of the sql server databases?

What I intend to accomplish is two lists that I can store in Microsoft Excel and use the data filter to determine fields that I can join in my sql scripts.

Note, a field labeled "product_id" in sql server database 1 might be labeled "item_id" in sql server database 2. Therefore, by determining the contents of the fields, I might be able to readily join the tables in my sql script.

If there is a better way, please let me know.

SELECT sysobjects.name AS
, syscolumns.name AS [Column], sysproperties.[value] AS Description
FROM (sysobjects INNER JOIN syscolumns
ON syscolumns.id = sysobjects.id) LEFT JOIN sysproperties
ON sysproperties.smallid = syscolumns.colid AND
sysproperties.id = syscolumns.id
where sysobjects.name <> 'SAMPLE'

 
Sounds like you might be trying to get the primary key from each table?

Kinda late where I am, but maybe something in this FAQ could help?


< M!ke >
Your right to an opinion does not obligate me to take you seriously.
- Winston Churchill
 
Actually, I was interested in extracting just one value from each field within all of the tables. Then, I can use Excel to assist me in finding appropriate fields to join on within my sql scripts.

This is due to some fields not being stored in a logical field name.

For example, you would think that something like patient_id could be linked to pt_id. In several cases, a join would need to occur on fields appear to be illogical!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top