I need to combine two ASP.NET membership databases with the corresponding roles and profile tables. Both databases have the same role and profile structure. They use built-in providers (SqlMembershipProvider and friends). Duplicates are possible.
Do you have any recommendations for me? Is there a tool for this? If not: can you recommend using the membership API or is it easier to use SQL.
Update
Here is the script that I finally used to transfer membership data.
insert into targetMembershipDatabase.dbo.aspnet_users select * from sourceMembershipDatabase.dbo.aspnet_users where username not in (select username from targetMembershipDatabase.dbo.aspnet_users) insert into targetMembershipDatabase.dbo.aspnet_membership select * from sourceMembershipDatabase.dbo.aspnet_membership where userid in (select userid from targetMembershipDatabase.dbo.aspnet_users) and not userid in (select userid from targetMembershipDatabase.dbo.aspnet_membership) insert into targetMembershipDatabase.dbo.aspnet_profile select * from sourceMembershipDatabase.dbo.aspnet_profile where userid in (select userid from targetMembershipDatabase.dbo.aspnet_users) and not userid in (select userid from targetMembershipDatabase.dbo.aspnet_profile) insert into targetMembershipDatabase.dbo.aspnet_usersinroles select * from sourceMembershipDatabase.dbo.aspnet_usersinroles where userid in (select userid from targetMembershipDatabase.dbo.aspnet_users) and not userid in (select userid from targetMembershipDatabase.dbo.aspnet_usersinroles)
Provided as is. Do not check duplicate letters. There is no guarantee that this will work in a more complex scenario.
source share