Sometime you required to erase all your data from application table but you don’t want to loos your precious data. there are two ways to take backup of data.
- first, To take backup of whole database, which contains .mdf file and log file.
- second, to take only one table backup in same database.
To take one table back in same database use following query.
SELECT * INTO <NEW TABLE NAME> FROM <OLD TABLE NAME>
NEW TABLE NAME – BACK UP TABLE NAME (I.E.NEW TABLE)
OLD TABLE NAME – NAME OF THE TABLE YOU WANT TO TAKE BACKUP
Add New Column in Table Use following Query:
ALTER TABLE <TABLENAME>
ADD <COLUMN NAME> <DATA TYPE> <NULL / NOT NULL>
Alter Table Column, Use following Query:
ALTER TABLE <TABLE NAME>
ALTER COLUMN <COLUMN NAME> <DATA TYPE>