SQL中不支持转义序列
我的桌子上有SQL中不支持转义序列,sql,sql-server,sql-server-2008,sql-server-2008-r2,Sql,Sql Server,Sql Server 2008,Sql Server 2008 R2,我的桌子上有 Id(int) name(nvarchar(300)) path(nvarchar(3000)) -------------------------------------------------------------- 8 Subunit1_1 વસૂલાત/SubUnit/!@#$%^&*()_+{}|:"<>?,.;'[]\-= 我的问题是: select * from tbl1 whe
Id(int) name(nvarchar(300)) path(nvarchar(3000))
--------------------------------------------------------------
8 Subunit1_1 વસૂલાત/SubUnit/!@#$%^&*()_+{}|:"<>?,.;'[]\-=
我的问题是:
select * from tbl1 where Path = 'વસૂલાત/SubUnit/!@#$%^&*()_+{}|:"<>?,.;''[]\-='
我得到的表是空的。使用了反斜杠和单引号。在搜索字符串中使用N前缀,类似这样的
select * from tbl1
where Path = N'વસૂલાત/SubUnit/!@#$%^&*()_+{}|:"<>?,.;''[]\-='
你好,M.阿里,我正在使用存储过程,我无法给出N WHERE did=@DomainId和OrgUnitPath=N+@OrgUnitPath->获取错误无效列名现在你问的是另一个问题。对于存储过程参数,只需确保您的参数是适当的数据类型,即NVARCHAR、NCHAR,这将允许unicode数据存储在其中。你好,阿里先生,我的存储过程参数已经在nvarchar数据类型中了。在你的问题中发布你的存储过程定义。看一看,我已经更新了你的过程,里面有很多不必要的东西。我已经把它清理了一点。对于这个简单的select语句,您根本不需要临时表,也不需要它是NVARCHARMAX。我已经做了一些更改,现在应该可以工作了。
CREATE PROCEDURE [dbo].[spSCS_ManageOrgunits]
@DomainId int,
@orgunitpath nvarchar(3000),
@iDisplayStart int,
@iDisplayLength int
AS
BEGIN
SET NOCOUNT ON;
IF @orgunitpath = ''
BEGIN
SELECT a.[row],a.OrgUnitId,a.did,a.OrgUnitName,a.OrgUnitPath,a.ScheduledStatus,a.AutoSyncStatus
FROM
(
SELECT ROW_NUMBER() OVER (ORDER BY OrgUnit_tbl.OrgUnitId) AS row,OrgUnitId,did,OrgUnitName,OrgUnitPath,ScheduledStatus,AutoSyncStatus
FROM OrgUnit_tbl
WHERE did = @DomainId AND OrgUnitPath = @orgunitpath
) AS a
WHERE a.[row] >= @iDisplayStart AND a.[row] < @iDisplayStart+@iDisplayLength
END
ELSE
BEGIN
SELECT OrgUnitId,did,OrgUnitName,OrgUnitPath,ScheduledStatus,AutoSyncStatus
FROM OrgUnit_tbl
WHERE did = @DomainId AND OrgUnitPath = @orgunitpath
END
END