Click here to Skip to main content
15,894,180 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dears,

I have an issue i don't understand
i have this table
SQL
CREATE TABLE [Security].[ServiceOperations]
    (
      [ServiceOperation_ID] [bigint] IDENTITY(1, 1)
                                     NOT NULL ,
      [ServiceContract_ID] [bigint] NULL ,
      [OperationName] [nvarchar](MAX) NULL ,
      [Name_Ar] [nvarchar](MAX) NULL ,
      [Name_En] [nvarchar](MAX) NULL
    )

with these data
SQL
SET IDENTITY_INSERT [Security].[ServiceOperations] ON 

GO
INSERT [Security].[ServiceOperations] ([ServiceOperation_ID], [ServiceContract_ID], [OperationName], [Name_Ar], [Name_En]) VALUES (1, 1, N'DGIT.Business.Entities.DMS.StoredFile GetFile(Int64)', N'جلب الملف من خلال رقم الملف', N'Return file from file id')
GO
INSERT [Security].[ServiceOperations] ([ServiceOperation_ID], [ServiceContract_ID], [OperationName], [Name_Ar], [Name_En]) VALUES (2, 1, N'DGIT.Business.Entities.DMS.StoredFile[] GetFiles(System.Guid)', N'جلب الملف من خلال الرقم المرجعي', N'Return file from file Guid ID')
GO
INSERT [Security].[ServiceOperations] ([ServiceOperation_ID], [ServiceContract_ID], [OperationName], [Name_Ar], [Name_En]) VALUES (3, 1, N'Boolean Delete(Int64)', N'حذف ملف من خلا رقم الملف', N'Delete file by file ID')
GO
INSERT [Security].[ServiceOperations] ([ServiceOperation_ID], [ServiceContract_ID], [OperationName], [Name_Ar], [Name_En]) VALUES (4, 1, N'Int64 CreateUpdate(DGIT.Business.Entities.DMS.StoredFile)', N'انشاء او تعديل ملف ', N'Create or Update file')
GO
INSERT [Security].[ServiceOperations] ([ServiceOperation_ID], [ServiceContract_ID], [OperationName], [Name_Ar], [Name_En]) VALUES (5, 1, N'Int64 GetCount(DGIT.Business.Entities.DMS.StoredFile)', N'جلب عدد الملفات', N'Get files count')
GO
INSERT [Security].[ServiceOperations] ([ServiceOperation_ID], [ServiceContract_ID], [OperationName], [Name_Ar], [Name_En]) VALUES (6, 0, N'[][][][]', N'', N'')
GO
SET IDENTITY_INSERT [Security].[ServiceOperations] OFF


when i query for a record using like

SQL
SELECT * FROM Security.ServiceOperations AS so WHERE OperationName LIKE 'DGIT.Business.Entities.DMS.StoredFile[] GetFiles(System.Guid)'

its not returning data cause of the '[]' but its returning using '=' operator
Posted
Comments
PIEBALDconsult 13-Feb-15 15:04pm    
You'll need to escape the [ and ] .
https://msdn.microsoft.com/en-us/library/ms179859.aspx
ZurdoDev 13-Feb-15 15:20pm    
Looks like a solution to me.
imaa2amha 14-Feb-15 2:05am    
Thanks its works out :) .

add as solution so i can make it as an answer
PIEBALDconsult 14-Feb-15 2:08am    
Nah.
imaa2amha 14-Feb-15 3:54am    
as you wish :P

Hi

The problem is that in the like operator the double square brackets are wildcards. See http://www.w3schools.com/sql/sql_wildcards.asp[^]

According to Microsoft to interpret a wildcard character as a literal you need to enclose it inside []. This would mean that in your case you should use [[]] instead of [].

Try this. It should work
 
Share this answer
 
replace [] with [[]] and it will work:
SELECT * FROM ServiceOperations AS so WHERE OperationName LIKE 'DGIT.Business.Entities.DMS.StoredFile[[]] GetFiles(System.Guid)'
 
Share this answer
 
Try this:
SQL
SELECT 
    * 
FROM Security.ServiceOperations AS so 
WHERE 
     OperationName LIKE REPLACE(REPLACE('DGIT.Business.Entities.DMS.StoredFile[] GetFiles(System.Guid)', '[', '[['),']',']]')
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900