Add SET @CNT = 1 before the second WHILE line.
Do you need something more?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a table called T_SMS_NOTIFICATIONS in that i want to insert huge records as per date like 80 records for october 8 2020, 920 records for october 9 2020.... 25 records for october 31st.
to do that i have created a table called test which has records like
The below code i have returned to load the records based on date:
DECLARE @NOTIFICATION_ID VARCHAR(36)='5eda1ff6-bf89-11eb-8f1c-8f99b4f0f32b',
@Anton _ID VARCHAR(36)='a90f91bd-bd38-11eb-b4d1-e1fb2b121933',
@solution _TYPE_ID VARCHAR(36)='5c3fb969-bd2d-11eb-b4d1-09b63d5a372d'
DECLARE ROW_COUNT CURSOR
FOR SELECT COUNT FROM TEST
DECLARE @apl DATETIME='2020-10-11 15:40:59.807',
@COUNT BIGINT=3063,
@CNT INT=1,
@NUMBER_OF_RECORDS INT
OPEN ROW_COUNT
FETCH NEXT FROM ROW_COUNT INTO @NUMBER_OF_RECORDS
WHILE @@Fetch _STATUS = 0
BEGIN
WHILE(@CNT<=@NUMBER_OF_RECORDS)
BEGIN
INSERT INTO MASTER.[T_SMS_NOTIFICATIONS]( [NOTIFICATION_ID]
,[BATCH_ID]
,[RECIEVER_PHNUM]
,[SOLUTION_NAME]
,[RESPONSE_CODE]
,[RESPONSE_DESCRIPTION]
,[CREATED_BY]
,[CREATED_DT]
,[LAST_UPDATED_BY]
,[LAST_UPDATED_DT]
,[CHANNEL_ID]
,[PROFILE_ID]
,[SOLUTION_TYPE_ID]
,[SMS_PROVIDER_ID]
,[SMS_ID]
,[RESPONSE_TIME])
VALUES( CONCAT(SUBSTRING(@NOTIFICATION_ID,1,LEN(@NOTIFICATION_ID)-LEN(@COUNT)),@COUNT),
'153517152984',
'oUmkYpw6PM4CdiW5b013Fw==',
'admin',
200,
'TTLExpiredException: The message expired and was dead lettered.',
'ssx==',
@DATE,
'ssx==',
@DATE,
'6485a2b4-8f61-11ea-bc55-0242ac130003',
@PROFILE_ID,
@SOLUTION_TYPE_ID,
'3e7bc5b6-01c4-46d7-ad23-bfa74dc10129',
1,
1)
SET @CNT=@CNT+1
SET @COUNT=@COUNT+1
END
FETCH NEXT from ROW_COUNT INTO @NUMBER_OF_RECORDS
SET @DATE=DATEADD(DD,1,@DATE)
END
DEALLOCATE ROW_COUNT
Since i used nested while loop cursor only takes first value as @number_of_records value and fetch next from row_count into @number_of_records are not working.
I need a script to insert random number of records into a table for different date.
Add SET @CNT = 1 before the second WHILE line.
I also agree with that because I have tried it...
It works until you run out of credits.