hi
u can try the following
I wrote it along time ago so u need to update some of the fields according to the new tables
u can add more customer attributes i only took name and last name
hope it helps
declare
@CustomerGuid uniqueidentifier,
@Username nvarchar(1000),
@Email nvarchar(1000),
@Password nvarchar(max),
@PasswordFormatId int,
@PasswordSalt nvarchar(max),
@AdminComment nvarchar(max),
@IsTaxExempt bit,
@AffiliateId int,
@VendorId int,
@Active bit,
@Deleted bit,
@IsSystemAccount bit,
@SystemName nvarchar(max),
@LastIpAddress nvarchar(max),
@CreatedOnUtc datetime,
@LastLoginDateUtc datetime,
@LastActivityDateUtc datetime,
@BillingAddress_Id int,
@ShippingAddress_Id int,
@IsBanned bit,
@EntityId int,
@FirstName nvarchar(400),
@LastName nvarchar(max),
@InsertId int,
@i int = 0,
@EmailExternal nvarchar(max),
@ExternalIdentifier nvarchar(max),
@ExternalDisplayIdentifier nvarchar(max),
@OAuthToken nvarchar(max),
@OAuthAccessToken nvarchar(max),
@ProviderSystemName nvarchar(max)
WHILE @i < 500000 BEGIN
SET @i = @i + 1
SET @EntityId = @i
SELECT
@CustomerGuid = [CustomerGuid],
@Username = [Username],
@Email = [Email],
@Password = [Password],
@PasswordFormatId = [PasswordFormatId],
@PasswordSalt = [PasswordSalt],
@AdminComment = [AdminComment],
@IsTaxExempt = [IsTaxExempt],
@AffiliateId = [AffiliateId],
@VendorId = [VendorId],
@Active = [Active],
@Deleted = [Deleted],
@IsSystemAccount = [IsSystemAccount],
@SystemName = [SystemName],
@LastIpAddress= [LastIpAddress],
@CreatedOnUtc = [CreatedOnUtc],
@LastLoginDateUtc = [LastLoginDateUtc],
@LastActivityDateUtc = [LastActivityDateUtc],
@BillingAddress_Id = [BillingAddress_Id],
@ShippingAddress_Id = [ShippingAddress_Id]
FROM [windalert_sql].[dbo].[Customer]
WHERE Id = @EntityId
IF @@RowCount <> 0
BEGIN
SELECT @FirstName = [Value] FROM [windalert_sql].[dbo].[GenericAttribute]
WHERE EntityId = @EntityId AND [Key] = 'FirstName'
SELECT @LastName = [Value] FROM [windalert_sql].[dbo].[GenericAttribute]
WHERE EntityId = @EntityId AND [Key] = 'LastName'
INSERT INTO [windalert].[dbo].[Customer]([CustomerGuid],[Username],[Email],[Password],[PasswordFormatId],[PasswordSalt],[AdminComment],[IsTaxExempt]
,[AffiliateId],[VendorId],[Active],[Deleted],[IsSystemAccount],[SystemName],[LastIpAddress],[CreatedOnUtc] ,[LastLoginDateUtc]
,[LastActivityDateUtc] ,[BillingAddress_Id],[ShippingAddress_Id])
VALUES
( @CustomerGuid,@Username ,@Email,@Password,@PasswordFormatId,@PasswordSalt,
@AdminComment,@IsTaxExempt,@AffiliateId,@VendorId,@Active,
@Deleted,@IsSystemAccount,@SystemName,@LastIpAddress,@CreatedOnUtc,
@LastLoginDateUtc,@LastActivityDateUtc,@BillingAddress_Id,@ShippingAddress_Id
)
SELECT @InsertId = Id from [windalert].[dbo].[Customer] where Email = @Email
INSERT INTO [windalert].[dbo].[GenericAttribute]([EntityId],[KeyGroup],[Key],[Value],[StoreId])
VALUES(@InsertId, 'Customer', 'FirstName', @FirstName,0)
INSERT INTO [windalert].[dbo].[GenericAttribute]([EntityId],[KeyGroup],[Key],[Value],[StoreId])
VALUES(@InsertId, 'Customer', 'LastName', @LastName,0)
SELECT
@EmailExternal = [Email],
@ExternalIdentifier = [ExternalIdentifier],
@ExternalDisplayIdentifier = [ExternalDisplayIdentifier],
@OAuthToken = [OAuthToken],
@OAuthAccessToken = [OAuthAccessToken] ,
@ProviderSystemName = [ProviderSystemName]
FROM [windalert_sql].[dbo].[ExternalAuthenticationRecord] WHERE CustomerId = @EntityId
IF @@RowCount <> 0
BEGIN
INSERT INTO [windalert].[dbo].[ExternalAuthenticationRecord]
([CustomerId],[Email],[ExternalIdentifier],[ExternalDisplayIdentifier]
,[OAuthToken] ,[OAuthAccessToken] ,[ProviderSystemName])
VALUES(@InsertId,@EmailExternal,@ExternalIdentifier,@ExternalDisplayIdentifier
,@OAuthToken ,@OAuthAccessToken ,@ProviderSystemName)
END
END
END
GO