SQL Server object creation -
update table_ta set abm=a.abm (select id,abm final_data )a inner join table_ta tb on a.id=tb.id
someone wrote query in procedure has left company. query confusing me bit table table_ta can tell me if table's object created 2 times or one? concern in query in inner join used alias [tb] updating table.
ps: query may not written logically correct no need join point creation of object of now.
the query posted uses "derived table" named "a". derived tables resultsets can use table. have @ article find out how work: http://www.programmerinterview.com/index.php/database-sql/derived-table-vs-subquery/
i think better written version of statement have this:
update tb set tb.abm = a.abm final_data inner join table_ta tb on a.id = tb.id
to explain: query uses 2 tables (a derived table "a" , table_ta "tb")..so first line should update tb
instead of update table_ta
. what's more it's not necessary @ use derived table here. simple join enough.
Comments
Post a Comment