Results 1 to 3 of 3

Thread: SQL 2K5, Results To CSV, NULL Values?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    SQL 2K5, Results To CSV, NULL Values?

    When you try to save results in a grid to a csv file, whenever there are NULLs present, the value actually shows up in text as NULL in the CSV output. What can I do, if anything, to have it save as an empty field with nothing in it?

    If I have data in three columns: 1, (null), 2
    the result in the file is :1,NULL,2
    where I want the output to be : 1,,2

    Would make importing much easier to have nothing there than a NULL in text, especially in a numerical column.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: SQL 2K5, Results To CSV, NULL Values?

    You could try using the IsNull function

    ISNULL ( check_expression , replacement_value )

    Sample usage
    Code:
    SELECT ISNULL(Column2, ''))
    FROM Table1
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    Hyperactive Member
    Join Date
    Jan 2008
    Location
    Merseyside
    Posts
    456

    Re: SQL 2K5, Results To CSV, NULL Values?

    I would suggest using the Export Data function found when you right click on the database. Select Tasks, followed by Export Data.

    In here you will be able to select your source (Database) and destination (Flat File), as well as how you want to extract it. You can also specify if you want a full table copy or use a piece of SQL to transfer the data.

    The finished csv file will have blanks where the NULLS should be.
    Attached Images Attached Images  

Posting Permissions

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



Click Here to Expand Forum to Full Width