Solved

Insert old user data into aspnet_Users & aspnet_Membership

Posted on 2011-03-02
1
1,244 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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now