Problem
With SQL Server is it possible to move the secondary database involved with Log Shipping to a different drive without disturbing the Log Shipping configuration? If so, what are the steps to accomplish this task? Check out this tip to learn more.
Category Archives: Database
Script to check – Login Name and Password are same
It is always a risk if the user name & password is equal. You can run the below script to find out the list of User/Login name & password which are equal.
select cast(@@SERVERNAME as varchar(150)) as SQLInstanceName ,name as [LoginName] ,'Password is same as Login Name' [Description] from sys.syslogins WHERE PWDCOMPARE (name,password) = 1
sys.sql_logins
sys.sql_logins: Returns one row for each SQL Server authentication login. It will return all the below columns.
- name
- principal_id
- sid
- type
- type_desc
- is_disabled
- create_date
- modify_date
- default_database_name
- default_language_name
- credential_id
- is_policy_checked
- is_expiration_checked
- password_hash
You can query sys.sql_logins to get all the below information.
SQL Logins which are disabled:
SELECT name FROM [sys].[sql_logins] WHERE [is_disabled] = 1;
SQL Server Logins which adhere the password policy:
SELECT name FROM [sys].[sql_logins] WHERE [is_policy_checked] = 1;
SQL Server Logins which do not adhere to the password policy
SELECT name FROM [sys].[sql_logins] WHERE [is_policy_checked] = 0;
SQL Logins which do not adhere to password expiration
SELECT name FROM [sys].[sql_logins] WHERE [is_policy_checked] = 0 OR ([is_policy_checked] = 1 AND [is_expiration_checked] = 0);
Update Statistics Useful Scripts
Script to find out the statistics update date for all the indexes in the current database
sp_MSforeachtable 'sp_autostats "?"'
Script to update the statistics of all the indexes
EXEC sp_MSforeachtable 'UPDATE STATISTICS ? WITH FULLSCAN'
How to check Lock Pages In Memory is enabled?
You can use below simple technique to check whether lock pages in memory is enabled or not. If lock pages in memory is enabled you can see the “Using locked pages for buffer pool” message in the SQL Server error log.
exec xp_readerrorlog 0, 1, 'locked pages'
To check if it is disabled. You have to check for the “Address Windowing Extensions (AWE) requires the ‘lock pages in memory’ privilege which is not currently present in the access token of the process.” message.
exec xp_readerrorlog 0, 1, 'lock pages in memory'