Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. declare @squery varchar(max)
  2. set @squery = 'if('+CHAR(39)+@AppendType+CHAR(39)+' = ''Address'')
  3. begin
  4. update tblchild set name=(REPLACE(LEFT(phone,2)+LEFT(a,1),' ',''))
  5. update a set a.a=a.name,a.name = b.name,a.email= b.email,a.b = '1' from tblchild as a , tblmaster as b where a.phone = b.phone
  6. update a set a.name = b.name,a.phone = b.phone,a.a=b.a,a.b = '1' from tblchild as a , tblmaster as b where a.email = b.email and (a.b IS NULL or a.b = '')
  7. end'
  8.  
  9. print(@squery)
  10. exec (@squery)
  11. select * from tblchild
  12.  
  13. name email phone a b
  14. s z@a.in 111 NULL 1
  15. u a@ghf.ij 222 NULL 1
  16. x qww 333 NULL 1
  17. ik k@gmail.com 1234567890 NULL 1
  18. kinjal kin@abc.com 7894561230 NULL 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement