exporting sql query to xls file

  • Hi

    Explaining the situation with the master database sysobjects.

    select id,name from master..sysobjects where uid = 1

    The output of the query will be

    id name

    ------------------------------------------

    117575457spt_test1

    133575514spt_test2

    149575571spt_test3

    in query analyser.

    My requirement is

    I need to export this result to excel sheet (.xls) not as csv along with column header.

    Pls help.

  • SSIS can do that.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Hi

    Can you tell me in more detail, how to do that.

    thanks

  • SSMS can do this as well. Just run the query in a new query window, select all the data in the results panel and copy/paste it into a new excel workbook.

  • I cant do this manually. Please

  • In SSIS, you would create a Data Flow Object, create a connection to the database and define its source as the proc, then a destination, which would be the spreadsheet. You can use variables to assign values to any input parameters for the proc, and you can also use variables to create Excel files to output to (and name them).

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Hi Thanks for the information.

    I have created the dtsx. package and trying to start the job using sql server agents / jobs.

    created a new job, by choosing this package to run,

    while executing the job, getting the following error, Please help.

    In my excel sheet, only the column header is generated not the rows.

    Started: 10:37:56 Error: 2008-06-18 10:38:20.83 Code: 0xC0016016 Source:

    Description: Failed to decrypt protected XML node "DTS:Password" with error 0x8009000B "Key not valid for use in specified state.". You may not be authorized to access this information. This error occurs when there is a cryptographic error. Verify that the correct key is available. End Error Progress: 2008-06-18 10:38:27.62 Source: Preparation SQL Task Executing query "CREATE TABLE `Query` ( `gender_cat` LongText, `des".: 100% complete End Progress Progress: 2008-06-18 10:38:28.25 Source: Data Flow Task Validating: 0% complete End Progress Progress: 2008-06-18 10:38:28.58 Source: Data Flow Task Validating: 33% complete End Progress Progress: 2008-06-18 10:38:28.64 Source: Data Flow Task Validating:... The package execution fa... The step failed.

  • That's probably a permissions issue. Make sure the job is running under an account that has the necessary rights. Often, you have to set up a proxy account for it to run under.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply