sql - How to Update last 3 columns of a temp table -
reqid respid name part type base ---------------------------------------------------------------------------- 674508621df6 d5830288f5c2 00000233a null null null c356c1e03784 d5830288f5c2 00000233a null null null
when running following query out stored procedure part getting above result. want update sp using return values sp.
declare @temptable table( reqid varchar(255), respid varchar(255), name varchar(255), part bit, type bit, base bit) insert @temptable (reqid ,respid ,name) select * distributessystemsview dsv join mydomain md with(nolock) on md.mydomainid = dsv.mydomainid dsv.lotoperationsegmentresponseid=@lotopsegrespid
stored procedure part
should able update part,type , base
columns using following sp takes md.domainid parameter above join statement
insert @temptable(part,type,base) execute [soadb].[dbo].[splocal_anotherspl] md.mydomainid select * @temptable
if understand problem correctly, can try this.
- add new column
mydomainid
@temptable
- insert data
@temptable
before - have table
@temptable2
stores data procedure specific@mydomainid
- run update of
@temptable
after joining@temptable2
- rinse , repeat steps 3 , 4 if required different values of
@mydomainid
query
declare @temptable table( mydomainid varchar(255), reqid varchar(255), respid varchar(255), name varchar(255), part bit, type bit, base bit); insert @temptable (mydomainid,reqid ,respid ,name) select dsv.mydomainid,reqid ,respid ,name distributessystemsview dsv join mydomain md with(nolock) on md.mydomainid = dsv.mydomainid dsv.lotoperationsegmentresponseid=@lotopsegrespid declare @temptable2 table( part bit, type bit, base bit) insert @temptable(part,type,base) execute [soadb].[dbo].[splocal_anotherspl] @mydomainid update t set part = temp2.part , type = temp2.type, base = temp2.base @temptable t cross join @temptable2 temp2 t.mydomainid = @mydomainid
Comments
Post a Comment