arun
arun

Reputation: 319

ESCAPE SEQUENCE NOT SUPPORT IN SQL

My Table Contains

Id(int)  name(nvarchar(300))         path(nvarchar(3000))
--------------------------------------------------------------
8        Subunit1_1                  વસૂલાત/SubUnit/!@#$%^&*()_+{}|:"<>?,.;'[]\-=

my Query:

select * from tbl1 where Path = 'વસૂલાત/SubUnit/!@#$%^&*()_+{}|:"<>?,.;''[]\-='

I am Getting Empty Table.backslash and single quotes are used.

Upvotes: 0

Views: 87

Answers (1)

M.Ali
M.Ali

Reputation: 69524

Use N prefix in your search string something like this...

select * from tbl1 
where Path = N'વસૂલાત/SubUnit/!@#$%^&*()_+{}|:"<>?,.;''[]\-='

Because you have these unicode characters in your strings, you need to tell sql server explicitly that string may contain some unicode character by prefixing it with N.

Same is true when you are inserting, updating unicode data in sql server.

Your Updated Stored Procedure

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

Upvotes: 1

Related Questions