解决 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

结果显示:

 

你可能感兴趣的:(sql)