GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Database  >  Sybase
Go To First  |  Previous Question  |  Next Question 
 Sybase  |  Question 44 of 64    Print  
A column name is given to you. You have to find out which table has that column. Database has 230 tables.
For example: empid (column name)
For this how do you find out which table has the column (empid) ?

  
Total Answers and Comments: 5 Last Update: October 08, 2009     Asked by: Karthi 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: shamimaziz
 
select name from sysobjects where type = 'U' and id = ( select id from syscolumns where name = 'empid')

Above answer was rated as good by the following members:
dheerukrishnap
July 13, 2007 04:03:02   #1  
SDJ        

RE: A column name is given to you. You have to find ou...
select sysobjects.name from sysobjects syscolumns
where
sysobjects.id syscolumns.id and
syscolumns.name like 'empid'

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
July 21, 2007 02:05:39   #2  
shamimaziz Member Since: July 2007   Contribution: 8    

RE: A column name is given to you. You have to find ou...
select name from sysobjects where type 'U' and id ( select id from syscolumns where name 'empid')
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
August 17, 2007 00:27:32   #3  
Kapil Kumar        

RE: A column name is given to you. You have to find ou...
You can use this query as well

Select Object_name(ID) from Syscolumns where Name 'Coulmn Name'

Regards
Kapil

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
April 15, 2009 21:13:02   #4  
nbeeram Member Since: April 2009   Contribution: 1    

RE: A column name is given to you. You have to find out which table has that column. Database has 230 tables. For example: empid (column name) For this how do you find out which table has the column (empid) ?

By joining the system tables - syscolumns and sysobjects on the id column


 
Is this answer useful? Yes | No
October 08, 2009 04:27:42   #5  
nishusingh84 Member Since: October 2009   Contribution: 1    

RE: A column name is given to you. You have to find out which table has that column. Database has 230 tables. For example: empid (column name) For this how do you find out which table has the column (empid) ?
SELECT DISTINCT o.name FROM sysobjects o syscolumns c
WHERE o.id c.id AND
c.name 'empid' --- or you can go for c.name LIKE " empid "

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape