0
I’m trying to create a design that according to the price range takes a different field from the table.
Create Procedure BuscaPreco
@preco decimal,
@faixa1 int,
@faixa2 int,
@faixa3 int,
@faixa1=100,
@faixa2=200,
@faixa3=300
Select
case when @preco <@faixa1 then p.preco1
when @preco <@faixa2 and @preco >=@faixa1 then p.preco2
when @preco <@faixa3 and @preco >= @faixa2 then p.preco3
else p.preco4
end,
from produtos p
Msg 102, Level 15, State 1, Procedure BuscaPreco, Line 6
Incorrect syntax near '='.
Msg 156, Level 15, State 1, Procedure BuscaPreco, Line 15
Incorrect syntax near the keyword 'from'.
Syntax error must be the comma after the end .... end, without going into greater merits
– Motta
The second error has been corrected.
– Davi Dorna
No sql server work but a quick search says you need DECLARE and SET https://docs.microsoft.com/pt-br/sql/t-sql/language-elements/assignment-operator-transact-sql
– Motta