April 22, 2012 at 3:44 pm
How to create a dynamic procedure to insert multiple data into two or more tables
April 22, 2012 at 5:20 pm
Can you explain the requirements in more detail please?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 22, 2012 at 11:19 pm
This is the best I could do with the vague question you posted:
Create Procedure Give_More_Details
@Table1 varchar(10),
@Table2 varchar(10),
@Col1 varchar(10),
@Col2 varchar(10),
@Data1 varchar(max),
@Data2 varchar(max)
As
Declare
@query1 varchar(max),
@query2 varchar(max)
Begin
Set @query1 = 'Insert Into '+@Table1+'('+@Col1+') Values('''+@Data1+''');'
Set @query2 = 'Insert Into '+@Table2+'('+@Col2+') Values('''+@Data2+''');'
Exec (@query1)
Exec (@query2)
End
Hope this helps. If not then please read the name of the procedure.:-P:-D
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply