Home  »  Code Snippets  »  SQL Server  »

Create StoreProcedure for inserting multiple row at a time

 Posted By : Manoranjan SahooPosted Date : 13/07/2011 02:23:49 PM Category : SQL Server Points : 2

sometimes we need to create one store procedure which will insert multiple row into one table and we must pass the list of the value with (,) separate value as parameter.

try below code :


CREATE PROCEDURE insertMultiPleRow
@STRList varchar(600)
AS
DECLARE @str VARCHAR(8000)
SET @str = 'INSERT TableName(Col1) VALUES (' + REPLACE(@STRList, ',', '); INSERT TableName(Col1) VALUES (') + ')'
EXE(@str)
GO

Responses
No responses found for this thread. Be the first to respond this thread.
Post Reply
Login to post Response.