views:

602

answers:

2

I've got an SQL query that looks like this:

INSERT INTO DB..incident
( 
    incident_number        --nvarchar(10)
)
VALUES 
(
    N'I?'
)

What does the ? do in the value statement?

EDIT:: Turns out there's some funny business via triggers and custom datatypes that occur on insert (we've got a bit of a messed up DB.) Given normal settings I've marked the answer appropriately.

+6  A: 

At the risk of sounding flippant... Nothing... It puts an I? into the field... Try this...

DECLARE @TestTable TABLE (test NVARCHAR(10))

INSERT INTO @TestTable (
    test
) VALUES ( 
    N'I?' ) 


SELECT * 
FROM  @TestTable
TGnat
Hear hear! At the risk of offending, I see many questions here that make me wonder why the questioner didn't just perform an experiment on their own. Of course there may always be factors that I don't know about, but I like the encouragement to have the questioner investigate.
Blair Conrad
+1  A: 

The question in my mind when I read this was, what does the N do?

In Oracle, N before a character string literal indicates that the string should be encoded in the national (i.e. localized) character set rather than the default character set for the database.

So as the others have said, you're inserting the string 'I?' into the column. However, it may be encoded using a different character set (although since these characters are in the standard ASCII range the result will probably be the same).

Dave Costa
N indicates it is inserting unicode characters
HLGEM