How to find a text from database column in a table? - sql

I have a database in SQL Server in which there is a table with a single column URL that contains URL.
I have 1000 rows (supposed).
Now I need to find that which URL contains the text that I will tell.
Example :
Sr. URL
1 http://example.com
2 http://example2.com
If I have these kind of data and I need to find that which row contains example2 or simply 2 then I should give me the specific row(s).

select id from table where URL like ('%example%');

Related

Turning rows from sql table into headers in Pentaho

I have a SQL table that return name and I would like to take that result and turn into headers (csv file)
for example: select name from TBL give me
name
Client Name
Phone Number
City
Is it possible to turn those return rows and convert into a header? I have try to find something but had no luck. The reason for this is to make the header dynamic.

Replace all URLs in SQL Server table column which contains html data

I have a SQL Server table column which contains html contents with links in format href="/page/random_id1/random_id2".
Here random_id1 is a guid and random_id2 is a slug. Now i would like to run a sql query which can replace all href values by converting them to href="/page/random_id2".
Notice here, i'm removing random_id1 part from every herf.
Here's a sample query:
select top 1 id, htmlcode from tenantpage;
03781776-5f64-4c59-a6f7-5873e0b9f128
<div>test</div>Link<div>something else <span>test Link</span></div>Link
I don't know if this is possible, if possible please help here.

split string with specific character

Here is my situation
there is a column that comes from csv file, i loaded all fields properly in sql but in email column, i have more than 1 email address for some records.
if it would be 2 emails, i could handle but as long as i have 3-4 or more emails, then i have little problem.
here is an example
'ekuntsche#addictionsuisse.ch;ekuntsche#suchtschweiz.ch;ekuntsche#sfa-ispa.ch;ekuntsche#addiction-info.ch'
this is only 1 column, i need to split them to 4 different column as email1,email2,email3,email4 and delimiter is ';'
I think i should use charindex and substring etc. but i could not create it.
if someone can create a function and show how to run the function, that would be super helpful.
thank you
database name 'bi_deploy'
main column name is 'email'
unique id for this table is 'ID'
(this is only email table, every row will have 1 email address, i can make it actually, but i could not split emails properly)

Find out if a value exists in a column with a large input values set

What is the most effective (and simple) way to find out if a specific column cells of a table contain one of a given values?
To give you some background, I have a list of 1000 ID numbers. They might or might not exist in a "FileName" column of a table "ProcessedFiles" as a part of the filename.
Basically, I need to check which of these 1000 tasks have been processed (i.e. they exist in the table).
The thing that I came with seems very uneffective:
SELECT * FROM ProcessedFiles
WHERE FileName LIKE '%54332423%'
OR FileName LIKE '%234432%'
OR FileName LIKE '%342342%'
...
etc
Thanks for help!
You could create a temporary table and insert all the Ids in a column. Then you could cross join with the ProcessedFiles table and check for the id in the name with a like:
SELECT pf.*
FROM ProcessedFiles pf,table t
WHERE pf.FileName like '%'+t.Id+'%'
I tested the above and it worked on SQL Server.

Google Fusion queries: using wildcard for LOCATION parameter

I am querying a Google Fusion table as follows:
SELECT * FROM {mytableIDhere} WHERE col1 LIKE '%{mystringhere}%'
This shows all row data for entries containing {mystringhere} in column 1. Is it possible to use a * wildcard on the column field, so that the search applies to ANY column? I tried that, but I get a parse error when doing:
SELECT * FROM {mytableIDhere} WHERE * LIKE '%{mystringhere}%'
It seems that the location parameter cannot be open-ended. Is this correct? If so, is there a workaround?
EDIT: In terms of desired functionality, I am trying to create a global search of a table so that any rows containing the search query will be returned. The columns include e-mail addresses, ID numbers, commentary, and other values.