Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

backup query result

Status
Not open for further replies.

williamsandrew144

Programmer
Jul 23, 2015
3
UA
Hello, there is a need to make backup query result. Can you suggest an easy way, please?
 
Make a right click in the result grid => "Save results as"?

"Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family." (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
Hello, there is 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
 


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.
 
I think you are trying to backup part of a database, not the query itself. You can't do that. You can:

1. Backup the entire database
or
2. Copy a full table or part of a table. If this is what you want to do...and it does look like this is what you are asking....then danlout144's suggestion is the way to go.

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top