Click here to Skip to main content
14,388,761 members
Rate this:
Please Sign up or sign in to vote.
i want to insert multiple int values selected from dropdown in to a single column seperated by a delimiter(,)
along with this values there are some other rows too in which some other values are inserted

a table has
Booking id which contain values like 1
and roomid which contain values like 1,2,3

how can i do it using sql server insert query
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 1

ritesh2712 wrote:
insert multiple int values selected from dropdown in to a single column

Since the comma separated values are selected from a dropdown, form this value in code behind on server side before sending it for SQL update.

So it would be
INSERT INTO tableBook 
(BookingId, RoomId)
VALUES
(1,'1,2,3')
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

You need to normalize your table.

Create a new table which now has bookingid and roomid -

booking id - roomid
-------------------
1 - 1
1 - 2
1 - 3
2 - 44

and so on...
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 3

Parse the int values from drop down selection @ FE convert them to another string variable and then pass it to BE query... we are doing this but in reverse order....can u tell how you are passing the values to BE?
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100