22

データベースを 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

私はそれをよく検索しますが、見つけた解決策は役に立ちません。

ありがとう!

4

3 に答える 3

35

ANSI SQL 標準によると、オブジェクト識別子 (必要な場合UPDATE "hotel" ...)) には二重引用符が使用されます (例: 文字列の区切り記号 ( "Overview of Park Central ...")でQUOTED_IDENTIFIERはありません) ON

編集 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" ...) および文字列リテラルの区切り記号( ) として使用できますSELECT "String1" AS Alias1 ...。単一引用符は、ストリングの区切り記号として、および列の別名 ( SELECT Column1 ASAlias1 ...) の区切り記号として使用できます。

代わりに一重引用符を使用します。

update hotel 
set hotel_policy = 'Overview of Park Central ...'
where hotel_id = 1
于 2013-10-26T07:45:22.763 に答える
11

二重引用符を一重引用符に変更したくない場合は、スクリプトの先頭に次の 2 行を追加します。

 SET QUOTED_IDENTIFIER OFF
 SET ANSI_NULLS ON 
于 2014-11-10T15:43:02.143 に答える