Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Update query help

Author  Topic 

tooba
Posting Yak Master

224 Posts

Posted - 2012-10-04 : 19:30:17
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.

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-10-05 : 07:09:52
What do you get when you run the inner query?
select top 1 'Payer'+' '+e.Payerid
from Payer e
where e.id = @id
Go to Top of Page

tooba
Posting Yak Master

224 Posts

Posted - 2012-10-06 : 00:19:59
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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-06 : 00:29:24
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
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -