Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
SELECT CI.ImageId , CI.CombinationId , C.Id 
FROM
Production.Product P
INNER JOIN
Production.Combination C
ON
P.Id = C.Product_Id
AND 
P.Id = 11
INNER JOIN
Production.Combination_Image CI 
ON
C.Id = CI.CombinationId
INNER JOIN
Production.[Image] I
ON 
CI.ImageId = I.Id
AND
I.Id = 18


and here my Result is right

RESULT :
18	12	12


Its fine and that's my real Result BUT !!! :|

NOW I make that query as a stored procedure
like under here

SQL
CREATE PROC GetCombinationAndCombinationImageByProductIdAndImageId
@ProductId INT,
@ImageId INT
AS
BEGIN
SELECT CI.ImageId , CI.CombinationId , C.Id 
FROM
Production.Product P
INNER JOIN
Production.Combination C
ON
P.Id = C.Product_Id
AND 
P.Id = @ProductId
INNER JOIN
Production.Combination_Image CI 
ON
C.Id = CI.CombinationId
INNER JOIN
Production.[Image] I
ON 
CI.ImageId = I.Id
AND
I.Id = @ImageId
END


-- and here EXECUTE my proc
EXEC GetCombinationAndCombinationImageByProductIdAndImageId @ProductId = 11 , @ImageId=18


AND ... RESULT :|

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)
Msg 217, Level 16, State 1, Procedure GetCombinationAndCombinationImageByProductIdAndImageId, Line 55
Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).


Please Help Me :)

Regards
Posted
Updated 9-Dec-15 2:50am
v2
Comments
ZurdoDev 9-Dec-15 8:50am    
You have nesting going on. You'll have to figure out where.
Ali Javani 9-Dec-15 8:54am    
http://www.sql-server-helper.com/error-messages/msg-217.aspx[^]

and i understand recursion in SQL SERVER
i don't know how do i fix this

Regards
PIEBALDconsult 9-Dec-15 8:53am    
Does the procedure include the EXEC command shown at the bottom? If so, remove it.
Ali Javani 9-Dec-15 8:57am    
i wrote EXEC for testing query .
if i remove it, how do i see result of execution ?
PIEBALDconsult 9-Dec-15 8:59am    
You execute it separately; it should not be part of the procedure.

1 solution

DEAR "PIEBALDconsult" said :
i need enclose my execution
and i just observance the encapsulation
with batch
"GO"

Exactly i forgot GO
:)

thanks
"PIEBALDconsult"

SQL
ALTER PROC GetCombinationAndCombinationImageByProductIdAndImageId
@ProductId INT,
@ImageId INT
AS
BEGIN
SELECT CI.ImageId , CI.CombinationId
FROM
Production.Product P
INNER JOIN
Production.Combination C
ON
P.Id = C.Product_Id
AND 
P.Id = @ProductId
INNER JOIN
Production.Combination_Image CI 
ON
C.Id = CI.CombinationId
INNER JOIN
Production.[Image] I
ON 
CI.ImageId = I.Id
AND
I.Id = @ImageId
END
GO
EXEC GetCombinationAndCombinationImageByProductIdAndImageId @ProductId = 11 , @ImageId=17
GO
 
Share this answer
 
v3

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