in Search
 
           
Welcome to SPAN Sign in | Join |
 
 

SqL statement "N" keyword

Last post 11-20-2007, 10:27 AM by lyfatt3. 1 replies.
Sort Posts: Previous Next
  •  11-19-2007, 4:39 PM 566

    SqL statement "N" keyword

    Hi I try to convert the following SQL Statement from

    WHERE (U.login_email = N'" & UserID & "')   to

    WHERE (U.login_email = @UserID)

     Basically just change from Dynamic string to parameter object. However I have a concern on the Original "N" keyword. Can someone tell me what that mean? I try put u.login_email = N@UserID but it does not work. I change back to u.login_email = @UserID and it work. I worry what is the meaning of 'N' keyword which might take any side effect if my conversion is not right.

     

    Thank you

  •  11-20-2007, 10:27 AM 567 in reply to 566

    Re: SqL statement "N" keyword

    hi,

     show u some example

    /*
    A. Execute a simple SELECT statement
    This example creates and executes a simple SELECT statement that contains an embedded parameter named @level.
    */

    use master
    go

    execute sp_executesql
              N'select * from pubs.dbo.employee where job_lvl = @level',
              N'@level tinyint',
              @level = 35

     

    N'select * from pubs.dbo.employee' , the N'abc123' will change the 'abc123' as nVarchar data string. variable-length (nvarchar) is  Unicode data and use the UNICODE UCS-2 character set. normally we use it to support the 2 byte character, example like Thai character, or chinese character and other. nVarchar can support maximum 4000 character in a variable. other then using for chinese character , i aslo use it to contruct a dynamic select Statement,  let user choose some question, contruct the Query Statement from the answer, and using the ExecuteSql to run the select Statement. u can refer the example above.

    important note:]

    Use nvarchar when the data entries in a column are expected to vary considerably in size.

    SET ANSI_PADDING OFF does not apply to nchar or nvarchar. SET ANSI_PADDING is always ON for nchar and nvarchar.

    regarding the sp_ExecuteSql, u may refer the SQL server book online.

    regarding the nVarchar, u may refer the SQL server book online.

     

     

     

View as RSS news feed in XML
 
SPAN © COPYRIGHTS 2006. |  PRIVACY STATEMENT  |  TERMS OF USE  | FAQ