Author |
Topic |
JohnSourcer
Starting Member
9 Posts |
Posted - 2013-07-02 : 07:56:16
|
Hi Guru's,I have the following SQL:SELECT Customers.CustomerId, Customers.Firstname, Customers.Surname FROM Customers INNER JOIN DealershipCustomers ON Customers.CustomerId = DealershipCustomers.CustomerId INNER JOIN Dealerships ON DealershipCustomers.DealershipId = Dealerships.DealershipId INNER JOIN CONTAINSTABLE(Customers, *, @Term) AS K ON Customers.CustomerId = K.[KEY] I now want to pass a wildcard to @Term which works fine as say 'Joh*' but won't work when the term is 'John*' where 'John' is an exact match. How do you get around this limitation? |
|
JohnSourcer
Starting Member
9 Posts |
Posted - 2013-07-03 : 03:01:42
|
Can this not be done? Seems a bit strange. Otherwise I'll have to pull out FT search altogether. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-07-03 : 03:07:10
|
do you mean this?SET @Tearm='"John*"'SELECT Customers.CustomerId, Customers.Firstname, Customers.Surname FROM Customers INNER JOIN DealershipCustomers ON Customers.CustomerId = DealershipCustomers.CustomerId INNER JOIN Dealerships ON DealershipCustomers.DealershipId = Dealerships.DealershipId INNER JOIN CONTAINSTABLE(Customers, *, @Term) AS K ON Customers.CustomerId = K.[KEY] ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
JohnSourcer
Starting Member
9 Posts |
Posted - 2013-07-03 : 03:36:12
|
Yes, visakh.If the match is exact i.e John, SQL throws an error but: SET @Term='"Joh*"' Returns the match. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-07-03 : 03:44:34
|
quote: Originally posted by JohnSourcer Yes, visakh.If the match is exact i.e John, SQL throws an error but: SET @Term='"Joh*"' Returns the match.
Ok...------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
JohnSourcer
Starting Member
9 Posts |
Posted - 2013-07-03 : 05:11:27
|
quote: Originally posted by visakh16Ok...
Sorry Visakh16, I possibly wasn't clear on this.Here is a mockup of the issue:A test table:CREATE TABLE [dbo].[TestTable]( [ID] [int] NOT NULL, [Code] [nvarchar](12) NOT NULL, CONSTRAINT [PK_TestTable] PRIMARY KEY CLUSTERED ( [ID] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY] Add data: INSERT INTO TestTable (ID, Code) VALUES (1, 'CB55FJGP') Fulltext Index the tableRun this query:DECLARE @Term nvarchar(10)SET @Term='"CB55FJGP*"'SELECT TestTable.ID, TestTable.Code FROM TestTable INNER JOIN CONTAINSTABLE(TestTable, *, @Term) AS K ON TestTable.ID = K.[KEY] Results in:Syntax error near '"' in the full-text search condition '"CB55FJGP*'.But changing the term to '"CB55FJG*"' works fine. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-07-03 : 05:27:40
|
Ok. So I hope your issue is resolved------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
JohnSourcer
Starting Member
9 Posts |
Posted - 2013-07-03 : 05:37:04
|
quote: Originally posted by visakh16 Ok. So I hope your issue is resolved
lol No it isn't. I know you're very knowledgeable. Can you explain why this doesn't work. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|