Skip to Content
0
Former Member
Nov 21, 2011 at 11:08 PM

Variables at Query Manager

145 Views

Hello Experts,

I have this problem I need to store some variables in order to execute a query,

but an error shows when I add the last part of the variable let me explain better.

This works Fine:

--1

Declare @VendedorName varchar(150),

@Fecha_ini datetime,

@Fecha_fin datetime,

@Fecha_finfin datetime,

@VendedorCode int

/SELECT DocDate FROM [dbo].[OINV] T0/

/* WHERE */

set @Fecha_ini = /* T0.DocDate*/ '[%0]'

/SELECT DocDate FROM [dbo].[OINV] T0/

/* WHERE */

set @Fecha_fin = /* T0.DocDate*/ '[%1]'

This Works Fine:

--2

Declare @VendedorName varchar(150),

@Fecha_ini datetime,

@Fecha_fin datetime,

@Fecha_finfin datetime,

@VendedorCode int

SELECT @VendedorCode=T0.SlpCode FROM OSLP T0

WHERE SlpName = '[%2]'

but this do not work... I cant Figure it out why, maybe you can help me ...

--3

Declare @VendedorName varchar(150),

@Fecha_ini datetime,

@Fecha_fin datetime,

@Fecha_finfin datetime,

@VendedorCode int

/SELECT DocDate FROM [dbo].[OINV] T0/

/* WHERE */

set @Fecha_ini = /* T0.DocDate*/ '[%0]'

/SELECT DocDate FROM [dbo].[OINV] T0/

/* WHERE */

set @Fecha_fin = /* T0.DocDate*/ '[%1]'

SELECT @VendedorCode=T0.SlpCode FROM OSLP T0

WHERE SlpName = '[%2]'

Any Help Will Be Apreciated