I have a employee table and I am trying to get only comma values in SQL Server. Emp table: Eid Ename 1 Peter,J 2 Mike,S 3 , 4 ,,,,,, I tried this code: I am not getting the length 0 if the values contain only commas. Expected result: I want only 3 and 4 emp ids. Answer The answer there
Tag: sql-server
Add geometry column from exisiting x,y,z columns
I have a table as such: All columns are Decimal(18, 3), there are also millions of rows. I would like to add a fourth column to be a geometry point. I have tried but to no avail: Driving me insane! Cheers Answer As mentioned by @lptr in the comments, you can use STPointFromText db<>fiddle
sql update – access to the current row
I would like update the column [ACIdent] from the table [Values]. With the subquery i try to get an ID from the same table. On the point ??? i try to access to the column [PathName] of the respective row of the update script. But this solution doesn’t work. How can i do this? Many thanks in advance! Ans…
How to select unique records from a 5 column table where the values can be the same but in different orders
I used 1 table to do a cross join 4 times giving me 5 columns of data. I used the same column in all 4 cross joins to get every combination. The only problem is I get the same data it is in a different order. I am trying to only get records that are unique. I can only have
Base on SQL column content insert the data into another table
I have below table name: CustomerContent with the below image data and My product is:is common in ProductContent cell. First colon no need to split (My product is:) if next colons we need to split the ProductContent Cell base text assign the values like below. If slip data content CGM then assign value 37. my…
Using one query’s result into another
I have this query which shows the below result, I want to use this MarksObtained and take out min, max and avg of each course and show it with the second query (have provided below). This is the second query So it will basically show min, max and avg of each course achieved by the students. What I want: Sampl…
SQL Server – Retrieve list of month dates between two columns
I want to add a new column that should contain months between startdate & enddate present in two separate columns. My current data looks something like this : Case Name StartDate EndDate 1 ABC 2021-01-15 2021-03-15 2 DEF 2021-03-15 2021-05-15 My desired output is : Case Name StartDate EndDate MonthList 1 …
How to make a composite key out of two foreign keys
I have three tables: In Table 1 primary key is pizza and in Table 2 ingredient. In Table 3, pizza and ingredient are foreign keys, that reference Table 1 and Table 2 respectively, and i want to make them into a composite key. Here’s what i tried: But i’m not sure whether it’s a correct imple…
Sum values in two different tables and join results keeping the columns
I have two tables: one with downtime and the other with productive time. I want to have a table like this But I am getting this In the result, I am getting twice the downtime of the sum for the report 04102021-1, but as can be seen in the second picture, the value is present only once. The script I
Suggested way to do a ‘parallel period’ SQL statement
Let’s say I want to get the profit between two dates. Then I can do something like this: I would then like to compare it to a previous period offset by a fixed amount. It could be written something like this to get it in two rows: Is there a way to do this without a union? I am looking