?
Solved

How would you create a stored procedure to insert records containing a field that has mulitple values using SQL Server 2005?

Posted on 2012-04-10
1
Medium Priority
?
185 Views
Last Modified: 2012-04-16
I am creating a Stored Procedure to insert records into a table using SQL Server 2005.

I have a table titled tblA with the following 3 fields and the last field titled

ELEMENT_TYPE_VALUE_PAIRS can have mulitple values in it's field:

ID_TYPE     PRIN_NAME   ELEMENT_TYPE_VALUE_PAIRS

K                          smithj           {(User_Type, Master Access)}  
K                          smithj           {{(Holder,holder-1),(Action,All)}}  
K                          smithj           {{(Holder,holder-2),(Action,Update)}}                
K                          cliffr              {{(Holder,holder-1),(Action,Browse)}}  
K                          cliffr              {(User_Type,Security Officer Access)}  

How would you create a stored procedure to populate table tblA with the values listed above?
0
Comment
Question by:zimmer9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
f_o_o_k_y earned 2000 total points
ID: 37830142
I would use this:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Fooky
-- Create date: 2012-04-10
-- Description:	simple insert
-- =============================================
CREATE PROCEDURE sp_simple_insert 
	-- Add the parameters for the stored procedure here
	@id_type int, 
	@name varchar(50),
	@value varchar(1000)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	INSERT INTO table( ID_TYPE  ,   PRIN_NAME ,  ELEMENT_TYPE_VALUE_PAIRS)
	VALUES(@id_type,@name,@value)
END
GO

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip Migration Tip #1 – Source Server Health can be found listed in my profile here: http:…
Have you considered what group policies are backwards and forwards compatible? Windows Active Directory servers and clients use group policy templates to deploy sets of policies within your domain. But, there is a catch to deploying policies. The…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question