sql - 以......开头的标识符太长。最大长度为 128

标签 sql sql-server

我正在将数据库转移到 MS SQL Server 2008 R2,当我尝试保存长字符串时,它会给出最大长度错误,而我已将该列的数据类型设置为“文本”我用“varchar(max)”替换它,但没有解决方案。

请为我提供解决此问题的解决方案。我正在执行以下查询:

update hotel 
set hotel_policy = 
    "Overview of Park Central New York - New York
    This hotel is making improvements.
        The property is undergoing renovations. The following areas are affected:
        Bar/lounge
        Business center
        Select guestrooms

    Every effort will be made to minimize noise and disturbance.
    Occupying a Beaux Arts building dating to 1927, Park Central New York Hotel is within a block of famed concert venue Carnegie Hall and within a 5-minute walk of Manhattan’s world-renowned Broadway theater district. Prefer the great outdoors to the Great White Way? Central Park is just 3 blocks from the hotel. There, you can rent a rowboat at the lake, play a game of tennis, or visit the Central Park Zoo. The international boutiques and flagship department stores of Fifth Avenue start within a 10-minute walk of the hotel. For travel to sights farther afield, there are 7 subway lines located within 3 blocks of the Park Central.
    The hotel has a snack bar for guests' convenience, and coffee and tea in the lobby.
    Retreat to your guestroom and sink into a bed with a pillowtop mattress and down comforter and pillows. Need to check email or finish up some work? You’ll find a desk with an ergonomic chair and wireless high-speed Internet access (surcharge). Unwind with a video game (surcharge) on the flat-panel HDTV."

where hotel_id = 1

我搜索了很多,但找到的解决方案对我来说没有用。

谢谢!

最佳答案

根据 ANSI SQL 标准,双引号用于对象标识符(例如 UPDATE "hotel"...)(如果必要),而不是用作字符串分隔符(“中央公园概览...”)。当 QUOTED_IDENTIFIERON 时,SQL Server 会出现此行为。

编辑 1: 使用单引号和双引号作为对象标识符(包括列别名)的分隔符的说明如下:

                        Delimiter   Delimiter
                        for         for
SET QUOTED_IDENTIFIER   Object ID   Alias ID        StringDelimiter
ON                      " or []     " or ' or []    '
OFF                     []          " or ' or []    " or '
  • ON 那么双引号可以用作对象标识符(包括列别名)的分隔符,单引号用作字符串文字和/或列别名的分隔符(SELECT Column1 AS 'Alias1' ....)标识符。
  • OFF 那么双引号可以用作列别名的分隔符 (SELECT Column1 AS "Alias1"...) 和字符串文字的分隔符 (选择“String1”AS Alias1 ...)。单引号可用作字符串分隔符和列别名的分隔符 (SELECT Column1 ASAlias1...)。

使用单引号代替:

update hotel 
set hotel_policy = 'Overview of Park Central ...'
where hotel_id = 1

关于sql - 以......开头的标识符太长。最大长度为 128,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19603993/

相关文章:

c# - LINQ 查询语法中的 SQL ROW_NUMBER()

SQL 服务器 : how to return 1 row as default if condition not met

sql - 如何在不使用LIMIT和OFFSET的情况下获得第二高的数字?

Mysql 在一次查询中选择 group by 和不使用 group by

mysql - 我需要子选择吗?

C# - 选择查询在 SqlCommand 中不起作用

sql-server - Microsoft Azure 导出 SQL 数据库

sql - grails-使用GroovyRowResult的列名打印每行的值

sql - 如何仅在存在时删除 SQL Server 2008 中的表

sql - 如何在不复制主键的情况下导出/生成数据?