delimiter

How do I escape a single quote in SQL Server?

大憨熊 提交于 2019-11-25 22:56:26
问题 I\'m trying to insert some text data into a table in SQL Server 9. The text includes a single quote(\'). How do I escape that? I tried using two single quotes, but it threw me some errors. eg. insert into my_table values(\'hi, my name\'\'s tim.\'); 回答1: Single quotes are escaped by doubling them up , just as you've shown us in your example. The following SQL illustrates this functionality. I tested it on SQL Server 2008: DECLARE @my_table TABLE ( [value] VARCHAR(200) ) INSERT INTO @my_table

SQL split values to multiple rows

送分小仙女□ 提交于 2019-11-25 22:16:51
问题 I have table : id | name 1 | a,b,c 2 | b i want output like this : id | name 1 | a 1 | b 1 | c 2 | b 回答1: If you can create a numbers table, that contains numbers from 1 to the maximum fields to split, you could use a solution like this: select tablename.id, SUBSTRING_INDEX(SUBSTRING_INDEX(tablename.name, ',', numbers.n), ',', -1) name from numbers inner join tablename on CHAR_LENGTH(tablename.name) -CHAR_LENGTH(REPLACE(tablename.name, ',', ''))>=numbers.n-1 order by id, n Please see fiddle

Split string with multiple delimiters in Python [duplicate]

≡放荡痞女 提交于 2019-11-25 22:07:56
问题 This question already has an answer here: Split Strings into words with multiple word boundary delimiters 31 answers I found some answers online, but I have no experience with regular expressions, which I believe is what is needed here. I have a string that needs to be split by either a \';\' or \', \' That is, it has to be either a semicolon or a comma followed by a space. Individual commas without trailing spaces should be left untouched Example string: \"b-staged divinylsiloxane-bis

Can you use a trailing comma in a JSON object?

微笑、不失礼 提交于 2019-11-25 18:54:36
When manually generating a JSON object or array, it's often easier to leave a trailing comma on the last item in the object or array. For example, code to output from an array of strings might look like (in a C++ like pseudocode): s.append("["); for (i = 0; i < 5; ++i) { s.appendF("\"%d\",", i); } s.append("]"); giving you a string like [0,1,2,3,4,5,] Is this allowed? brianb Unfortunately the JSON specification does not allow a trailing comma. There are a few browsers that will allow it, but generally you need to worry about all browsers. In general I try turn the problem around, and add the