November 25, 2010 at 12:18 pm
Dear All,
I have a table and i want to allow all the special character insert into that table.
But it causes problem for insert the data in database table for some special character senario.
(
test_col VARCHAR(20)
)
INSERT INTO #test([test_col])VALUES ('sh&&?34')
INSERT INTO #test([test_col])VALUES ('sh&&?!@#$%^&*()_+- ?"'')
Please suggest for the needful.
Thanks in advance.
Thanks and Regards,
Sumanta Panda
November 25, 2010 at 1:25 pm
In your example, the problem was unclosed single quote. If you have single quote, you will have to handle it by enclosing it in another set of single quotes.
If you want to store all kind of special chars and different languages (Accents, tilts), then do not use varchar. Use nVarchar.
-Roy
November 25, 2010 at 1:29 pm
There are several questions:
1) what do you consider being a "special character"? Do you have just a list of character, a rule on how to define it or a list considered as "not special"?
2) If you define a column as VARCHAR(20), you cannt insert 22 character (like you posted in your sample)
3) If you'd like to insert a single quotation mark within a string, it needs to be presented as two single quotation marks ('' instead of '). But make sure to use two single and not a double quotation mark...
4) What are you trying to achieve? (there might be easier solutions available...)
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply