1

I want to generate backup of specific table in SQL Server 2014 through a SQL Query.

I can generate it manually but I want to generate it through a SQL Query. Can any body help me to do that?

TheGameiswar
  • 27,855
  • 8
  • 56
  • 94
M.K.S
  • 51
  • 1
  • 3
  • 10
  • check the link - http://dba.stackexchange.com/questions/102745/how-can-i-take-backup-of-particular-tables-in-sql-server-2008-using-t-sql-script – Abhishek Oct 31 '16 at 07:39
  • @Abhishek they solved it in very difficult way I want easy solution which would be understandable – M.K.S Oct 31 '16 at 07:42
  • Is exporting it to CSV an option? http://stackoverflow.com/a/21286975/5418176 – DenStudent Oct 31 '16 at 07:44

1 Answers1

1

You've not provided much information as to what exactly you require with this, but you can do a simple SELECT * INTO, which will create a table based off the table you reference in the SELECT * command.

Example:

Say you have a table called Accounts, and you want to create a backup of this table, calling it AccountsBackup, you can do this:

SELECT *
INTO AccountsBackup
FROM Accounts

Note, this will create a table with the same schema in the same database as the Accounts table and insert all records from the source table in to it. This will not copy primary keys or constraints, it will be a simple dump of the source table.

Also, this table shouldn't exist before you run the above SQL, so if you plan on doing this more than once, either check if it exists first or generate unique names each time.

Tanner
  • 22,205
  • 9
  • 65
  • 83