I want to Insert "'765','76','70','70','80','82','11'" into nvarchar column in sql-server. How it's possible?
-
What have you tried so far, and what exactly was the problem?Mureinik– Mureinik2017-09-23 14:32:43 +00:00Commented Sep 23, 2017 at 14:32
-
3Please note that we often see people putting comma-separated values into one column in SQL, and then they get all sorts of problems trying to get them out individually. There is a better way of storing the data if you are going to need the individual parts.Andrew Morton– Andrew Morton2017-09-23 14:48:48 +00:00Commented Sep 23, 2017 at 14:48
-
1Seriously reconsider doing this. It's a terrible idea and violated 1NFS3S– S3S2017-09-23 17:04:25 +00:00Commented Sep 23, 2017 at 17:04
-
@AndrewMorton I have a key-value table as config. Imagine these are codes of some info that are forbidden in filtering a query result. So I have a key to select config, and according value, in addition to Id. The Value column type is nvarchar, and in my case these codes are string to.Elnaz– Elnaz2017-09-24 05:22:18 +00:00Commented Sep 24, 2017 at 5:22
Add a comment
|
1 Answer
Here you go:
DECLARE @N NVARCHAR(MAX);
SET @N = '''765'',''76'',''70'',''70'',''80'',''82'',''11''';
SELECT @N AS Result;
Result:
+-------------------------------------+
| Result |
+-------------------------------------+
| '765','76','70','70','80','82','11' |
+-------------------------------------+