Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2015
    Posts
    2

    Unanswered: backup query result

    Hello, there is a need to make backup query result. Can you suggest an easy way, please?

  2. #2
    Join Date
    Jul 2015
    Posts
    3
    Could you please explain in a bit more detail what it is you need?

  3. #3
    Join Date
    Jul 2015
    Posts
    2
    Thanks for reply, I a need to make backup data from a query. I think about this:
    BACKUP DATABASE 'sourceDB'
    Select * from Table1 where Day = '20.07.2015';
    TO DISK = 'F:\Program Files\Microsoft SQL Server\MSSQL\Backup\sourceDB.bak' WITH FORMAT

  4. #4
    Join Date
    Jul 2015
    Posts
    3
    I would suggest next. If you have access to Management Studio, you can save query results to a file quite easily: 1.Open a query window. One way to do this is by right-clicking on the database name in the Object Explorer. 2.You might want to write the query and run it there first, to test that it is producing the desired results. 3.When you are ready to run the query and save it to file, on the menu choose Query, then Results To, and finally Results to File. 4.Now, when you run the query (F5), you will get a dialog box to indicate the filename and folder to save the data. You can find more details, if you need sqlbak.com/blog/backup-query-results/ That's all there is to it.

  5. #5
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    https://msdn.microsoft.com/en-us/library/ms162802.aspx (aka BCP.EXE) was once the best way to do this, and it is still the most efficient way.

    https://msdn.microsoft.com/en-us/library/ms141026.aspx SSIS does this nicely, with GUI tools.

    It is possible to use BACKUP DATABASE, but it is a LOT more work.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

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