SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Update query help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

223 Posts

Posted - 10/04/2012 :  19:30:17  Show Profile  Reply with Quote
Hi guys,

Help me out. I have very simple query inside S.P, Here it is

Update Mytable
Set Pay = (select top 1 'Payer'+' '+e.Payerid
from Payer e
where e.id = @id)
where mytable.id = @id

I am getting (Payer) in resule it should be (Payer 12 or Payer so on)

Is any one help me why i am not getting value. Data type of fild is varchar(50).

Thank You.

Flowing Fount of Yak Knowledge

5155 Posts

Posted - 10/05/2012 :  07:09:52  Show Profile  Reply with Quote
What do you get when you run the inner query?
select top 1 'Payer'+' '+e.Payerid
from Payer e
where e.id = @id

Edited by - sunitabeck on 10/05/2012 07:10:04
Go to Top of Page

Posting Yak Master

223 Posts

Posted - 10/06/2012 :  00:19:59  Show Profile  Reply with Quote
When i run inner query i am getting value that it suppose to be, but when i am updating some how its change how/when/why no clue....
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 10/06/2012 :  00:29:24  Show Profile  Reply with Quote
is this any better?

Update m
Set m.Pay = 'Payer'+' '+e.Payerid
from Mytable m
inner join Payer e
on m.id = e.id
where e.id = @id

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000