Importing data into the ASP.NET profile table

 

I had a requirement to bring a bunch of data into the ASP.NET Profile table from a data export.

After some reading about the format of the PropertyValuesString table on 4guysfromrolla.com: -

http://aspnet.4guysfromrolla.com/demos/printPage.aspx?path=/articles/101106-1.aspx

I was able to come up with the following bit of SQL: -

INSERT INTO dbo.aspnet_Profile
(UserId,PropertyNames,PropertyValuesString,PropertyValuesBinary,LastUpdatedDate)

SELECT U.UserId, 'FullName:S:0:' + Convert(VarChar,LEN(RTRIM(C.[Contact Name]))) + ':' As PropertyNames, C.[Contact Name] As PropertyValuesString, 0x As PropertyValuesBinary, GetDate() As LastUpdatedDate
FROM Contacts$ C
    JOIN aspnet_Users U
        ON C.[Email Name] = U.UserName collate SQL_Latin1_General_CP1_CI_AS
WHERE NOT U.UserId IN (SELECT UserId FROM dbo.aspnet_Profile)

Thought this might be useful to share. Obviously this is structured for my own Profile which has but one column.

Thanks,

Phil.

Published Sunday, December 09, 2007 12:34 AM by Plip

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required)