我的表格包含
Id(int) name(nvarchar(300)) path(nvarchar(3000))
--------------------------------------------------------------
8 Subunit1_1 વસૂલાત/SubUnit/!@#$%^&*()_+{}|:"<>?,.;'[]\-=
我的查询:
select * from tbl1 where Path = 'વસૂલાત/SubUnit/!@#$%^&*()_+{}|:"<>?,.;''[]\-='
我正在使用Table.backslash和单引号。
答案 0 :(得分:1)
在搜索字符串中使用N
前缀,如下所示......
select * from tbl1
where Path = N'વસૂલાત/SubUnit/!@#$%^&*()_+{}|:"<>?,.;''[]\-='
因为你的字符串中有这些unicode字符,你需要通过在N
前面添加前缀来明确告诉sql server该字符串可能包含一些unicode字符。
在sql server中插入,更新unicode数据时也是如此。
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