8
爲什麼這個工作...的Varchar變量沒有在WHERE子句工作
DECLARE @MyInt int = 12345;
SELECT * FROM MyTable WHERE MyId = @MyInt; --Returns 1 row
SELECT * FROM MyTable WHERE MyId = 12345; --Returns 1 row
但是這不?
DECLARE @MyVarchar varchar = 'ABCDEF';
SELECT * FROM MyTable WHERE MyId = @MyVarchar; --Returns 0 rows
SELECT * FROM MyTable WHERE MyId = 'ABCDEF'; --Returns 1 row
的SQL Server版本是10.50.1746
哦,我多麼傻。或者,也許這是微軟的愚蠢 – 2011-12-20 18:24:38