Pawel's profileOut of Space - Pawel Pot...PhotosBlogListsMore Tools Help

Blog


    January 09

    SQLCMD utility - horrible documentation

    I must say I hate to visit Microsoft's connect site. However, last time I visited it many times. I've been writing an article on SQLCMD utility for several days and I have found some errors in documentation. For example:
     
    If you do not specify a user name when you start sqlcmd, SQL Server checks for and uses the SQLCMDSERVER environment variable.
     
    The sentence above refers to -S option which is used to set the server and instance name when connecting to SQL Server with SQLCMD. The error is obvious. SQLCMDSERVER and -S option have nothing to do with user name...
    January 08

    New Polish MVPs

    There are four MVPs from Poland, among them someone I know - Noise (Networking MVP). Big congratulations! Respect to my friend, Maciej Pilecki, who was re-awarded. No wonder. This guy is everywhere, always talking about SQL Server ;-) The real MVP.

    See Polish MVP site: http://www.microsoft.com/poland/communities/mvp/.

    January 06

    A method to rename logins [SQL Server 2000]

    Last days there was a question on WSS.pl: how can you change login names in SQL Server after the domain migration?
     
    There is a way to change them in SQL Server 2000:
     
    -- Run server in single user mode (sqlsrvr,.exe -m)
    EXEC master.dbo.sp_configure 'allow updates', '1'
    RECONFIGURE WITH OVERRIDE

    USE master
    GO

    UPDATE dbo.sysxlogins
    SET name = REPLACE(name,N'your_old_domain_name\',N'your_new_domain_name\')

    EXEC master.dbo.sp_MSForEachDB
    'UPDATE ?.dbo.sysusers SET name = REPLACE(name,N''your_old_domain_name\'',N''your_new_domain_name\'')'

    EXEC master.dbo.sp_configure 'allow updates', '0'
    RECONFIGURE WITH OVERRIDE

     
    In SQL Server 2005 just use ALTER LOGIN statement to change the login name.