I have a table which has 3 columns:
ProblemID
FileContent
FileName
I want to search for a user specified string from the fileContent column. Is it possible to convert binary data in VARCHAR? I tried it but it gives results in different format.
i am storing .pdf files only
You can't search real binary data in SQL Server if the binary format is Word or Excel or anything except a raw text file
Related
I've stored an image in varbinary type in SQL Server.
Here's an example of data:
0x89504E470D0A1A0A0000000D49484452000005E7000002DB0802000000FFE6ACCA00000001735247420 (and much more characters after)
Originally, it's filename is : test.jpg
I'd like to retrieve "test.jpg" by a stored procedure in SQL Server instead of this long and terrifying string. Is it possible?
No. A file's name is typically only stored in the filesystem; not in the contents of the file. So unless you stored the filename in a separate column, you can't retrieve it with TSQL.
I want to get file type from binary data in a column File_Stream in FileTable.
In FileTable, there is File_Type column but it's not reliable.
Pay attention to the following queries:
These files are the same!
The file_type column value is derived from the file name, not the binary contents of the file. SQL Server has no notion of what the actual binary contents represent.
One of the column is having clob data in DB and I want to validate whether a particular text is present in that clob data but i am not able to achieve it through sql query, as the formats differs . Is there any specific sql query to covert clob data to string?
I am using csvkit (specifically, the csvsql tool) to load a tab delimited file to an mssql db.
Numeric fields are processed correctly, while all the text (varchar) fields are loaded to the DB as a single character (their first one).
The column type according to csvstat -c is 'unicode'. In the DB, I tried loading to a varchar and nvarchar field. Both showed the same phenomenon of loading just a single character.
I suspect it is related to csvkit or the file's encoding, because when I write a manual sql INSERT statement the value ends up in the DB correctly.
How can I fix it to load the field correctly?
I have my Database running on a SQL Server 2012. One Column of my Table contains RTF Text. The Datatype of the Column is nvarchar(MAX).
I want setup a full text search for this column which analyses the rtf and searches only in the real text, so that I don't get rtf Tags as result.
As I understand, parsing rtf should already be part of the SQL Server. But I don't get it working :-(
I did following:
Create a full text catalog
Select the column containing rtf and add a full_text Index
But I still get wrong results
SELECT * FROM myTable WHERE
CONTAINS(myRtfColumn,'rtf')
--> still get all columns, as 'rtf' is a keyword
Any Ideas what I doing wrong? Do I have to activate rtf-Search for my SQL Server or something similar?
A full text search works only on text columns. You are inserting into your database binary stuff -> rtf. When you have chosen nvarchar you told the sql server you want to store text, but you are storing binary stuff. For binary stuff use varbinary(max) instead.
The problem will still remain, because the index routines don't know how to interpret richtext - what are control chars what is content.
let us talk about the interpreter/filter
documentation says:
https://technet.microsoft.com/en-us/en-en/library/ms142531(v=SQL.105).aspx
varbinary(max) or varbinary data
A single varbinary(max) or varbinary column can store many types of documents. SQL Server 2008 supports any document type for which a filter is installed and available in the operative system. The document type of each document is identified by the file extension of the document. For example, for a .doc file extension, full-text search uses the filter that supports Microsoft Word documents. For a list of available document types, query the sys.fulltext_document_types catalog view.
Note that the Full-Text Engine can leverage existing filters that are installed in the operating system. Before you can use operating-system filters, word breakers, and stemmers, you must load them in the server instance, as follows:
Finally todo:
check if ".rtf" is as filter available.
EXEC sp_help_fulltext_system_components 'filter';
then add a calculated column to you table "typ" which always returns ".rtf"
alter table yourname add [Typ] AS (CONVERT([nvarchar](8),'.rtf',0));
This can used now for the index as type specification.