Friday, January 20, 2017

T-SQL update table from join table value

If you want to update your table from join table value you can try with this:

  SET r.l_auto_refill = 1  
    ,r.d_start_date = p.dDispDate  
       ,r.n_frequency = p.nDispDaysSupply  
       ,r.d_next_fill  = DATEADD(DAY, p.ndispdayssupply, p.ddispdate)  
 FROM rx r  
 INNER join   
  profile AS p ON r.[rxno_PK] = p.rxno_FK  
 where r.rxno_PK = '000010578126'  

SQL Get all Index create script from Database

To get all script from database as a create new index into another database you can use the following --Get all Index Script SELECT...