Variable in query
I want to create a complex query with the Query generator and in a Note I found that is is recommended to declare variables.
I tried to use this example for a query but this doesn't work. What's wrong? Does anyone have a working example?
/SELECT FROM [dbo].[OITM] T0/
declare @art as string
/* WHERE */
set @art = /* T0.Itemcode */ '[%0]'
SELECT T1.Itemcode FROM OITM T1 where T1.Itemcode = @art
You should use varchar instead of string:
declare @art as varchar(20)
Then it works!