Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2005
    Posts
    40

    Unanswered: string concatenation variable

    Trying to put a variable in a this statement, need the correct syntax...

    Select @RunningDateST3 = Convert(char(8),DATEADD(m,-@counter3,@EndDate),120+ SELECT @startstring

    For example, @startstring = '05', want to put this in the sql syntax so that the sql can be dynamic. Another words, this is not what is needed:
    Select @RunningDateST3 = Convert(char(8),DATEADD(m,-@counter3,@EndDate),120+ '05'

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    This is a guess, but:
    Code:
    SELECT @RunningDateST3 = Convert(CHAR(8)
    ,  DateAdd(m, -@counter3, @EndDate)
    ,  120 + Cast(@startstring AS INT))
    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Apr 2005
    Posts
    40
    nope, but thanks for trying

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    It appears that I don't understand what you want to do. Please explain it differently using English instead of code to describe what you want.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  5. #5
    Join Date
    Apr 2005
    Posts
    40
    nevermind this is it
    Convert(char(8),DATEADD(m,-@counter3,@EndDate),120)+@startstring

  6. #6
    Join Date
    Sep 2011
    Posts
    75
    Hello,

    Please provide your requirements clearly its confusing right now

  7. #7
    Join Date
    Sep 2011
    Posts
    71

    Thumbs up Cocatinate columns at sql syntex

    Please try as below code

    SELECT CategoryId,

    "1" + ', ' + "2" + ', ' + "3" + ', ' + "4" AS Product_List

    FROM ( SELECT CategoryId, ProductName,

    ROW_NUMBER() OVER (PARTITION BY CategoryId
    ORDER BY ProductName)

    FROM Northwind.dbo.Products ) P ( CategoryId, ProductName, seq )

    PIVOT ( MAX( ProductName ) FOR seq IN ( "1", "2", "3", "4" ) ) AS P_ ;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •