troubleshooting Question

Dynamic insert into an table on sql server

Avatar of gosi75
gosi75Flag for Iceland asked on
Microsoft SQL Server 2008SQL
1 Comment1 Solution324 ViewsLast Modified:
I need some help to finish my code as this programming is new to me. I have 110 Entity_SQN number that I need to generate a new line based on current values for that SQN Number in the DIM_Category table, where I need to alter only 2 column values in the new line.  

Example: for each Entity_SQN I need a new line where Detail_SQN should be 0, Grouping1,Grouping2,Description, Entity and Entity_SQN should be the same as in DIM_Category for that Entity_SQN and Text should have the value 'No Category'

I would appreciate if someone could help me finish the code, what I'm having problems with is how do I insert the values from the DIM_Category table?

DECLARE @Detail_SQN int,
		@Grouping1 varchar(100),
		@Grouping2 varchar(100),
		@Description varchar(255),
		@Text varchar(255),
		@Entity varchar(37),
		@Entity_SQN int
SET @Detail_SQN = 0
set @Grouping1 = ?
set @Grouping2 = ?
set @Description = ?
set @Text = 'No Category'
set @Entity = ?
set @Entity_SQN = ?

--This query gives me the correct result to add into the DIM_Category table
Select distinct @Detail_SQN,Grouping1,Grouping2,Description,@Text,Entity,Entity_SQN
FROM DIM_Category
where Entity_SQN in 
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros