Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 19th, 2003, 10:26 PM
umeshs79 umeshs79 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 2 umeshs79 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 16 sec
Reputation Power: 0
How to check whether column exist or not in a table?

Hi,
I want to check whether a particular column exist or not in a given table. This i want to check before dropping the column so no error comes if column is not present.

So please can anybody tell me how i do this?
Exmple:
--How to do: check if column exist
-- if exist
ALTER table table_name DROP COLUMN column_name

Thanks
Umesh Sharma

Reply With Quote
  #2  
Old February 20th, 2003, 03:09 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,775 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 16 h 2 m 7 sec
Reputation Power: 37
Depends on which DBMS you are using but I question the rationale for having this type of functionality. Changing the data model should not be done in run time.

Reply With Quote
  #3  
Old October 21st, 2007, 08:01 PM
sriramvellanki sriramvellanki is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 1 sriramvellanki User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 33 sec
Reputation Power: 0
I want it for MS-Access Database

Hi:

I need an sql query/statement to check whether a specific column exists or not in MS-Access Database's Table.

Thanks,
Sriram.

Reply With Quote
  #4  
Old April 15th, 2008, 01:02 AM
dishadevassy dishadevassy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 1 dishadevassy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 45 sec
Reputation Power: 0
Query to check whether column exists in a table

Hi,
I think, this is the query which you are searching

SELECT c.name FROM syscolumns c, sysobjects t
WHERE c.id = t.id AND t.name = 'table_name' AND c.name = 'column_name'

Cheers
Disha


Quote:
Originally Posted by umeshs79
Hi,
I want to check whether a particular column exist or not in a given table. This i want to check before dropping the column so no error comes if column is not present.

So please can anybody tell me how i do this?
Exmple:
--How to do: check if column exist
-- if exist
ALTER table table_name DROP COLUMN column_name

Thanks
Umesh Sharma

Reply With Quote
  #5  
Old April 15th, 2008, 04:44 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,690 r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 6 Days 16 h 20 m
Reputation Power: 985
disha, that's sql server, yes? sriram is using microsoft access

however, sriram may not need it any more, since the question is 6 months old

by the way, you quoted umesh, but umesh asked the original question over 5 years ago

nice try anyway, though

__________________
r937.com | rudy.ca

Reply With Quote
  #6  
Old June 8th, 2008, 10:46 PM
umeshs79 umeshs79 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 2 umeshs79 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 16 sec
Reputation Power: 0
This is nice to this thread active for so long

Quote:
Originally Posted by r937
disha, that's sql server, yes? sriram is using microsoft access

however, sriram may not need it any more, since the question is 6 months old

by the way, you quoted umesh, but umesh asked the original question over 5 years ago

nice try anyway, though


Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > How to check whether column exist or not in a table?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway