Let’s say I have two tables (1 to many): table company with fk id and table product with fk id and also fields sId and tId (if sId has data tId is null and vice versa, not sure if it matters). I want …
Tag: sql-server
How should I insert video in SQL Server with column of description?
I have tables with two columns: Video and desc. I want to insert video in SQL Table. I use next script: INSERT INTO table(Video) SELECT ( SELECT BulkColumn FROM OPENROWSET(BULK ‘sourcevideo.mp4’, …
How to use a function remove multiple possible prefixes from a Name string in SQL Server
I need to correct Names of users by removing prefixes for a report. I need to use a function here since there is an elaborate case logic in the report. I want to pass a first name with prefix and get …
sql extract multiple words from one cell
I have a column that has some text written in it, including serial numbers. What I want to do is to extract the serial numbers , when they exists. I managed to extract only the first one. This works great if there is only one SN in it, otherwise the rest are not shown. For example I have this: I
Returning the column value even if the special character isn’t present using SUBSTRING & CHARINDEX
I’m using SQL and trying to show all the data in a column before a special character like <. I've used this SQL: SUBSTRING(ACTIVITY.Name, 0, CHARINDEX('<', ACTIVITY.Name, 2)) AS …
Retrieving the latest result in sql
I have written sql query that is pulling agreements data. I need to pull the latest agreement. The latest version is determined based on the most recent version. As you can see currently my query is …
Select distinct values from table and put them in string
I have the following tables: SELECT g.[Id], –br.name –por.id FROM [Game] AS g INNER JOIN [GameAvailability] AS ga ON ga.[GameId] = g.[Id] INNER JOIN [Portal] AS por ON por.Id = ga….
SQL to get whole words till end from the keyword
Consider I have text from the field (notes) as below: I want a SQL query which fetches the link part only. That is to find keyword http and print till the last. Output: Also if the text field doesnt have any link, can we print NA? Answer For SQL Server you can consider this below logic- For MySQL- In case
Calculate time from begin date in SQL
I’m trying to tally up the number of unique ID accounts that are active for more than a year as well as include how long each one is active. The problem with the code I have is it’s not including …
Convert specific MS Access query to SQL Server query
I have MS Access query and try to convert to SQL Server query. Please someone can help me. UPDATE AppReferrals SET AppReferrals.DeviceID = CLng(Val(Left(IIf([AppReferrals].[DeviceID] Like ‘0’,[…