Skip to Content
author's profile photo Former Member
Former Member

Variables at Query Manager

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2011 at 02:38 AM

    Dear

    cristianlf

    You Can this Query

    Declare

    @VendedorName varchar(150),

    @Fecha_ini datetime,

    @Fecha_fin datetime,

    @Fecha_finfin datetime,

    @VendedorCode int

    /SELECT FROM dbo.OINV T0/

    /SELECT FROM dbo.OSLP T1/

    /* WHERE */

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

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

    Set @VendedorCode = /* T1.SlpCode */ '[%2]'

    Hope Can help you

    Regards

    Ang Sukarno

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2011 at 02:56 PM

    Hi,

    Welcome you post on the forum.

    The format of your parameter must the same.

    Try:

    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 SlpCode FROM [dbo].[OSLP] T1*/
    /* WHERE */
    set @VendedorCode= /* T1.SlpCode*/ [%2]

    Thanks,

    Gordon

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.