0

I want to Insert "'765','76','70','70','80','82','11'" into nvarchar column in sql-server. How it's possible?

4
  • What have you tried so far, and what exactly was the problem? Commented Sep 23, 2017 at 14:32
  • 3
    Please 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. Commented Sep 23, 2017 at 14:48
  • 1
    Seriously reconsider doing this. It's a terrible idea and violated 1NF Commented 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. Commented Sep 24, 2017 at 5:22

1 Answer 1

1

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' |
+-------------------------------------+
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.