Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UPDATE tables dinamicaly

Status
Not open for further replies.

victorashi

IS-IT--Management
Jul 22, 2006
32
0
0
RO
Can someone help me with an algoritm for updating a table imputed dinamicaly .
what steps do i have to take to find out the the tables columns , and update .
 
More info is needed on what you want to do. If you want to have a stored procedure that accepts a table name and/or columns as parameters, then you will have to write dyncamic SQL to do this.

Jim
 
yes, i want to make a procedure that accepts a table_name and table_name.id as argument and updates the other columns.
what i don't fully understand is what means dinamic sql, how does it works...
 
Go back to your original post, Borislav Borissov has already answered your question and give you a good example.

Jim
 
i know, that was very usefull with select statement, but at update i need to acces the table's columns dinamicaly.
that's what i was trying to find out

-- if @a is the table
exec ('update '+@a' set --in this set i must acces the table's columns and asign each a variable
 
i can make a query to give me the table's columns, like this:

select * from information_schema.columns where table_name =@a

but i still neet to put variables in the columns
 
i misspelled the last command, the query for retuning the table's columns was:

select column_name from information_schema.columns where table_name =@a
 
can u help me pls with the dinamic insertion of data into columns?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top