copy the select results into text file

  • ๐Ÿ™‚

  • if you use an enhanced text editor like EditPlus,NotePad++,UltraEdit or one of many others, you can do it in a couple of seconds flat:

    copy and pasting from grid view of SSMS gives you tab delimited results.

    then you can find and replace the regular expression \t for tab with the pipe charcter and you are done.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Actually i am selecting the data in stored procedure. from stored procedure it self i need to upload the data into text file with | delimeter

  • purushotham.k9 (6/9/2010)


    Actually i am selecting the data in stored procedure. from stored procedure it self i need to upload the data into text file with | delimeter

    In that case, look at either a CLR or xp_cmdshell calling bcp;

    bcp has the ability to select a different delimiter when exporting.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • I'm not sure what you're after:

    1. Are you running the procedure from SSMS, and you want to put the results into a text file with this delimiter?

    2. Or do you want the procedure to put the results into a text file with this delimiter?

    Either one is relatively easy, but to give the correct answer, we need to know exactly what you are doing.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • It would help if you explained how you are getting this data, show some code, and then explain what will happen. As Wayne mentioned, there are ways to do this, it would help if you stopped, thought about what you are doing, and then provide more information.

  • Through stored procedure i am selecting some values. I want to add couple of line in the end of sp to copy those values into one text file and plce that text in file into one location.

  • SQL Server can't work with files directly. How is the stored procedure being called? Is there some reason you can't use SSIS and then call a job to run that instead?

  • I too have a similar requirement but we don't have SSIS installed so is there any way a Job can be run to direct the output from an executed sp to a file?

  • Please start another thread for your question & provide details. It will help us focusing on your issue specifically & wonโ€™t mix the responses for previous question.

  • If you are running the SP in a query window then you can copy the results to a text file or an excel file.

    In SSMS go to QUERY menu and there is an option called 'RESULTS TO'. In this option you can pick if you want to send it to a text file.

    Lastly, if you are running the SP in a job then

    Open the job that contains the command to run the SP. Go to the step that executes the SP then in the top left corner you will see the 'ADVANCED' tab. Click that tab and you will see an option to select an 'Output file' for that job step. If the SP is going to spit some results then those results will get saved in that file.

    http://saveadba.blogspot.com/

    Blog
    http://saveadba.blogspot.com/

Viewing 11 posts - 1 through 10 (of 10 total)

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