I have a field in a SQL table that looks like this. It’s literally a file name. I’d need to create 3 new fields and split the string shown above into this. How can I do that? I have this basic SQL that does the select and parsing, but I’m not sure how to do the insert into. I am
Tag: sql-server
SQL how to do a LIKE search on each value of a declared variable
I have a query where I am trying to do a LIKE search on each value of a declared variable, instead of doing a like search on the entire field value/string. Example: The record I am looking for is “John and Jane Smith”. The query above returns NO result. If the user searches just ‘John’…
How to use expression as LAG() second parameter on MySQL 8 (like MSSQL)?
I am trying to migrate this SQL SERVER query: dbfiddle link To MySQL 8 (same query): dbfiddle link Unfortunately I got this error: 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 ‘*(SELECT MIN(sales) FROM product_sales…
Compare two tables for a matching value from the respective columns and identify records missing
I have two tables and data like below: I want to compare two table’s columns “Type and MatchType” and identify the Ids of first table where Type is missing in MatchType. “Type” and “MatchType” are …
Convert character string into this specific date format?
I am using SQL Server 2014 and I have a table (t1) which contain a column (ReviewDate) in the nvarchar format. An example of a row of this column is given below: I need to extract the “date” component from this character string. To do this, my T-SQL is as follows: This gives me “Oct 2017R…
While loop SQL Server
Help me please. I need to write two functions, one that calculates the factorial and another that calculates the sums of euler. To make the euler sums I need to use the function that calculates the factory. I already have the function of factorial but when doing the sums the result I get “NULL” No…
Copying Data from one SQL Server Database to Another SQL Database on a Daily basis
I am trying to figure out what would be the best way to copy SQL database views from one database to another. Both databases are hosted on two different servers, so will require firewall access between them. I will need to send the views of the data on a daily basis to the required database. Copy table to a d…
Get the highest category while performing other type of aggregates
Story: I am trying to get the sum of records and the max date by country and games and another column that would rank the top countries based on the sum of records: It is the country rank column that is giving me trouble. Here’s what I tried: All it does is rank the each row partition by country which
Multiple WHEN in CASE only applies first two
I have a CASE with 4 WHENs. The first two applie fine, but the last two (or any others I add past that) do not get applied. All WHENs are referring to the same field. Here’s what I’m trying to do. The field in question is formatted as: So it would look like The first Case I wrote was to
Window functions + self join to solve?
I want to display how many days an item was in each stage. We have many items, so just showing one ID for now for simplicity. For first stage it should be action_date -created time. For last stage it …