Gavin Miller
Gavin Miller

Reputation: 43825

Question Mark in Insert Statement

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.

Upvotes: 2

Views: 3983

Answers (2)

TGnat
TGnat

Reputation: 4001

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

Upvotes: 6

Dave Costa
Dave Costa

Reputation: 48121

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

Upvotes: 1

Related Questions