SQL Server 2012: Table data backup in Excel - sql

Is it possible to take a table's data backup as Excel in SQL Server 2012?
We can get the full database backup by using a maintenance plan automatically in .bak format or using import/export wizard to take Excel backup manually.
But I need to take a table's data backup in Excel (.xlsx/.xls) after 6 hour time interval automatically. Is it possible in SQL Server 2012?

No, you won't be able to do that. The SQL Server backup creates a .BAK file and that is the only option you have. However, what I might suggest you do is to create an SSIS package that takes the data in your database and creates an Excel file, and schedule the SSIS package to fire every 6 hours.
This might be a bit tedious to set up, especially if you have a lot of tables, but it can be done. And, as you probably know, if any of your tables has more than 1M rows, you're going to lose data sending it to Excel.

Related

How to backup script for subset of tables in SQL Express DB

I have developed a SQL Express database. I need to backup all but one table in that database in an automated way. I was thinking i could write a SQL script to do this, trigger it using sqlcmd from a batch file but not sure how to write that SQL script.
I was also thinking, if nothing else possible, i could create a second db that has the tables i want to backup then i write a script that copys data 'into' the second db and then do a auto backup of that entire db. This has the disadvantage of having a procrastinated unpacking of that backup when wanting to use it - its not a small install script.
Is this a possibility, is it the only option or is there tools for SQL Express to do this?
There is no option to exclude just one table while backing up .Few things i could think of
1.Right click database ->Tasks ->generate scripts ->exclude the table you want and choose to save the script and run this every time
2.you could also choose Export option,but since you are using SQL Express,you wont have the option to save this package
Keep the large table in a different database and just backup the original database. You can still use the large table even in a different database, i.e.
SELECT *
FROM MyDb.dbo.SomeTable s
JOIN OtherDb.dbo.LargeTable l
ON (expression);

Generate script for large table SQL Server 2012

How can I generate large table scripts ( data only) in sql server 2012?
-- Have approximately 116463 rows selected after seelect query was cancelled.could be more than that
Please suggest.
To do large amounts of just data the bcp Utility may be of a lot of help it can export data very quickly. It is through the cmd prompt but it is very clean and fast
It is a bulk copy.
This is the information from Microsoft
https://msdn.microsoft.com/en-us/library/ms162802.aspx
Look into DTS Wizard. It is fast, easy and just right for such one time jobs. You can control where the data goes to, including another SQL Server, Excel, CSV, etc.... And, if needed, move the data in reverse, from your backup medium back into the original database. DTS Wizard...don't go anywhere without it. ;)
Right click your database in the Object Explorer
Choose Tasks
Choose Export Data to bring up the SQL Server Import and Export Wizard and pick your source (DB and table or query) and destination.

Best Approach for migrating data from Access to SQL Server in SSIS

Please Let me know if any best approach available for these two SSIS Activities.
migrating access data to SQL Server table
multiple Access dbs are used as a source to migrate the data into a SQL table.
SQL server table to SQL server table
Is this a one time job that should it be done periodically?
If one time job, then you can use SQL server Import Data utility to accomplish both things easily.
If it is just copy of data from source to destination without any modification to data, then there is no need to use SSIS.
Use the SQL server Import and export wizard, at the end don't click on run now, and save the package , you can schedule these packages to do the same for you,
Yes you can copy from access to SQL table, and from SQL table to SQL table.
http://msdn.microsoft.com/en-us/library/ms140052%28v=sql.105%29.aspx

SQL Server 2005 backup and restore

I have two backup files
1) is named 'backup.sql' with a bunch of SQL defining TABLES
2) is named 'backup' with a bunch of encoded data, which I believe are the ROWS
I need to restore these TABLES + ROWS, but all I am able to figure out is how to restore the tables.
Any tips on dealing with these files? It's the first time I ever deal with SQL Server.
The backup process would not create a file with actual SQL statements, it would create a binary file. So #1 is not a backup file (it's probably a script someone saved to re-create the schema).
I would try to use SQL Server Management Studio to restore the second file and see what happens. I don't think it will allow you to restore an invalid file, but I would take some basic precautions like backing up the system first.
What is the extension for the 'backup' file? Is the filename backup.bak? If you have a backup file created by sql server then it 'should' contain the logic to create both the tables and restore the data, but it could depend on how the backup was created.
---Edit
It is possible for a .SQL file to contain data values as well as the logic to create the tables/columns for a database. I used to run backups of a MySql database in this way a long time ago...it just is not seen very often with SQL server since it has built in backup/restore funcationality.
Seems unlikely they would export all the rows from all tables into CSV file, and given you said it looks encrypted, it's making me think that's your actual backup file.
try this, save a copy of the "backup" file, rename it to backup.bak and run this from SQL Server Management Studio
restore filelistonly from disk='C:\backup.bak'
(assuming your file is saved on the root of the C: drive)
Any results/errors?

Move selected data from one server to another sql server 2008

I need to move selected data from 800+ tables in one database to the same 800+ tables in another database in another server. The data I select is based on date fields of every table. So, if I say table 1 date from 01/01/10 to 01/15/10, then only that data I want to be copied into the other server's database table specified.
I hope I am not confusing anyone. What is easiest way to do this?
Look into SSIS. What you're talking about is very easy using it. Here is a page that talks about using variables in SSIS.
If this is a one time solution and the destination database is going to be a brand new one. I would restore a backup from the source database and then delete all the records outside of the date range I want in the new database.
If this is a one time solution and you need to move the data to an existing database you can use the export/import wizard in SQL Server Management Studio (This is not in Express edition). Right click on the database go to task and select export data. Then you can use a query to select the data based on the date range from the source table.
You can also link the servers and just run an insert into Server1.database.dbo.table1 to Server2.database.dbo.Table2.
If you will be moving data everyday I would recommend you to create an SSIS package. You can use the Export Wizard and save the SSIS package at the end. Then you can modify the SSIS package using Visual Studio.