I have a function whose return value I am assigning it to a variable and I am getting an error
Incorrect syntax near the keyword 'TOP'. SQL Server
if @Miracle is null OR @Miracle =''
select @Miracle = TOP(1) M.MiracleName
FROM Miracle M where M.MiracelID = @MiracelID
how can I assign functions like TOP to a variable ??
I think you just need to move TOP 1 before your variable:
select TOP 1 @Miracle = M.MiracleName
...
Your aren't assigning TOP to a variable, but rather using TOP to tell SQL Server to only return a single row.
Good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With