ALTER PROCEDURE upProduct_Insert
@CategoryId int,
@ArticleNr varchar(20),
@Fullname varchar(100),
@Notes varchar(4000),
@Price money,
@Pricecategory varchar(1000), -- '1,2,3'
@PricecategoryValue varchar(4000) -- '10,20,30'
AS
Set nocount On
Declare @Identity as integer
Insert Into Product
(CategoryIDno, ArticleNr, Fullname, Notes, Price)
Values
(@CategoryId, @ArticleNr, @Fullname, @Notes, @Price)
Select @Identity = @@Identity
Create table #tmp1 (value varchar(400))
Insert Into #tmp1 (value)
Select value From fn_split(@Pricecategory, ',')
Create table #tmp2 (value varchar(400))
Insert Into #tmp2 (value)
Select value From fn_split(@PricecategoryValue, ',')
Select @Identity
Select value From #tmp1
Select value From #tmp2
go
upProduct_Insert 32,'123', 'fsdfsd', 'fsdfsdfasee', 599, '1,2,3', '10,20,30'
se bifogad bild för resultat av de 3 selecterna
av dessa vill jag göra en insert i en ny tabell med 3 kolumner och med följande resultat:
30 1 10
30 2 20
30 3 30
kom på´t!
la till en identity på inserterna i tmp-tabellerna
Create table #tmp1 (IDno int IDENTITY(1,1) NOT NULL, value varchar(400))
Insert Into #tmp1 (value)
Select value From fn_split(@Pricecategory, ',')
Create table #tmp2 (IDno int IDENTITY(1,1) NOT NULL, value varchar(400))
Insert Into #tmp2 (value)
Select value From fn_split(@PricecategoryValue, ',')
Insert Into Product_Pricecategory
(ProductIDno, PricecategoryIDno, Notes)
Select @Identity, t1.value, t2.value From #tmp1 t1 Inner Join #tmp2 t2 on t1.IDno = t2.Idno
258 ms totalt · 4 externa anrop · v20260731065814-full.51f67c91