[英]How to concatenate N' strings on insert in SQL
我正在嘗試將字符串插入到 NVARCHAR 中,因為我遇到了字符無法正確進入數據庫的問題。
例如,我有要放入數據庫的字符串,但要顯示特殊字符,似乎我需要 N' 來存儲 Unicode。
N'I used tö like SQL'
但有時這些字符串中已經有單引號。 例如
"I dön't anymore"
如何連接這些字符串以便仍然存儲 Unicode。 我認為這樣的事情會起作用,但我沒有運氣。
(N'' + "I dön't anymõre")
任何幫助將不勝感激謝謝!
要在 SQL 字符串中包含撇號,您需要將撇號加倍,如下所示:
N'I dön''t anymore'
另一方面,字符串連接是用||
執行的。 運算符如
N'This is the first substring' || N' and here''s the secönd substring'
會產生
This is the first substring and here's the secönd substring
通常要存儲報價,您只需將它們加倍:
declare @string nvarchar(50)
set @string=N'I dön''t anymõre'
print @string
編輯-您不是 state 一個特定的平台,但是我假設 SQLServer,雙引號適用於大多數平台。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.