I am using SQL Server 2005 Management Studio Express. Coins and themes are my tables. I created a stored procedures using the above two and got struck with
Error:Msg 102, Level 15, State 1, Procedure themestat, Line 1
Incorrect syntax near ‘id2’.
Here is my whole procedure:
create procedure themestat(id2 In numeric, id1 In numeric)
is
@userid nvarchar(50), @co nvarchar(50), @price nvarchar(50)
begin
update themes set prioirty=1 where themeid=id2;
select credits as co from coins where uid=id1;
select rate as price from themes where priority=1;
if(co>price)
begin
update themes set status=1 where priority=1;
update themes set priority=0 where themeid=id2;
end
else
begin
update themes set priority=0 where theme=id2;
PRINT 'no sufficient coins'
end
end
I am curious to know where I went wrong ??
I’m not sure where you’ve got the syntax from, but datatypes are declared as ‘@param type’, so the first line should read:
Then obviously change all references of id1 and id2 as appropriate. There’s other syntax errors in the script (missing
declare,isinstead ofas, possibly others – I’ve not looked much closer).This makes me wonder whether you’ve come from a different SQL dialect? I suggst reading about
CREATE PROCEDUREon the MSDN (as well as other pages).