我正在使用 SQL Server 精简版。我有一个简单的表:
CREATE TABLE people (
ident NCHAR(7) NOT NULL UNIQUE,
first_name NVARCHAR(100) NOT NULL,
last_name NVARCHAR(100) NOT NULL,
notes NVARCHAR(4000) NULL,
birth_year SMALLINT NULL,
birth_location NVARCHAR(200) NULL,
amount SMALLINT NULL,
location NCHAR(6) NOT NULL,
title_date INT NOT NULL,
num INT NOT NULL UNIQUE,
PRIMARY KEY (ident)
);
和一个简单的插入语句:
INSERT INTO people (ident, first_name, last_name, notes, birth_year, birth_location, amount, location, title_date, num)
VALUES ('t1bbbee', 'Sam', 'Simpson', 'HKiONV6JGxKdd2qs5pQ3GGWlrSPRSfu19cJ6zyEn2qT1WHyv5N', 2007, 'N6fCeYVqJcjDov9DDmLfkpYtGs0WV4QeSVRaKm659lw52W21TX', 1143, 'YcbKbv', 19805274, 7735)
和一个基于我阅读文档的简单查询应该可以正常工作:
SELECT p.ident + "-" + p.first_name + " " + p.last_name AS "name"
FROM people AS p
ORDER BY p.ident
但是,这会在 Visual Studio 和SQL Fiddle(后者使用 SQL Server,而不是 SQL Server CE)中返回错误:
列名 '-' 无效。:SELECT p.ident + "-" + p.first_name + " " + p.last_name AS "name" FROM people AS p ORDER BY p.ident
问题是什么?