2013-10-26 302 views
8

以前はYii FrameworkでMS SQL Server 2005を使用していましたが、そこでテーブルとストアドプロシージャを作成しました。しかし、今私はMS SQL Server 2008 R2にシフトされています。私は長い文字列を保存しようとしているとき、それは私の後に "テキスト"としてその列のデータ型を設定している間私に最大長のエラーを与えているそれを "varchar(max)"に置き換えましたが、解決策はありませんでした。...で始まる識別子が長すぎます。最大長は128

私にこの問題を解決する方法を親切に教えてください。私は次のクエリを実行しています:

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 

私はそれを多く探しますが、私がC#で見つけた解決法は役に立ちません。

ありがとうございます!

答えて

15

は、ANSI SQL標準によれば、二重引用符は、オブジェクト識別子の文字列の区切り文字("Overview of Park Central ...")として(例。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" ...)の区切り文字と、文字列リテラルの区切り文字(SELECT "String1" AS Alias1 ...)として使用できます。文字列区切り文字および列別名の区切り文字として、一重引用符を使用できます(SELECT Column1 AS Alias1 ...)。

利用代わりに単一引用符:

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

あなたは、単一引用符を二重引用符を変更したくない場合は、スクリプト

SET QUOTED_IDENTIFIER OFF 
SET ANSI_NULLS ON 
+0

ないの物乞いの2行以下のことを付け加え問題を解決しません。 – Zerubbabel

関連する問題