fdgfdgs dfg
fdgfdgs dfg

Reputation: 689

Script for changing DB values of columns with different names from several different tables

Kinda new to Database scripting,

  1. I want a script that will show me 10's of columns from 10's of columns.
  2. Script for changing values of 10's columns from 10's of columns.

I know I can use Select statement but is that best practice ?

Edit

I tired

Select

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

but getting this error

Msg 208, Level 16, State 1, Line 1 Invalid object name 'table1'.

Answer

Few table were deleted by mistake

Upvotes: 0

Views: 64

Answers (1)

AnandPhadke
AnandPhadke

Reputation: 13496

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,
       .....

Upvotes: 1

Related Questions