| Author |
Topic |
|
qutesanju
Posting Yak Master
193 Posts |
Posted - 2010-06-14 : 02:05:07
|
| below is oracle query ,I need to find it's equivalent in SQL server 2005select * from ALL_TAB_COLUMNS where column_name = 'DEPT'3 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-06-14 : 02:10:18
|
[code]SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'DEPT'[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
qutesanju
Posting Yak Master
193 Posts |
Posted - 2010-06-14 : 02:41:37
|
| ok that's good this statement gave me 50 rows.so what if i have to delete this column related value from all above 50 table's and heir corrpospoding columns?DO I have to create a statement to delete data DELETEFROM [dbo].[PLANT_SECTION]WHERE [PLANT_SECTION_PLAN_CHR] IN (@Plan1,@Plan2) and repeat same for 50 above rows? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-06-14 : 02:49:26
|
you will need to use Dynamic SQL (pls read The Curse and Blessings of Dynamic SQL)or the undocumented sp_MSforeachtable (just google for this) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-14 : 03:59:28
|
quote: Originally posted by qutesanju below is oracle query ,I need to find it's equivalent in SQL server 2005select * from ALL_TAB_COLUMNS where column_name = 'DEPT'3
What does 3 maen at 'DEPT'3?Is it a type error?MadhivananFailing to plan is Planning to fail |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2010-06-14 : 04:20:24
|
If this is a one-time deal you can do like this:SELECT 'ALTER TABLE [' + table_name + '] DROP COLUMN [' + column_name + ']' FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'DEPT' Then just copy/paste the result of the query to a new query window.- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com |
 |
|
|
qutesanju
Posting Yak Master
193 Posts |
Posted - 2010-06-14 : 06:46:22
|
| Actually i m looking data deletion from all above 50 statementslike for first table i can form the statement like DELETEFROM [dbo].[PLANT_SECTION]WHERE [PLANT_SECTION_PLAN_CHR] = @Plan1 |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|