Tab_Token_Master(Transid,Token_starts_from,Token_Ends_To,Token_value)
Tab_Token_Details(Transid,Token_No,Token_Value,Token_Status)
The first table is used to store the token starting number and end number.
for example (staring number)1 to 100(ending number). so i have to insert token1,token2...token100 in tab_Token_details table.
how can i insert that number of records using stored procedure?is there for loop to do this task?plz help me in this issue?thnks in advance
declare @Transid int, @TokenStart int, @TokenEnd int, @TokenValue intinsert into dbo.Tab_Token_Details (Transid, Token_No, Token_Value, Token_Status)select @Transid, N, @TokenValue, 'A' -- or whatever your status field should be from dbo.Tally where N between @TokenStart and @TokenEnd
the first table Tab_Token_Master is used to store the token generation and the second table used to store the all generated tokens.
CREATE PROCEDURE create_tokens ( @transid VARCHAR(10), @token_starts_from SMALLINT, @tokens_ends_to SMALLINT, @token_value SMALLINT )ASBEGIN TRANSACTION token_masterINSERT INTO Tab_Token_Master ( transid, token_starts_from, token_ends_to, token_value ) VALUES ( @transid, @token_starts_from, @token_ends_to, @token_value ) COMMIT TRANSACTION token_masterBEGIN TRANSACTION token_details -- uses WayneS's code so you still need to lookup tally table insert into dbo.Tab_Token_Details (Transid, Token_No, Token_Value, Token_Status) select @Transid, N, @token_value , 'A' -- or whatever your status field should be from dbo.Tally where N between @token_starts_from AND @tokens_ends_to COMMIT TRANSACTION token_details RETURN