zoukankan      html  css  js  c++  java
  • 解决 SQL 不能正确显示中文问题

    use DataBaseName
    go
    if not OBJECT_ID('[Employees]') is Null
       Drop Table [Employees]
    go
    Create Table [Employees]
    (ID int Primary Key Identity(1,1),
     [Name] Nvarchar(50) Not Null,
     [Title] Nvarchar(50) Null,
     [Phone] int Null,
     [City] Nvarchar(20))
     go
     Insert Into [Employees] 
     select '张三', '采购经理', 1234567, '北京'
     Union All
     select '李四', '销售', 7654321, '上海'
     Union All
     select '王小', '前台', 1230000, '上海'
    
     select * from [Employees] where [City] = '上海'
    View Code

    结果显示:

     不改变排序规则和字段类型,加 N 解决:

    use DataBaseName
    go
    if not OBJECT_ID('[Employees]') is Null
       Drop Table [Employees]
    go
    Create Table [Employees]
    (ID int Primary Key Identity(1,1),
     [Name] Nvarchar(50) Not Null,
     [Title] Nvarchar(50) Null,
     [Phone] int Null,
     [City] Nvarchar(20))
     go
     Insert Into [Employees] 
     select N'张三', N'采购经理', 1234567, N'北京'
     Union All
     select N'李四', N'销售', 7654321, N'上海'
     Union All
     select N'王小', N'前台', 1230000, N'上海'
    
     select * from [Employees] where [City] = N'上海'
    View Code

    结果显示:

  • 相关阅读:
    求解奖学金问题--贪心
    装饰模式(Decorator Pattern)
    组合模式(Composite Pattern)
    Java基础:容器
    DatabaseMetaData类
    Java命名规范
    MyEclipse快捷键
    工厂模式(Factory)
    单例模式详解以及需要注意的地方(Singleton)
    SpringBoot启动流程与源码
  • 原文地址:https://www.cnblogs.com/endless-on/p/3172024.html
Copyright © 2011-2022 走看看