Results 1 to 3 of 3

Thread: Problems extracting data from tables with osql.

  1. #1
    Join Date
    May 2007
    Posts
    2

    Problems extracting data from tables with osql.

    Hi @ll, I'm trying to extract data from a database where columns have names with spaces inside, I show an example:

    select "total amount"
    from sales;

    This query shows me all data stored in the "total amount" column in table sales, ok no problem.

    Well, the problem comes when I try to execute this query with osql because the output text file where I put the data only have the text "total amount".

    I use the query as I wrote before stored in a text file.

    I'm doing something like this:

    osql -U user -P passwd -i query.sql -o textfile.txt

    Can anybody give a hand? What I'm doing wrong?

    Thank you in advance.

    Bye.

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,922
    To use "" for column names you have to turn SET QUOTED_IDENTIFIER ON, instead of "" you can use [] as

    select [total amount]
    from sales;

  3. #3
    Join Date
    May 2007
    Posts
    2
    Thanks a lot skhanal, I'm newbie in Sql Server and I didn't know this detail.

    I have tested it and works perfefctly.

    Bye.

Posting Permissions

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