"How do I run a query where i save the data like the following"
what query are you trying to run? what are you trying to do? need clarification...
davidi1
ASKER
HainKurt - I dont have any query. I dont know how to write a query for this. hence the ask.
prajapati84
From frontend,
Pass the all the four fields as parameters in your stored procedure,
@Textbox1 (textbox1 value)
@Textbox2 (textbox2 value)
@Textbox3 (textbox3 value)
@NTLoginList (comma seperated string)
At backend, in stored procedure
@Textbox1 varchar(255),
@Textbox2 varchar(255),
@Textbox3 varchar(255),
@NTLoginList varchar(max)
Here you need to split the NTLoginList with comma with split function.
Then you can insert the splitted NTLogin items one by one (from the array of NTLogin) with other three values Textbox1,Textbox2,Textbox3 in your database table
As per my understanding you want to insert into databse multple entries at one time. 3 of the fields in your insert statment will have same value. but only last column will have different value. Your problem is to seperate those comma separate value and insert them to database.
if that is the case.
I will assue that three textbox values are in these three variables when you pass them to sql server
set @Text1 =' Textbox1'
set @Text2 =' Textbox2'
set @Text3 = ' Textbox3'
set @NTLogin = 'Ntlogin,Ntlogin1,Ntlogin2,)
then you can use this insert statement after creating function as in my previous post.
insert into yourtable(Text1, Text2, Text3, Login)
select @Text1, @Text2,@Text3, item from dbo.fnSplit(@NTLogin, ',')
this will insert data like you desired
SAMIR BHOGAYTA
USE YourDB
GO
INSERT INTO MyTable (FirstCol, SecondCol)
VALUES ('First',1);
INSERT INTO MyTable (FirstCol, SecondCol)
VALUES ('Second',2);
INSERT INTO MyTable (FirstCol, SecondCol)
VALUES ('Third',3);
INSERT INTO MyTable (FirstCol, SecondCol)
VALUES ('Fourth',4);
INSERT INTO MyTable (FirstCol, SecondCol)
VALUES ('Fifth',5);
GO
what query are you trying to run? what are you trying to do? need clarification...