Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
exec master.sys.sp_MSforeachdb
'
use [?];
if exists
begin
create proc toupdateuserlimit
@totaluser int,
@msgcode varchar(10)

as
begin

update tbl_controlpanel_mst set n_webuserLimit=@totaluser+(select max(n_webuserLimit) from tbl_controlpanel_mst)

if @@ERROR<>0
begin
set @msgcode=''9012''
end
else
begin
set @msgcode=''90012''
end
end
end';


when executing this query ian getting error like in below..
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'begin'.
Msg 137, Level 15, State 2, Line 12
Must declare the scalar variable "@totaluser".
Msg 137, Level 15, State 1, Line 15
Must declare the scalar variable "@msgcode".
Msg 137, Level 15, State 1, Line 19
Must declare the scalar variable "@msgcode".
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'begin'.
Msg 137, Level 15, State 2, Line 12
Must declare the scalar variable "@totaluser".
Msg 137, Level 15, State 1, Line 15
Must declare the scalar variable "@msgcode".
Msg 137, Level 15, State 1, Line 19
Must declare the scalar variable "@msgcode".
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'begin'.
Msg 137, Level 15, State 2, Line 12
Posted
Comments
ZurdoDev 5-Jun-15 7:49am    
You have if exists and then nothing.
Member 11337367 5-Jun-15 7:52am    
This query for execute one procedure in all databases.So what i can do for corect the query..?
ZurdoDev 5-Jun-15 7:55am    
Fix it. Why do you have if exists? What are you trying to see if exists?
Member 11337367 5-Jun-15 8:00am    
I removed that.still same error is existing.
ZurdoDev 5-Jun-15 8:02am    
You have syntax errors. You just need to fix them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900