GP2010
SQL 2008 R2
In our DEV or TEST environment, it is often necessary to pull in a fresh copy of the LIVE data. Many times (nay, MOST times) this causes the user logins to fail. Simple enough to just delete the user and re-add them, right? Yes, unless you get the "Deleting the login failed for an unknown reason. Contact your SQL Server Administrator for assistance" error. There is a work-a-round for this in KB 943027 (support.microsoft.com/.../943027) but I was still having some issues even after following those instructions.
When executing the statement DELETE DYNAMICS..SY10000 WHERE USERID = 'User_name', I get the following message:
Msg 4405, Level 16, State 1, Line 1
View or function 'DYNAMICS..SY10000' is not updatable because the modification affects multiple base tables.
However, if I run the below, then SELECT * FROM SY10000 WHERE USERID = 'User_name', no results are displayed (which is good).
-- Ctrl+H to find and replace the 6 occurances of the user's name
DECLARE @USER as varchar(30)
SET @USER = 'User_name'
DELETE COMPANY_1..SY01401 WHERE USERID = @USER
DELETE COMPANY_2..SY01401 WHERE USERID = @USER
DELETE COMPANY_3..SY01401 WHERE USERID = @USER
DELETE DYNAMICS..ACTIVITY WHERE USERID = @USER
DELETE DYNAMICS..SY10500 WHERE USERID = @USER
DELETE DYNAMICS..SY08000 WHERE USERID = @USER
DELETE DYNAMICS..SY60100 WHERE USERID = @USER
DELETE DYNAMICS..SY01600 WHERE USERID = @USER
DELETE DYNAMICS..SY01400 WHERE USERID = @USER
DELETE DYNAMICS..SY01403 WHERE USERID = @USER
DELETE DYNAMICS..SY60100 WHERE USERID = @USER
DELETE DYNAMICS..SY10550 WHERE USERID = @USER
USE DYNAMICS
DROP USER User_name
GO
USE COMPANY_1
DROP USER User_name
GO
USE COMPANY_2
DROP USER User_name
GO
USE COMPANY_3
DROP USER User_name
GO
/*
Only run this if you're still having an issue adding user back to GP as this will
remove the SQL login and affect this user's access to all databases on this instance.
DROP LOGIN User_name
GO
*/
I hope someone finds this helpful and please, VIP's, if you see a glaring issue with any of this, feel free to critique.