Sunday, 30 December 2012

Recovery model and status of all databases



SELECT name,
DATABASEPROPERTYEX(name, 'Recovery') as [Recovery Model],
DATABASEPROPERTYEX(name, 'Status') as Status
FROM master.dbo.sysdatabases
ORDER BY 1

Use this query to get the recovery model and status of all the databases present in the server.

OR

EXEC sp_msforeachdb 'Select databasepropertyex(''?'', ''recovery'')as ''Recovery Model of ? Database'''

To find only the recovery model of all the databases.

SQL Server Migration Checklist



Are you migrating your SQL Servers?
Here is a quick checklist for your SQL Server Migration.
1.            Build your New Server, Install SQL Server and required updates and keep the server ready for migration
2.            Stop Application Service(s).
This is to ensure that the no applications are connected to the Databases during the migration process.
3.            Change the Properties of the databases that are part of Migration to "Read-only".
This is to ensure that the data modification is not happening by any other sources.
4.             Take a FULL backup of all the User databases that are involved in the Migration Process. 
5.            Move the backups to the destination server or a Shared location, then restore them to the appropriate drives on the destination.
6.            Change the compatibility level of the databases (Optional)
Do this if the applications connecting to these databases are independent of the database compatibility level.
7.            Transfer logins using SSIS (Transfer Logins Task) or using "sp_help_revlogin"
More information about sp_help_revlogin is at 
http://support.microsoft.com/kb/246133
8.            Check for Orphaned Users in the databases and Fix them (if Any)
9.            Update Usage on the migrated Databases
10.          Update Stats on the migrated Databases
11.          Re-Index or Re-Organize Indexes on the migrated Databases
12.          Transfer Jobs using SSIS or manually create them
13.          Build Maintenance plans (if Any)
14.          Recompile database objects if required
15.          Move or rebuild SSIS or DTS packages (if Any)
16.          Create Alerts and Operators (if Any)
17.          Setup High Availability Options (if Any Like Replication, LogShipping, Mirroring)
18.          Test the High Availability options that were setup in the previous step
19.          Point the Application(s) to new Server and start the Application Service(s)
20.          Test the Application(s)

SQL SERVER – DISABLE and ENABLE user SA


/* Disable SA Login */
ALTER LOGIN [sa] DISABLE
GO
/* Enable SA Login */
ALTER LOGIN [sa] ENABLE
GO

How we can connect with sql server cmd mode :-

-->Start:-
 Open cmd windows and write these commands:-
   Sqlcmd –U sa  -P niit
         Go
    Use master
Go
    Sp_help
Go
   sp_help tablename
Go
    select * from sys.tables
Go