DECLARE @DBName varchar(255) DECLARE @DATABASES_Fetch int DECLARE DATABASES_CURSOR CURSOR FOR select DATABASE_NAME = db_name(s_mf.database_id) from sys.master_files s_mf where -- ONLINE s_mf.state = 0 -- Only look at databases to which we have access and has_dbaccess(db_name(s_mf.database_id)) = 1 -- Not master, tempdb or model and db_name(s_mf.database_id) not in ('Master','tempdb','model') group by s_mf.database_id order by 1 OPEN DATABASES_CURSOR FETCH NEXT FROM DATABASES_CURSOR INTO @DBName WHILE @@FETCH_STATUS = 0 BEGIN declare @DBFileName varchar(256) set @DBFileName = datename(dw, getdate()) + ' - ' + replace(replace(@DBName,':','_'),'\','_') exec ('BACKUP DATABASE [' + @DBName + '] TO DISK = N''c:\db backup\' + @DBFileName + ''' WITH NOFORMAT, INIT, NAME = N''' + @DBName + '-Full Database Backup'', SKIP, NOREWIND, NOUNLOAD, STATS = 100') FETCH NEXT FROM DATABASES_CURSOR INTO @DBName END CLOSE DATABASES_CURSOR DEALLOCATE DATABASES_CURSOR
Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts
Sunday, June 3, 2012
Backup all Databases
Monday, December 5, 2011
Saving changes is not permitted - SQL Server
In MS SQL Server Management Studio
Tools
Options
Designers
Table and Database Designers
Uncheck -> Prevent saving changes ...
Tuesday, June 8, 2010
SQL Server Compact 3.5 Toolbox
SQL Server Compact 3.5 Toolbox add-in for Visual Studio 2010. This add-in adds several features to help your SQL Server Compact development efforts: Scripting of tables and data, import from SQL Server and CSV files, and others to come.
Wednesday, May 26, 2010
Difference between TRUNCATE & DELETE
About TRUNCATE
--------------
Much faster than Delete.
Can't be rollback.
Can't use where clause with it.
Can't use on a linked table. (When use on a table which is linked to another table you will see this message "Cannot truncate table 'TableName' because it is being referenced by a FOREIGN KEY constraint."
After using TRUNCATE all of the memory space is released back to the server.
About Delete
--------------
Slower than TRUNCATE.
Can be rollback (as its a DML operation).
Can use where clause with it.
After using Delete Command The memory will be occupied till the user does not give ROLLBACK or COMMIT.
--------------
Much faster than Delete.
Can't be rollback.
Can't use where clause with it.
Can't use on a linked table. (When use on a table which is linked to another table you will see this message "Cannot truncate table 'TableName' because it is being referenced by a FOREIGN KEY constraint."
After using TRUNCATE all of the memory space is released back to the server.
About Delete
--------------
Slower than TRUNCATE.
Can be rollback (as its a DML operation).
Can use where clause with it.
After using Delete Command The memory will be occupied till the user does not give ROLLBACK or COMMIT.
Subscribe to:
Posts (Atom)