Solved

Insert old user data into aspnet_Users & aspnet_Membership

Posted on 2011-03-02
1
1,302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

622 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