insert row of the data with special character as content in the table

  • INSERT INTO [dbo].[Events]

    ([ID]

    , [Questions]

    ,[Answer_A]

    ,[Answer_B]

    ,[Answer_C]

    ,[Answer_D]

    ,[Answer_Key])

    VALUES

    (7

    ,'When completing an event report it is necessary to document the following except:'

    ,'the severity level of the patient or resident' & [font="Arial Black"]chr(44)[/font] & 'injury'

    ,'the patient’s roommate’s name'

    ,'the condition of the patient or resident'

    ,'date, time and location of the event'

    ,'b')

    Thanks.

    I tried this it did not work , too.

    INSERT INTO [dbo].[Events]

    ([ID]

    , [Questions]

    ,[Answer_A]

    ,[Answer_B]

    ,[Answer_C]

    ,[Answer_D]

    ,[Answer_Key])

    VALUES

    (7

    ,'When completing an event report it is necessary to document the following except:'

    ,'the severity level of the patient or resident' & [font="Arial Black"]''''[/font] & 'injury'

    ,'the patient’s roommate’s name'

    ,'the condition of the patient or resident'

    ,'date, time and location of the event'

    ,'b')

    that is the text I need to import.

    the severity level of the patient or resident's injury

  • char(44) is a comma, is that your special character?

    this statement in syntactically correct:

    --the char

    select char(44)

    --an example

    select 'the severity level of the patient or resident' + char(44) + 'injury'

    INSERT INTO [dbo].[Events]

    ([ID]

    , [Questions]

    ,[Answer_A]

    ,[Answer_B]

    ,[Answer_C]

    ,[Answer_D]

    ,[Answer_Key])

    SELECT 7

    ,'When completing an event report it is necessary to document the following except:'

    ,'the severity level of the patient or resident' + char(44) + 'injury'

    ,'the patient’s roommate’s name'

    ,'the condition of the patient or resident'

    ,'date, time and location of the event'

    ,'b'

    select char(44)

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • To help you find the change that Lowell did to make your code work, you've done a little too much VB.NET. 🙂

    SQL uses + where VB.NET uses & (well, and the correct function name). Makes life interesting when you're trying to work with a number and a varchar.

    & in T-SQL is a Bitwise AND result.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • Thanks. you are right. I could not recall + sign any more after no coding for a while.

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

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