Why won't my SQL Server database show any results while running stored procedure?
Please look at the code I created. The first block is my stored procedure that I created.
The second block is me running the code manually, bypassing the stored procedure.
The 3rd block is me running the code using the stored procedure.
When I run the code without the stored procedure, I get results. When I run the code via the stored procedure, I don’t get anything, even though it’s presumably the same code.
ALTER PROCEDURE [dbo].[uspCheckSaleVIN] @VIN nvarchar(17) AS SELECT * FROM Sales WHERE VIN = @VIN SELECT * FROM Sales WHERE (VIN = 09872345098723457) GO uspCheckSaleVIN 09872345098723457
One Solution collect form web for “Why won't my SQL Server database show any results while running stored procedure?”
Do it like:
This is because 09872345098723457 is numeric and leading zero is just truncated from literal. Of course it would work only if you have non zero leading digit.
CREATE PROCEDURE test @p VARCHAR(5) AS SELECT @p GO EXEC test 01234 EXEC test '01234'