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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

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

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

tooba
Posting Yak Master

224 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.

sunitabeck
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

tooba
Posting Yak Master

224 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

visakh16
Very Important crosS Applying yaK Herder

India
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
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next 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.04 seconds. Powered By: Snitz Forums 2000