Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2006
    Posts
    33

    Unanswered: Query output as text rather than a temp table..

    Hi Guys,

    I'm trying to figure out how to output a query as text instead of a tempory table...

    I thought perhaps i could use this:

    SELECT PRINT CustomerID FROM ORDER_TABLE

    But that doesn't work

    PRINT CustomerID FROM ORDER_TABLE

    Doesn't work either...


    I need this so i can print a customised invoice in SQL. That is, unless their is a better way of tackling this problem?

    thx for reading

    --Philkills

  2. #2
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    Where does "SELECT CustomerID FROM ORDER_TABLE" write its output to?
    --_Peter Vanroose,
    __IBM Certified Database Administrator, DB2 9 for z/OS
    __IBM Certified Application Developer
    __ABIS Training and Consulting
    __http://www.abis.be/

  3. #3
    Join Date
    Nov 2006
    Posts
    33
    That generates a tempory table with a heading of 'CustomerID' and row numbers at the left hand side.....

    Im talking about just outputing the data in the customerID column... and nothing else

    The same way you would do:

    PRINT 'BLAH'

    etc...

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by Philkills
    That generates a tempory table with a heading of 'CustomerID' and row numbers at the left hand side.....
    you can be assuered that it isn't a temporary table and it doesn't have line numbers -- your front end app is doing that

    what database is this? (notice you have posted in the standard sql forum)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Nov 2006
    Posts
    33
    Its for MSSQL

    and i found 1 potential way....

    storing the output in a buffer:

    DECLARE @ordNo INT
    DECLARE @outBuff VARCHAR(1000)
    DECLARE @newLine CHAR(1)
    SET @ordNo = 1
    SET @outBuff = ''
    SET @newLine = '
    '

    SELECT @outBuff = @outBuff + 'PRICE: ' + CAST(ItemPrice AS VARCHAR) + @newLine
    FROM ORDER_ITEM, ITEM
    WHERE ORDER_ITEM.ItemID = ITEM.ItemID

    PRINT @outBuff


    But is there a better way?

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    moved to SQL Server forum
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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