Link to home
Start Free TrialLog in
Avatar of ljhodgett
ljhodgett

asked on

show what sql parameter is returning from sql syntax in sql server 2005

Hi,

I have the following snapshot sql syntax: -

SELECT TOP 1 @LatestRoutingOption=UnitTestRoutingOption FROM @UnitTestStatus;

I am trying to show what @LatestRoutingOtion has in it and display it on the messages. How do I do this please in sql manager 2005.

Best Regards
Lee
Avatar of chapmandew
chapmandew
Flag of United States of America image

PRINT CAST(@LatestRoutingOption as varchar(200))


SELECT TOP 1 @LatestRoutingOption=UnitTestRoutingOption FROM @UnitTestStatus;
Avatar of ljhodgett
ljhodgett

ASKER

Hi,

I've had to change it a bit to show the returned value from a sql table: -

select dbo.Test_UnitRegister.RoutingOption from dbo.Test_UnitRegister where SerialNumber = @SerialNumber
PRINT CAST( dbo.Test_UnitRegister.RoutingOption as varchar(max))

but it comes up: -

The name "dbo.Test_UnitRegister.RoutingOption" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.

Best Regards
Lee
does it return move than one record?  If so, it is going to be hard to print it out to the messages window.

your syntax is wrong

select RoutingOption from dbo.Test_UnitRegister where SerialNumber = @SerialNumber
PRINT CAST( dbo.Test_UnitRegister.RoutingOption as varchar(max))
Hi,

Don't worry about the last one I've had to change it to: -

PRINT CAST( @LatestRoutingOption as varchar(max))


IF @LatestRoutingOption IS NULL      
begin
      select RoutingOption from dbo.Routing_MinimumRoutingOption where ProductType = @Assembly
      set @LatestRoutingOption = dbo.Routing_MinimumRoutingOption.RoutingOption
end

but it comes up: -

The multi-part identifier "dbo.Routing_MinimumRoutingOption.RoutingOption" could not be bound.

What am I doing wrong please.

Best Regards
Lee
sorry...should be:

select RoutingOption from dbo.Test_UnitRegister where SerialNumber = @SerialNumber
PRINT CAST( @LatestRoutingOption as varchar(max))


IF @LatestRoutingOption IS NULL      
begin
      select @LatestRoutingOption = RoutingOption from dbo.Routing_MinimumRoutingOption where ProductType = @Assembly
      print cast(@LatestRoutingOption  as varchar(255))
end
Hiya,

Sorry I had to change it to do it a different way. We must have pressed the button at the same time.

PRINT CAST( @LatestRoutingOption as varchar(max))


IF @LatestRoutingOption IS NULL      
begin
      select RoutingOption from dbo.Routing_MinimumRoutingOption where ProductType = @Assembly
      set @LatestRoutingOption = dbo.Routing_MinimumRoutingOption.RoutingOption
end

but it comes up: -

The multi-part identifier "dbo.Routing_MinimumRoutingOption.RoutingOption" could not be bound.

What am I doing wrong please.

Best Regards
Lee
try my last post....
lol,

Sorry it's on line: -

set @LatestRoutingOption = dbo.Routing_MinimumRoutingOption.RoutingOption

which is not in the previous post.

Many Thanks and sorry for the confusion.

Lee
ASKER CERTIFIED SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial