How to insert all types of special char in database table

  • 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.

      CREATE TABLE #test

      (

      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

  • 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

  • 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...)



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply