31
2013
How to transfer logins and passwords between instances of SQL Server 2008
How to transfer logins and passwords between instances of SQL Server 2008How to transfer logins and passwords between instances of SQL Server 2008 1. On server A, start SQL Server Management Studio, and then connect to the instance of SQL Server from which you moved the database. 2. Open a new Query Editor window, and then run the following script.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
USE master GO IF OBJECT_ID ('sp_hexadecimal') IS NOT NULL DROP PROCEDURE sp_hexadecimal GO CREATE PROCEDURE sp_hexadecimal @binvalue varbinary(256), @hexvalue varchar (514) OUTPUT AS DECLARE @charvalue varchar (514) DECLARE @i int DECLARE @length int DECLARE @hexstring char(16) SELECT @charvalue = '0x' SELECT @i = 1 SELECT @length = DATALENGTH (@binvalue) SELECT @hexstring = '0123456789ABCDEF' WHILE (@i <= @length) BEGIN DECLARE @tempint int DECLARE @firstint int DECLARE @secondint int SELECT @tempint = CONVERT(int, SUBSTRING(@binvalue,@i,1)) SELECT @firstint = FLOOR(@tempint/16) SELECT @secondint = @tempint - (@firstint*16) SELECT @charvalue = @charvalue + SUBSTRING(@hexstring, @firstint+1, 1) + SUBSTRING(@hexstring, @secondint+1, 1) SELECT @i = @i + 1 END SELECT @hexvalue = @charvalue GO IF OBJECT_ID ('sp_help_revlogin') IS NOT NULL DROP PROCEDURE sp_help_revlogin GO CREATE PROCEDURE sp_help_revlogin @login_name sysname = NULL AS DECLARE @name sysname DECLARE @type varchar (1) DECLARE @hasaccess int DECLARE @denylogin int DECLARE @is_disabled int DECLARE @PWD_varbinary varbinary (256) DECLARE @PWD_string varchar (514) DECLARE @SID_varbinary varbinary (85) DECLARE @SID_string varchar (514) DECLARE @tmpstr varchar (1024) DECLARE @is_policy_checked varchar (3) DECLARE @is_expiration_checked varchar (3) DECLARE @defaultdb sysname IF (@login_name IS NULL) DECLARE login_curs CURSOR FOR SELECT p.sid, p.name, p.type, p.is_disabled, p.default_database_name, l.hasaccess, l.denylogin FROM sys.server_principals p LEFT JOIN sys.syslogins l ON ( l.name = p.name ) WHERE p.type IN ( 'S', 'G', 'U' ) AND p.name <> 'sa' ELSE DECLARE login_curs CURSOR FOR SELECT p.sid, p.name, p.type, p.is_disabled, p.default_database_name, l.hasaccess, l.denylogin FROM sys.server_principals p LEFT JOIN sys.syslogins l ON ( l.name = p.name ) WHERE p.type IN ( 'S', 'G', 'U' ) AND p.name = @login_name OPEN login_curs FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @type, @is_disabled, @defaultdb, @hasaccess, @denylogin IF (@@fetch_status = -1) BEGIN PRINT 'No login(s) found.' CLOSE login_curs DEALLOCATE login_curs RETURN -1 END SET @tmpstr = '/* sp_help_revlogin script ' PRINT @tmpstr SET @tmpstr = '** Generated ' + CONVERT (varchar, GETDATE()) + ' on ' + @@SERVERNAME + ' */' PRINT @tmpstr PRINT '' WHILE (@@fetch_status <> -1) BEGIN IF (@@fetch_status <> -2) BEGIN PRINT '' SET @tmpstr = '-- Login: ' + @name PRINT @tmpstr IF (@type IN ( 'G', 'U')) BEGIN -- NT authenticated account/group SET @tmpstr = 'CREATE LOGIN ' + QUOTENAME( @name ) + ' FROM WINDOWS WITH DEFAULT_DATABASE = [' + @defaultdb + ']' END ELSE BEGIN -- SQL Server authentication -- obtain password and sid SET @PWD_varbinary = CAST( LOGINPROPERTY( @name, 'PasswordHash' ) AS varbinary (256) ) EXEC sp_hexadecimal @PWD_varbinary, @PWD_string OUT EXEC sp_hexadecimal @SID_varbinary,@SID_string OUT -- obtain password policy state SELECT @is_policy_checked = CASE is_policy_checked WHEN 1 THEN 'ON' WHEN 0 THEN 'OFF' ELSE NULL END FROM sys.sql_logins WHERE name = @name SELECT @is_expiration_checked = CASE is_expiration_checked WHEN 1 THEN 'ON' WHEN 0 THEN 'OFF' ELSE NULL END FROM sys.sql_logins WHERE name = @name SET @tmpstr = 'CREATE LOGIN ' + QUOTENAME( @name ) + ' WITH PASSWORD = ' + @PWD_string + ' HASHED, SID = ' + @SID_string + ', DEFAULT_DATABASE = [' + @defaultdb + ']' IF ( @is_policy_checked IS NOT NULL ) BEGIN SET @tmpstr = @tmpstr + ', CHECK_POLICY = ' + @is_policy_checked END IF ( @is_expiration_checked IS NOT NULL ) BEGIN SET @tmpstr = @tmpstr + ', CHECK_EXPIRATION = ' + @is_expiration_checked END END IF (@denylogin = 1) BEGIN -- login is denied access SET @tmpstr = @tmpstr + '; DENY CONNECT SQL TO ' + QUOTENAME( @name ) END ELSE IF (@hasaccess = 0) BEGIN -- login exists but does not have access SET @tmpstr = @tmpstr + '; REVOKE CONNECT SQL TO ' + QUOTENAME( @name ) END IF (@is_disabled = 1) BEGIN -- login is disabled SET @tmpstr = @tmpstr + '; ALTER LOGIN ' + QUOTENAME( @name ) + ' DISABLE' END PRINT @tmpstr END FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @type, @is_disabled, @defaultdb, @hasaccess, @denylogin END CLOSE login_curs DEALLOCATE login_curs RETURN 0 GO |
3. Note This script creates two stored procedures in the master database. The procedures […]
29
2013
dbc_RemoteWriteFile: ERR – could not write progress status message to the NAME socket
In continuation with my old post where I troubleshoot the Symantec NetBackup Error (31073), today faced similar error on another server where UAC was enabled earlier but disabled later. On investigation found Error (31073) again but this time even after implementing all solutions from my last post link, faced a new error as below, Error: In GUI console, ERR – Error in CreateEx: 0x80070005. CONTINUATION: – Unknown VDI error code In dbclient, 06:24:13.321 [1628.6700] <2> […]
29
2013
Lock Pages in Memory enabled but “Using locked pages for buffer pool” message not found
On a SQL Server 2005 x64 SP4+CU3 Standard Edition with Lock pages in memory settings enabled, max memory configured, found issue that “Using locked pages for buffer pool” message is not logged in SQL Server Error logs, How to check Lock Pages in Memory is enabled? Run below commands in SSMS and in result you should see message like “Using locked pages for buffer pool” else configure or troubleshoot based on situation, exec xp_readerrorlog […]
28
2013
Memory Supported by the Editions of SQL Server
SQL Server 2005: http://msdn.microsoft.com/en-us/library/ms143685(v=sql.90).aspx SQL Server 2008: http://msdn.microsoft.com/en-us/library/ms143685(v=sql.100).aspx SQL Server 2008 R2: http://msdn.microsoft.com/en-us/library/ms143685(v=sql.105).aspx
16
2013
Using Concatenate function in excel without impacting custom format
Suppose you have date time text in one column (format as YYYY-MM-DD) which you want to use in your concatenate function without changing custom format, because if you don’t do it then in concatenate function it will come in some numerical form for e.g. 40513 instead of 2010-12-01. It happens because excel ignores formatting. Use below to fix it, Say column name is A1 where date value resides and you want to sue it […]
15
2013
[sqsrvres] CheckQueryProcessorAlive: sqlexecdirect failed
Found SQL Server 2005 SP4 CU3 A/P failover cluster SQL services are stopping and starting several times in interval of 30mins to 1 hour. Following errors are found, Application Log Errors: [sqsrvres] printODBCError: sqlstate = 08S01; native error = 0; message = [Microsoft][SQL Native Client]Communication link failure [sqsrvres] CheckQueryProcessorAlive: sqlexecdirect failed [sqsrvres] OnlineThread: QP is not online. [sqsrvres] printODBCError: sqlstate = 08S01; native error = 2746; message = [Microsoft][SQL Native Client]Communication link failure [sqsrvres] […]
14
2013
Delete Blank rows from long list in excel
To quickly remove unwanted blank rows from long list in excel, do following, Select column having blank rows Press the F5 key on your keyboard (or select Edit, Goto). Click the Special… button. Click the Blanks option and click OK. This will select all blank cells in the range you had previously selected. Now right click and choose delete or choose Edit, Delete, select the Entire Row option and click OK. Useful references: http://chandoo.org/wp/2010/01/26/delete-blank-rows-excel/ […]
14
2013
How to drop Publisher database in Transactional Replication
Dropping publisher database may be required in various scenarios; please find steps which can help you to drop in case you are facing issues with it. I am including roll back approach as well, it helps sometimes. First step -> Drop Publication and subscription Second Step -> Drop Database First step, Right click Publication > Generate Scripts > Generate Drop replication and objects script > Save script to local drive Right click Publication […]
14
2013
Restore Publisher Database which is part of Transactional Replication
Today I have to restore a publisher database from production backup in QA environment which is part of transactional replication in SQL Server 2005, now there are multiple ways to do it, visit this link for Microsoft recommendation. My approach was, Stop and remove replication, restore database, recreate replication without reinitializing Before beginning ensure that there is no pending distributed items by going to replication monitor > publication > double click the subscription > […]
14
2013
Copy folder along with security parameters (ACL) using Robocopy utility
Robocopy is very useful Microsoft provided utility and it comes preinstalled in SQL Server 2008 onwards and can be installed via rktools.exe toolkit in Windows Server 2003 (link) You can check if Robocopy is installed or not via opening command prompt as, Run>CMD> <type Robocopy /?> If it shows parameter list then Robocopy is installed on your system else download and install (if you are not allowed to install anything on your server, then […]
Subscribe to this blog via Email
Old Posts
- November 2017 (3)
- October 2017 (4)
- September 2017 (2)
- May 2017 (1)
- April 2017 (1)
- July 2016 (3)
- May 2016 (1)
- April 2016 (1)
- February 2016 (2)
- January 2016 (1)
- October 2015 (1)
- September 2015 (1)
- August 2015 (1)
- July 2015 (2)
- June 2015 (3)
- April 2015 (1)
- March 2015 (1)
- December 2014 (1)
- September 2014 (2)
- April 2014 (1)
- January 2014 (3)
- October 2013 (2)
- September 2013 (2)
- August 2013 (4)
- July 2013 (1)
- June 2013 (2)
- May 2013 (5)
- April 2013 (3)
- March 2013 (1)
- February 2013 (9)
- January 2013 (11)
- December 2012 (14)
- November 2012 (3)
- October 2012 (4)
- July 2012 (2)
- June 2012 (3)
- May 2012 (2)
- April 2012 (8)
- March 2012 (6)
- February 2012 (3)
- January 2012 (1)
- December 2011 (5)
- November 2011 (8)
- October 2011 (5)
- September 2011 (3)
- August 2011 (3)
- July 2011 (3)
- May 2011 (1)
- November 2010 (1)
Tags
View Post by Categories
Recent Articles
- Setting up Always ON Availability Group in Multi Subnet Cluster – Recommendations
- Configuring Replication with Always ON Availability Group
- Login failed for user ‘DOMAIN\COMPUTER$’. Reason: Could not find a login matching the name provided. [CLIENT: ]
- Modern Servicing Model (Service Pack and Cumulative Updates) for SQL Server 2017 and onwards
- Fix: SSMS 2012 opening Debug window when pressing F5