Friday, September 17, 2010

MULTIPLE RECORDS IN TABLE AT A TIME

 CREATE PROC [dbo].[INSERT_RECORDS_CompanyRegistration_Table](@Rec_Number int)as
BEGIN

DECLARE @I INT DECLARE @CompanyCode BIGINT,@CompanyName VARCHAR(20),@CompanyContactFirstName NVARCHAR(100),@CompanyContactMiddleName NVARCHAR(100),@CompanyContactLastName NVARCHAR(100),@EmailAddress VARCHAR(50),@WebURL VARCHAR(50),@ContactAddressLine1 VARCHAR(100),@ContactAddressLine2 VARCHAR(100),@ContactStreet VARCHAR(50),@ContactCity VARCHAR(50),@ContactZip VARCHAR(10),@ContactState VARCHAR(30),@ContactCountry VARCHAR(50),@ContactPhone VARCHAR(15),@ContactFax VARCHAR(20),@BillingAddressLine1 VARCHAR(100),@BillingAddressLine2 VARCHAR(100),@BillingStreet VARCHAR(50),@BillingCity VARCHAR(50),@BillingZip VARCHAR(10),@BillingState VARCHAR(30),@BillingCountry VARCHAR(50),@BillingPhone VARCHAR(20),@BillingFax VARCHAR(20)--,@ProfileStatus BIT--,@IsDeleted BIT,@SecurityToken VARCHAR(400),@CompanyURL VARCHAR(1000),@CreatedBy VARCHAR(50)--,@CreatedOn DATETIME,@UpdatedBy VARCHAR(50)
--,@UpdatedOn DATETIME
SET @CompanyCode=23SET @CompanyName='FOCUS'SET @CompanyContactFirstName='Thought'SET @CompanyContactMiddleName='Focus'SET @CompanyContactLastName='TF'SET @EmailAddress='thoughtfocus@gmail.com'SET @WebURL='http://thouhht'SET @ContactAddressLine1='Bang'SET @ContactAddressLine2='Line'SET @ContactStreet= 'Street'SET @ContactCity='City'SET @ContactZip= '786587'SET @ContactState='KA'SET @ContactCountry= 'Ind'SET @ContactPhone='9980428027'SET @ContactFax='60-977089798'SET @BillingAddressLine1= 'BLine1'SET @BillingAddressLine2= 'BLine2'SET @BillingStreet= 'BStreet'SET @BillingCity='BCity'SET @BillingZip='863560'SET @BillingState='AP'SET @BillingCountry='Ind'SET @BillingPhone='9666223134'SET @BillingFax='65970657673'--SET @ProfileStatus=--SET @IsDeleted=
SET @SecurityToken=@ISET @CompanyURL='http://company'
SET @CreatedBy=2--SET @CreatedOn=--@CreatedOn
SET @UpdatedBy=3--SET @UpdatedOn=--@UpdatedOn
SET @I=1WHILE(@I<@Rec_Number)BEGIN
INSERT INTO dbo.CompanyRegistrationSELECT @CompanyCode+CAST(@I AS VARCHAR(20)),@CompanyName+CAST(@I AS VARCHAR(20))+'PAY',@CompanyContactFirstName+CAST(@I AS VARCHAR(20)),@CompanyContactMiddleName+CAST(@I AS VARCHAR(20))
,@CompanyContactLastName,LEFT(@EmailAddress,CHARINDEX('@',@EmailAddress)-1)+'_'+CAST(@I AS VARCHAR(200))+RIGHT(@EmailAddress,10),@WebURL+cast(@I as varchar(50))+'.com',@ContactAddressLine1+CAST(@I AS VARCHAR(20)),@ContactAddressLine2+CAST(@I AS VARCHAR(20)),@ContactStreet+CAST(@I AS VARCHAR(20)),@ContactCity+CAST(@I AS VARCHAR(20)),@ContactZip+CAST(@I AS VARCHAR(20)),@ContactState+CAST(@I AS VARCHAR(20))
,@ContactCountry,@ContactPhone+CAST(@I AS VARCHAR(20)),@ContactFax+CAST(@I AS VARCHAR(20)),@BillingAddressLine1+CAST(@I AS VARCHAR(20)),@BillingAddressLine2+CAST(@I AS VARCHAR(20)),@BillingStreet+CAST(@I AS VARCHAR(20)),@BillingCity+CAST(@I AS VARCHAR(20)),@BillingZip+CAST(@I AS VARCHAR(20)),@BillingState+CAST(@I AS VARCHAR(20)),@BillingCountry+CAST(@I AS VARCHAR(20)),@BillingPhone+CAST(@I AS VARCHAR(20)),@BillingFax+CAST(@I AS VARCHAR(20)),0--@ProfileStatus,0--@IsDeleted
,@SecurityToken,@CompanyURL+CAST(@I AS VARCHAR(20))+'.com'
,@CreatedBy,DATEADD(hh,@i,GETDATE())--@CreatedOn
,@UpdatedBy,DATEADD(hh,1+@i,GETDATE())--@UpdatedOn

END
SET @I=@I+1END

No comments:

Post a Comment