Hello,
i just have a simple select statement, and i get the max value from one table that i use to at it to the where clause from another table, example:
select Max(Order_ID)
from dbo.orders
then get that max id manully and copy it to the below select statement
select *
from customer_orders
where orderID = 50
however... when i create a store procedure and use a variable, like below:
declare @MaxOrderID bigint
select @MaxOrderID = Max(Order_ID)
from dbo.orders
select *
from customer_orders
where orderID = @MaxOrderID
for some reason, the results come up blank, the orderID is also bigint... so i am not sure what i am missing... has that happen to anyone before?
Can you use Set instead of select
Or rewrite your query
Select * from customer_orders where order_id = (select max(order_id) from dbo.orders)
September 29, 2020 at 3:08 pm
good call, let me see about setting it and re-write, will let you know.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply