is it possible to save data in excel by user id

  • is it possible to save data in excel by userID and also need to email the file too

    Here is the sample data

    User ID | Email | Product Info | Price

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

    23456 | a@hotmail.com | ABC | 23.00

    23456 | a@hotmail.com | ABC | 23.00

    23456 | a@hotmail.com | ABC | 23.00

    12345 | d@hotmail.com | ABC | 23.00

    12345 | d@hotmail.com | ABC | 23.00

    ....

  • This is more than a vague question...

    What do you mean "save by userId"? Just the sort order within a Excel worksheet? An additional line between each userId to separate it visually?

    Separate Worksheets? Separate Excel files?

    What do you mean by "email the file too"? Do you want to mail the final Excel file just created or the output of the query as csv or xls file?

    In all cases the short answer is "Yes, it can be done". But the effort may vary...

    If you need a moer detailed answer, please provide a more detailed question together with ready to use sample data and expected result(s). See the first link in my signatur on how to do that to make it easy for us to help you.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • "save by userId" mean file name for excel and email the file to same userid email in the file.

    Thanks for your response.

  • Do you need to physically save the file or just to mail it?

    If the latter, have a look at sp_send_dbmail.

    You'll need to loop through the userID's and send the mail based on filtered data.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Do you need to physically save the file or just to mail it? >>>>>>>>>> Yes I need both physically save the file and also send mail

  • See Phil Factor's article[/url] for detailed examples of different ways to export to Excel.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Yes using SSIS you can do this.

    Good Luck 🙂 .. Visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.

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

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