Solved

Insert old user data into aspnet_Users & aspnet_Membership

Posted on 2011-03-02
1
1,283 Views
Last Modified: 2012-05-11
I'm trying to migrate user data from a previous database into the new aspnet membership schema. Specifically, I want to take user data from one table (UserName, Email) and add those records into the new schema, which means creating the records in the aspnet_Users table and the aspnet_Membership table. I could do it one record at a time through ASP.Net configuration, but I have 9000+ accounts I want to move over. What would be the best way to get this done? Any ideas?
0
Comment
Question by:dodgerfan
1 Comment
 
LVL 7

Accepted Solution

by:
Cboudroz earned 500 total points
ID: 35022792
if you have access to the both database on the same server you can create a cursor in T-SQL and do it in batch whit management studio.

I don't know the database schema, but you can create a cursor like this:


DECLARE @USERNAME VARCHAR(1000)
DECLARE @EMAIL VARCHAR(1000)

DECLARE cur_User CURSOR
FOR 
SELECT 
	USERNAME
	, EMAIL
FROM 
	OLDDATABASE..user  -- put the real database and table name here


OPEN cur_User 


FETCH NEXT FROM cur_User INTO @USERNAME, @EMAIL

WHILE @@FETCH_STATUS = 0
BEGIN 
	-- YOU NEED TO FOUND THE GOOD STORE PROCEDURE TO BE ABLE TO INSERT THE USER
	EXECUTE NEWDATABASE..USER_INS @USERNAME =  @USERNAME, @EMAIL = @EMAIL, @PASSWORD = 'TEST' 

	FETCH NEXT FROM cur_User INTO @USERNAME, @EMAIL
END

CLOSE cur_User
DEALLOCATE cur_User

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL query for highest sequence 4 61
Problem to copy file 14 46
Connect remotely to SQL Server DB without TCP/IP enabled? 2 31
Need help with another query 10 36
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question