I have a column with multiple line data. It shows as one line in SQL Server but multiple lines in Power BI so I guess there are some special characters in there to tell Power BI where the new line starts. What I want to achieve is to search the second to the last line instead the whole cell, to
Tag: sql-server
How can I select multiple columns while setting one of them as DISTINCT
I have 6 columns and I want to select data from them while fixing one column as distinct the Display should be the following: Answer Using ROW_NUMBER and TOP: But this assumes that the second and third column are part of what defines a “group” in your expected result set. If instead only Column1 d…
SQL separate for stored procedure
About SQL Server Management Studio stored procedure. The following variables ‘|’ I want to separate it from. How can I do it? ‘628391|28100|8304|3|1201129|12|Kg|M01|SERIOUSLY CHUNKY WOOL’ ‘627452|…
Update table data, fetched from another table
I have a table which is storing the attendance information on an employee and another table that’s storing the information about the shift of the employee which is basically a duty roster. Here is …
SQL Select row with max value in one column
I have the following query SELECT Dnumber, SUM(WORKS_ON.Hours) AS sum_hours FROM DEPARTMENT JOIN PROJECT ON DEPARTMENT.Dnumber = PROJECT.Dnum JOIN WORKS_ON ON PROJECT.Pnumber = WORKS_ON.Pno …
SQL Count Number Of Classmates For a Student Across All Courses
I have the following tables: Student: Student_ID (PK), Student_Name Course: Course_ID (PK), Course_Name Enrollment: Student_ID (FK), Course_ID (FK) I need 2 queries: A query that computes for each student id in the Student table the total number of different (Unique) classmates that this student has across al…
Provide the values for a ‘like’ function from a specific column in a Table?
I am using SQL Server 2014 and I need a T-SQL query which uses the like function to run on a specific column (c1) of a Table (t1) to find out if it contains one of the codes from a list of codes found …
How to SUM columns in the same row?
I have a table like below: id pymt_no1 pymt_no2 pymt_no3 pymt_no4 pymt_amt1 pymt_amt2 pymt_amt3 pymt_amt4 25 100 5 150 50 …
Reverse order of every other character in a string
I’m currently working on a project where the data I’m receiving is being given to me in a messed up order. I need every 2 characters to switch places in a string. Currently I have the below code, but it is ungodly slow in a function or stored procedure. Any help would be appreciated. Ex: FK741 OCE…
I need a Row_number over partition to achieve this in SQL Server
I have three columns PID, AppNo and ProcessedDate I need a query to update the AppNo in the format below PID AppNo ProcessedDate 11 1 09/30/2019 18:21 3 1 09/25/2019 08:37 3 2 …