chosen icon indicating copy to clipboard operation
chosen copied to clipboard

Hi, i m using chosen multi select plugin in my project. it is working fine with adding new records in database table. but i m struggling with retrieving the records while i do edit. In my database table multi select values inserting with comma separator(eg: 2,3,4,). help assist me sort this issue

Open joyalgeorgek123 opened this issue 4 years ago • 3 comments

joyalgeorgek123 avatar Jun 29 '20 05:06 joyalgeorgek123

Capture Capture1

joyalgeorgek123 avatar Jun 29 '20 05:06 joyalgeorgek123

Here my question is why using for loop. No need to use loop. By default chosen multi select submit in array format accept in array on server and insert in table. OR using Join method on server code create comma separated value and pass to procedure. If you are passing comma separated value to your procedure then split there using split method and insert.

INSERT INTO EMPLOYEE_DETAIL (EMPNAME,ADDRESS) SELECT *,@ADDRESS FROM STRING_SPLIT(@EMPLOYEENAME, @SEPARATOR)

https://codingsight.com/several-ways-to-insert-split-delimited-strings-in-a-column/

MahammadMoine avatar Jun 30 '20 18:06 MahammadMoine

Use: STRING_SPLIT for SQL SERVER 2016 to 2019, for SQL SERVER 2014 or previous use:

SELECT split.a.value('.', 'VARCHAR(249)') AS Value FROM (SELECT Cast ('<M>' + Replace(@Años, ',', '</M><M>')+ '</M>' AS XML) AS Data) AS A CROSS apply data.nodes ('/M') AS Split(a)

jacobocano avatar Mar 11 '22 00:03 jacobocano