It only gets one value back is it possible to get multiple values inside? Like get test, test1 and test2. Answer Looking at each of the three fully visible example rows: ID=25 No match, because IsDeleted is 1 ID=26 Match. This is the row you see in the results. ID=27 NO MATCH, because Contains() matches full words by default. This
Tag: sql-server
Joining two tables where keys from one table is missing
I am not sure what type of join I need to obtain my desired result. As per the below example I am trying to join table 1 to table 2 but I am missing Q3 in the first table. table 1: Quarter Sales Q1 100 Q2 200 Q4 300 table 2: Quarter Cost Q1 20 Q2 50 Q3 70 Q4
Converting recursive CTE from Postgre SQL to SQL Server
I am having trouble adapting some recursive CTE code from PostgreSQL to SQL Server. Here is my table: and what I am trying to adapt: I have been having issues adapting the use of ARRAYs. Any pointers would be really helpful! Answer Much more quicker will be : Tested with 100003 rows, the results are : Charlieface Query 1 :
Understanding How to Parse SQL Solution
I am working on the HackerRank Top Earners problem. The problem states the following: We define an employee’s total earnings to be their monthly salary x months worked, and the maximum total earnings to be the maximum total earnings for any employee in the Employee table. Write a query to find the maximum total earnings for all employees as well
Why am I getting an error when using the REPLACE function with a WHERE clause?
I am using SQL Server and SSMS. I have the following code: But I get the following error: Msg 174, Level 15, State 1, Line 2 The replace function requires 3 argument(s). I’d like to change G1 to G2 and C11 to C33. This is a small sample of a much larger code I’d like to build replacing many other
How can I generate an ID column for a column in SQL? [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 months ago. Improve this question I have a column that I’d like to generate an ID column for. How can I do this using SQL?.
Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword ‘as’ , whats wrong? [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 6 months ago. Improve this question
get dates periods
it is necessary to get the date periods. input data: expected result: Answer This is a gaps and islands problem. One trick we can use here is to create a pseudo-group which tracks to which island of continuous dates each record belongs. Demo In the first CTE above, the alias cnt gets assigned to a value of 1 whenever the
Simplify SQL query with string as array parameters
I’m trying to find a way to simplify my stored procedure. When I try to query using single parameter it went well but when using array, the retrieval process took so long. Any idea how will I simplify this? Someone suggested to me to put StringAsArray into temp table but I don’t know exactly what they’re trying to suggest. Any
Insert Data By Splitting Column into Different Rows in SQL
I have a temporary table Temporary Table Image ID Code Type 1 A001 A, B 2 B001 A, B 3 C001 A, B & a source table in my database Source Table Image ID Code Text 1 A001 Text A 2 B001 Text B 3 C001 Text C I want to insert the the ‘type’ data to have output like