Unix Technical Forum

Stored Proc to assign variable from subquery not working -- ugh

This is a discussion on Stored Proc to assign variable from subquery not working -- ugh within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi, I'm trying to run a stored proc: ALTER PROCEDURE dbo.UpdateXmlWF ( @varWO varchar(50) ) AS DECLARE @varCust VARCHAR(50) ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 07:11 PM
KathyB
 
Posts: n/a
Default Stored Proc to assign variable from subquery not working -- ugh

Hi, I'm trying to run a stored proc:

ALTER PROCEDURE dbo.UpdateXmlWF
(
@varWO varchar(50)
)
AS
DECLARE @varCust VARCHAR(50)

SELECT @varCust=(SELECT Customer FROM tblWorkOrders
WHERE WorkOrder=@varWO)

When I remove the SELECT @varCust= I get the correct return. With it
in, it just appears to run but nothing comes up in the output window.

PLEASE tell me where I'm going wrong. I'm using MSDE, although I don't
think that should matter?

Thanks, Kathy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 07:11 PM
Chuck Urwiler
 
Posts: n/a
Default Re: Stored Proc to assign variable from subquery not working -- ugh

Kathy,

I think you need this instead:

SELECT @varcust = Customer
FROM tblWorkOrders
WHERE WorkOrder = @varWO

--
-Chuck Urwiler, MCSD, MCDBA
http://www.eps-software.com


"KathyB" <KathyBurke40@attbi.com> wrote in message
news:75e8d381.0310030635.753cd52a@posting.google.c om...
> Hi, I'm trying to run a stored proc:
>
> ALTER PROCEDURE dbo.UpdateXmlWF
> (
> @varWO varchar(50)
> )
> AS
> DECLARE @varCust VARCHAR(50)
>
> SELECT @varCust=(SELECT Customer FROM tblWorkOrders
> WHERE WorkOrder=@varWO)
>
> When I remove the SELECT @varCust= I get the correct return. With it
> in, it just appears to run but nothing comes up in the output window.
>
> PLEASE tell me where I'm going wrong. I'm using MSDE, although I don't
> think that should matter?
>
> Thanks, Kathy



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 07:11 PM
DanRB
 
Posts: n/a
Default Re: Stored Proc to assign variable from subquery not working -- ugh

Instead of "SELECT @varCust=" use "SET @varCust= "


KathyBurke40@attbi.com (KathyB) wrote in message news:<75e8d381.0310030635.753cd52a@posting.google. com>...
> Hi, I'm trying to run a stored proc:
>
> ALTER PROCEDURE dbo.UpdateXmlWF
> (
> @varWO varchar(50)
> )
> AS
> DECLARE @varCust VARCHAR(50)
>
> SELECT @varCust=(SELECT Customer FROM tblWorkOrders
> WHERE WorkOrder=@varWO)
>
> When I remove the SELECT @varCust= I get the correct return. With it
> in, it just appears to run but nothing comes up in the output window.
>
> PLEASE tell me where I'm going wrong. I'm using MSDE, although I don't
> think that should matter?
>
> Thanks, Kathy

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:45 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com