Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 25th, 2008, 10:38 AM
Registered User
 
Join Date: Apr 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Finding an aliased column's original name & table

Hi,

I need to find out where the columns in a number of functions are coming from. My problem is that the functions tend to pull information from more than one table and the columns are aliased within the function. I would like to query this information out of the system tables.

I am trying to write a query that will return the following:
- Column name from a given view/function (based on objectID)
- Table name of the table where the column comes from
- Column name of the column as it appears in the table (for aliased columns)

I want the query to be parameterized by passing it an objectid or objectname.

Is there a way to write this using the system tables or information_schema views? I've been trying to figure out what I could join these tables on to get this information but have so far come up with nothing.

 
Old July 31st, 2008, 06:41 AM
Registered User
 
Join Date: Jul 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think following queries fulfill your requirement

For getting Table Name from database
Select Name From Sysobjects Where Type='U'

For getting column info use following query
Select * From Information_Schema.Columns


Mohd Azharuddin Ansari
Syntel Inc
Pune





Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate a List Box with Table Names & Table date hewstone999 Access VBA 1 February 27th, 2008 10:10 AM
Table rendering with table & comboBox pazzuzu Java GUI 0 May 9th, 2007 09:04 AM
Original form SaveAs new doc w/o original VBA ChuckTremain Word VBA 0 February 8th, 2007 02:58 PM
sql & join tables & find a field in multiple table trangd Beginning PHP 2 January 29th, 2004 07:18 PM
Finding Field Type & string length From dataset? Jackie VB.NET 2002/2003 Basics 4 July 9th, 2003 04:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.