I was trying to create a sqlfiddle
DECLARE @binsize INT = 5;
select 5;
select @binsize; <-- this fail.
select 6;
And got this error.
Must declare the scalar variable "@binsize".
I have found sample like this and works ok in sql server.
USE AdventureWorks2012;
GO
DECLARE @find varchar(30);
/* Also allowed:
DECLARE @find varchar(30) = 'Man%';
*/
SET @find = 'Man%';
SELECT p.LastName, p.FirstName, ph.PhoneNumber
FROM Person.Person AS p
JOIN Person.PersonPhone AS ph ON p.BusinessEntityID = ph.BusinessEntityID
WHERE LastName LIKE @find;
SOLVE
Going with the GO change solve the issue. but still open other issues.
DECLARE @binsize INT = 5;
select @binsize + 2 ;
select @binsize + 5 ;
GO
Only return 7