My company business hour is 7:30 to 18 and 13:00 to 15:00 is lunch time. Important part is about lunch time that should not calculate as working time of employee at all. So imagine employee start working at 8:30 and exit at 15:00 so the time of 4:30 hours should be calculate for him. actually I want to remove lunch
Tag: sql-server-2017
Get the immediate parent child relation in a table
I have a table with following value I need the output data from the above in the following format : Thanks in advance for any guidance on this. EDIT : I used the while loop approach to achieve this but trying to avoid the while loop. The while loop logic worked if proper sequence of ranklvl is there for a
How to split a sentence and get only left 15 or less (Not greater than 15) characters on one column but at the end it could be a complete word
How to split a sentence and get only left 15 or less (Not greater than 15) characters on one column but it could be a complete word. Example: Ali, House Number ABC/123, Sattelite Town, Lahore. Need support here. Answer You can try something like this:
SQL Server – Ordering Combined Number Strings Prior To Column Insert
I have 2 string columns (thousands of rows) with ordered numbers in each string (there can be zero to ten numbers in each string). Example: The end result is to combine these 2 columns, sort the numbers in ascending order and then put each number into individual columns (smallest, 2nd smallest etc). e.g. Colstring1 is 1;3;5;12; and ColString2 is 4;6;
SQL Calculate Consecutive hours [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question Need to calculate consecutive hours. Here is the data This the client has a limit of the amount of consecutive hours allowed. Here is the
Function to convert units based on conversion table
There is a very simple table in the database with metric unit conversions, that looks like: I was thinking about creating a function to convert units that calculates the conversion from the table based on inputs (Unit, FromUnit, ToUnit). For example Conv_Units(0.1, ‘m’, ‘cm’) returns 100. Is this even possible? What I came up with is following, but it does
Finding cumulative sum using SQL Server with ORDER BY
Trying to calculate a cumulative sum up to a given number. Need to order by 2 columns : Delivery, Date. Query: Results: Expected results: Version: Microsoft SQL Server 2017 Answer You need a third column in the ORDER BY clause to break the ties on Contract_Date and Delivery. It is not obvious which one you would use. Here is one
How to get the actual script of a stored procedure in another server?
I use SQL Server 2017. I have linked a serverdatabase to another my main database. So, if I execute the query below, it works and brings me the correct data: What I want to do is to get the actual script of a stored procedure from the linked database. Assume I have the stored procedure: sp_GetNumbers, then I can receive
Can I use string_split with enforcing combination of labels?
So I have the following table: Id Name Label ————————————— 1 FirstTicket bike|motorbike 2 SecondTicket bike 3 ThirdTicket e-bike|…
(SQL Server 2017) I get error Msg 8152 and I don’t know why
I have no idea why, but I am getting the error Msg 8152 (in SQL Server 2017) after trying to insert something like into the table The output I get is Msg 8152, Level 16, State 14, Line 1 String or binary data would be truncated. Thanks in advance for your help! Answer You need to define a length for