2012-08-06 34 views
0

還挺新的數據庫腳本改變與不同名稱的列的DB值,腳本從幾個不同的表

  1. 我想一個腳本,該腳本會告訴我的列10的從塔10的。
  2. 用於從10列中更改10列的值的腳本。

我知道我可以使用Select語句,但是最佳實踐?

編輯

我累

Select 

table1.column1, 
table1.column2, 
table2.column1 
    ...... 
    table100.column100 FROM table1,table2,.....table100; 

,但得到這個錯誤

消息208,級別16,狀態1,行1無效的對象名稱表1「。

回答

很少有表被錯誤

回答

1
1.Selecting 10's of columns from 10's of columns -- select * from tablename is good way. 
But this is not good when you consider the query for performance point of view.If your reuirement is to get all the columns of a table then you can use select * from tablename. 

2.This is quite obvious that you have to use all 10 columns if u have to change their values. 
UPDATE tablename SETcol1=value1, 
     col1=value1, 
     col1=value1, 
     ..... 
+0

都能跟得上其刪除隨機列,並非所有列:( – 2012-08-06 14:39:44