0

I'm using primavera with a SQL Server database.

I switched computers, so I took with me the primavera_DAT, primavera_LOG files, then I installed primavera on the other computer and replaced the above files.

The issue is, whenever I enter primavera, I can establish the connection, but can not login and it is telling me the username and password are wrong.

I did some research and I found out that the usernames and passwords are stored in the master.mdf file.

I also have the master.mdf from the other computer, however when I replace them, I am getting the error whenever I start the SQL Server service from services.

How can I recreate the username or pass for the users (privuser, pubuser) that is, get the new master.mdf like the old one ??

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
tony9099
  • 4,567
  • 9
  • 44
  • 73

1 Answers1

0

You can recreate the necessary logins from the users of your database using sp_change_users_login with 'Auto_fix' which will map existing logins and create new logins if they don't exist. The password has to be given and changed later for not existing logins.

Declare @Membername varchar(255)
Declare @SQl Varchar(8000)


Select @SQL=''
Create Table #tmp
(
DbRole varchar (255),
Membername varchar (255),
MemberSid uniqueIdentifier
)
insert into  #tmp exec sp_helprolemember
Delete from #tmp where Membername in ('sa','dbo','guest')
Delete from #tmp where Membername like ('db_%')


DECLARE P_cursor CURSOR FOR 
SELECT Distinct Membername from #tmp

OPEN P_cursor

FETCH NEXT FROM P_cursor 
INTO @Membername

WHILE @@FETCH_STATUS = 0
BEGIN
   Select @SQL=@SQL + 'exec sp_change_users_login ''Auto_Fix'',  ''' + @Membername +'''  ,   NULL, '+'''B3r12-3x$098f6''' +Char(13)+Char(10) 
   FETCH NEXT FROM P_cursor 
   INTO @Membername
END

CLOSE P_cursor
DEALLOCATE P_cursor
Drop Table #tmp
--Print @SQL
Exec (@SQL)
bummi
  • 27,123
  • 14
  • 62
  • 101