I have two block of SQL statements (I am using sql server 2005):
-- 1
SELECT *
FROM Invoice
WHERE CustomerId = 'ITTEST01' AND StoreId = '01'
-- CustomerId and StoreId have VARCHAR(16) data type.
--2
BEGIN
DECLARE @pCustomerId AS VARCHAR(16)
DECLARE @pStoreId AS VARCHAR(16)
SET @pCustomerId = 'ITTEST01'
SET @pStoreId = '01'
SELECT *
FROM Invoice
WHERE CustomerId = @pCustomerId AND StoreId = @pStoreId
END
The 1st statement returns what I expect, but the 2nd block returns nothing. I am not sure why this happens as the two SQL blocks should return the same result to me? Could someone give me a hint?
Thank you.
Aucun commentaire:
Enregistrer un commentaire