SQL Server full text indexing not fully updating since table edit - sql

Setup info:
SQL Server 2019 running on Windows Server 2019
Using SSMS to setup full text
Document table
Content column (varbinary); this contains different file types pdf, doc, txt, Excel etc....
Extension column (nvarchar)
I added a column SignTag (nvarchar) to the table and after that is when the problem started happening.
Full text indexing was running fine on our server for a while now, however once the table was edited it stopped adding as much to the catalog.
Before it was sitting around 200k results but after the edit it only shows around 86k which is causing search results to either not have results or not show all results.
Example searching for "overtime" will only bring up one file instead of the four files it used to show.
I have tried a few things:
Disable then enable FTI
Delete FTI then setting it back up (this includes the catalog file)
Clicking full populate, rebuild, and update non of which changed anything.
I am not sure why the full text suddenly stopped collecting as much as it did before the change.
SQL wise nothing has changed the only that one table edit above.
Has anyone else also run into this?

After some digging i found out the Microsoft office filter pack was uninstalled however we never noticed since the index catalog was already built from when it had the pack.
It only showed up now when adding a new column it will rebuild the FTS catalog causing the issue.
With the filter pack missing not all document types are available for FTS which is why we only got 86k instead of the 200k before. Just to name two major file type missing for us. pptx xlsx
Fix:
1: Install Microsoft Office 2010 Filter Packs (64bit for my server)
2: run this query to update sql document types.
EXEC sp_fulltext_service 'update_languages';
EXEC sp_fulltext_service 'load_os_resources', 1;
EXEC sp_fulltext_service 'restart_all_fdhosts';
3: Go to services find SQL Full-text filter daemon launcher(MSSQLSERVER) then right click restart.
4: Tell FTS catalog to rebuild.
After that you can run this query to confirm all document types are added again.
SELECT * FROM sys.fulltext_document_types

Related

MS SQL Server - Cannot Create Same Index Name on Different Tables

I am creating indexes on two separate tables in the same Database (MS SQL Server), and I got an error saying that an index already exists.
This error does NOT come up again if I changed index name to another.
Please help. Many Thanks.
Screenshot from Microsoft SQL Server Management Studio
I'd strongly suggest that the visual designer is leading you astray. IIRC, indexes used to have schema-scoped names (back in the 7.0 or 2000 era, I think. Before user/schema separation) and later gained the ability to only need to be unique at an individual table level1.
If you try to create a duplicate index manually, you receive the error:
The operation failed because an index or statistics with name '<name>' already exists on table '<table name>'.
Since that's clearly not the error you're seeing, I strongly suspect that it's old code in the visual designer and yet another reason not to use it.
1Unfortunately, we're in an area where historic documentation from the right period is no longer available from the Microsoft website. It used to be easier to verify these recollections because you could still find the "What's new in SQL Server 2000", etc pages there.

How to use Adobe iFilter 11 with MSSQL Server 2017

I'm trying to get iFilter to work, I'm running Windows 10 64-bit with MS SQL Server 2017/2016 Developer version. I've downloaded the 64-bit version of iFilter 11 from Adobe website and I followed their guide here. Even though it's for MS SQL 2008/2012 it's still pretty easy to follow.
My problem is that the full-text search doesn't return any results.
I installed iFilter 11 64-bit and added it to the system PATH. I confirmed that this is working by restarting the pc and finding the DLL from cmd.
After that, because I didn't have the FullText search component of MSSQL Server, I installed it and started the SQL Full-text Filter Daemon Launcher (I also restarted the main MSSQL Server instance).
I already had a DB and apparently FullText search are enabled by default now so I continued with the installation.
I loaded the components and verified that everything is recognized by running the following queries:
GO
PRINT FULLTEXTSERVICEPROPERTY('IsFullTextInstalled')
exec sp_fulltext_service 'load_os_resources', 1
exec sp_fulltext_service 'verify_signature', 0
/* Verify if iFilter is installed */
SELECT * FROM sys.fulltext_document_types WHERE document_type = '.pdf'
GO
/* Restart MSSQL before continuing */
/* Enable fulltext search on the database */
Use [db]
GO
EXEC sp_fulltext_database 'enable'
GO
Use [db]
DROP TABLE pdfifiltertable
GO
CREATE TABLE pdfifiltertable(
PdfID INT IDENTITY NOT NULL,
PdfFileName VARCHAR(MAX),
Ext VARCHAR(10),
PdfText VARBINARY(MAX),
CONSTRAINT PK_PdfID PRIMARY KEY (PdfID)
)
GO
CREATE FULLTEXT CATALOG pdfCatalog AS DEFAULT
GO
CREATE FULLTEXT INDEX ON pdfifiltertable([PdfText] Type column [Ext] LANGUAGE 'French'
) KEY INDEX PK_PdfID with change_tracking auto
GO
/* Check if the table correctly have a fulltext_index */
SELECT distinct
object_name(fic.[object_id]) table_name,
[name] column_name
FROM
sys.fulltext_index_columns fic
INNER JOIN sys.columns c
ON c.[object_id] = fic.[object_id]
AND c.[column_id] = fic.[column_id]
GO
/* Try to search (doesn't work) */
SELECT PdfFileName
FROM [db].[dbo].[pdfifiltertable]
WHERE CONTAINS(PdfText, 'Adobe')
With the queries I was able to:
Verify that the FullText Search component is installed
I was able to load the different filters and verify that iFilter was
being loaded.
I have also made sure that fulltext is enabled on the database even
though it is on by default.
I've created a table and a catalog and I specified the most complex
language that it will be used for (French).
After creating my table and my catalog I ran a query to verify that
the PdfText column had a text index and it did.
Following Adobe own guide, I created their sample WinForm application to upload PDFs. I uploaded 2 PDF, one in French, the other in English. I then searched for simple words that should be contained in them but no results were returned.
I have tried rebuilding the Catalog and rebuilding all index for my pdf table but it didn't change the result.
I tried Installing iFilter 9 by downloading the file PDFiFilter64installer.zip from Adobe ftp in case the newest version had any problem. Unfortunately, it doesn't work either. I have ran a profiler on the MSSQL server and no error is being thrown.
I have searched and gathered multiple related questions which helped me build my complete troubleshooting. I will link them so that they are easier to search together:
SQL Server : full-text pdf search results using contains and ifilters - Not answered
Using full-text search with PDF files in SQL Server 2008 - No working answer for MSSQL 2017.
Using full-text search with PDF files in SQL Server 2005 - Not working for MSSQL 2017 either.
I'm thinking that maybe iFilter just doesn't work on newer OS and newer version of MSSQL.
Try to use iFilter 9 - ftp://ftp.adobe.com/pub/adobe/acrobat/win/9.x/PDFiFilter64installer.zip and install it to a short path (C:\iFilter works for me).
I got it working on SQL Server 2019
Following these tips
https://dba-presents.com/index.php/databases/sql-server/48-full-text-search-with-pdf-documents-in-sql-server-2014
using a newer URL to the iFilter:
https://supportdownloads.adobe.com/thankyou.jsp?ftpID=5542&fileID=5550
I used the short name version of my iFilter path (i.e. c:\SQLSer~1\IFilter)
I had a little challenge getting the SQL Server account to access the IFilter\bin directory but used this
https://www.thewindowsclub.com/fix-failed-to-enumerate-objects-in-the-container
to help me get that straight.
I restarted my computer after I did all the steps (because not doing so didn't work for me)
and now it works for me. Hope this is useful to someone else.

What is the correct SQL syntax for this SQL statement

I am using a Content Management system (DotNetNuke) that has a MS SQL backend. The logfiles for the CMS system (not SQL Server) have become enormous so I wish to delete them.
I'm trying to execute a Truncate statement, but apparently the LogFile table is joined to three other tables.
A fellow in the community wrote a SQL script that takes all of this into consideration. The instrtuction call for:
Install by running as script from SQL item in Host menu inside DNN or
run in
SQL Server Management Studio, after replacing placeholders {databaseOwner} and {objectQualifier} by its proper values from
web.config file.
In the case of objectQualifier I checked web.config and it is:
objectQualifier=""
So my question in the following statement do I replace everything in the brackets AND delete the brackets as well with ""
Here is one of the many lines where I must replace this information:
IF EXISTS (SELECT * FROM sys.sysobjects WHERE id = object_id(N'{databaseOwner}[{objectQualifier}sys_currentDNNVersion]') AND Type = N'FN')
DROP FUNCTION {databaseOwner}[{objectQualifier}sys_currentDNNVersion]
GO
I must do the same for {databaseOwner}
I assume that you are referring to the EventLog. In recent versions of DNN it has been organized into 3 tables, not the single table of prior versions.
Look here: http://www.dnnsoftware.com/community-blog/cid/155180/howto-truncate-your-eventlog-in-dnn-740
You can also configure the Event Log so that you don't save everything.
If you are referring to other tables, what are they?
To add to the answer of Joe Craig. Before DNN 7.4 you could do this
TRUNCATE TABLE sitelog;
TRUNCATE TABLE schedulehistory;
TRUNCATE TABLE eventlog;
However they added 2 more columns to the EventLog with Foreign Keys so you cannot truncate it anymore.
Download a script here (not mine). It will remove the constraints, truncate the tables and re-add the constraints again.

Linking a SQL Server table to a text file without SSIS

I want to link a SQL Server table to a text file so that any changes made to the text file, such as creating, deleting, or updating a row, are reflected in the SQL Server table.
The best way to do this appears to be SSIS, but I know that this is only for certain versions of SQL Server. I don't appear to have one of these versions, and this is not likely to change anytime soon.
Is it possible to achieve this result without SSIS?
Update: I am working with SQL Server 2016 Express.
Example of text file:
ITEM NUMBER ;LINE ;LOCATION
1234432 ;SHIPPING ;505R13201C

SQL Server 2008 R2 Data Export Problems

I am trying to export data from my production DB to my development DB but I am getting this error:
Messages Error 0xc0202049: Data Flow Task 1: Failure inserting into the
read-only column "id". (SQL Server Import and Export Wizard)
Is there a way to check which column is that because I have 20 tables that all of them use the column name id or at least get a better error report?
Just click on Edit mappings when you choose tables to import from and to. and check on the Enable identity insert checkbox. And you should do that for each choosen table. Then you can complete your import. It was helped me in the same situation.
If the column ID is an identity column, it's likely set up to generate automatically when a row is inserted, and is not able to be directly written to.
To preserve linking from the production environment to the test, use:
SET Identity_Insert <TableName> ON
To allow you to write identity values.
All I had to do was:
Right-click on the column (in this case 'ID')
Select Modify
Inside the Column Properties scroll down until you see Identity Specification
Expand the view and select NO from the drop down menu.
If anyone knows a different (faster) way of doing this please share
Sounds to me as though you might be trying to insert values into a column that has been declared as an IDENTITY field.
Well, the answer is a bit late but I'm posting it anyway for the sake of providing to community.
I assume that you are trying to copy tables (not partial data). My answer is based on this assumption.
Connect to the source db via Object Explorer in SSMS.
Right click the db that you want its tables to be copied.
Go to 'Tasks' --> 'Export'.
Choose your source and destination server and if you don't want additional script to be run before hands just press next ('Copy data from one or more tables or views'). Now you may select tables you want to be copied to the destination.
Select tables that you want to be completely copied to the destination. And click on 'edit mappings'. Here you may 'enable identity insert'. You will also have other options so check the screen before pressing OK.
If you do not use an express edition of SSMS here you may create an SSIS package to create jobs and to automatize this process in the future. You may check 'run immediately' and follow the screen about how it goes with all the warnings and errors. Hopefully you will get none. Good luck!
Tested with:
(
Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (Intel X86)
Jun 17 2011 00:57:23
Copyright (c) Microsoft Corporation
Enterprise Edition on Windows NT 5.2 <X86> (Build 3790: Service Pack 2)
)