Results 1 to 5 of 5

Thread: sql server

  1. #1
    Join Date
    Dec 2011
    Posts
    2

    Unanswered: sql server

    i want to display the following output where integer value is column data.


    {[Advertiser].[AdvertiserKey].&[4000],
    [Advertiser].[AdvertiserKey].&[4001],
    [Advertiser].[AdvertiserKey].&[4002],
    [Advertiser].[AdvertiserKey].&[4003],
    [Advertiser].[AdvertiserKey].&[3661],
    [Advertiser].[AdvertiserKey].&[3662]
    }

  2. #2
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Are you asking for permission?
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  3. #3
    Join Date
    Dec 2011
    Posts
    2
    No I am asking the function or SP to get this output

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by dreamwrox View Post
    No I am asking the function or SP to get this output
    where is the output supposed to come from?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    Is this what you are looking for?
    Code:
    DROP TABLE #DaTable
    CREATE TABLE #DaTable(
    	aNumber	INT	NOT NULL
    )
    
    INSERT INTO #DaTAble(aNumber) VALUES
    (4000),(4001), (4002), (4003), (3661), (3662) 
    
    DECLARE @T VARCHAR(MAX) ;
    SET @T = '' ;
    
    SELECT @T = @T + '[Advertiser].[AdvertiserKey].&[' + CAST(aNumber AS VARCHAR) + '],' + CHAR(09) + CHAR(10)
    FROM #DaTable
    
    -- Remove last comma and CR/LF'
    SET @T = LEFT(@T, len(@T) - 3)
    -- Put the result between '{' and '}'
    SET @T = '{'  + @T + '}'
    
    PRINT @T
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

Posting Permissions

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