I’m using SQL to create a database VIEW from the table below. ItemCode |BcdName |BcdCode | ————————|——————|————-| 03616006.ERA …
Tag: sql-server
SQL Server Select Query With Join/Sub Query On Same Table To Create A Master Field Value
This is a weird query, and I’m not sure if what I want to do is even possible (Efficiently anyway) as it’s a bit of a weird situation. Let’s say I have the following data called ProductTable. They …
How to search for separated values in cloumns from a merged values column
I have a database where the data I need to work with is stored into two different columns. I also need to import an excel file and the data in this excel file is all together only separated by a dash. …
Select Specific Column from a Linked Server Table
I have the following C# code to select a column from a table that is on a linked server: var query2 = $@”select [FileName] from [AMS_H2H].[H2H].[dbo].[FileReconciliation] where ProductCode = @…
Query to fetch in-out time for all employees from one table
I need to find first in and last out time for all employees from a table. I have tried the following query. This query return the records for a particular employee. But I have to find the data for all employees. Sample Table data: Answer you can use this.
How can I concat 2 different numbers to look like a decimal but is actually a varchar without losing place in the decimal portion?
I’m trying to calculate Hours and Minutes, but the minutes portion is dropping the leading 0 and it appears the calculation is incorrect. Example, 9.06 is displaying as 9.6 using this query against the values ClockIn 2020-01-07 23:00:53.000 ClockOut 2020-01-08 07:06:52.000 This results in a calculated t…
How restart the incremenal from a temp table in SQL
I want to try to do an incremental number for a table, that has to return to 0 when seeing from the previous column (LAG) 0. This is what I tried to do: And this is what I am expecting to get out: I’m not familiar with the WITH common_table_expression is the right way to solve my problem? Answer You
Conversion failed when converting the varchar value ‘U’ to data type int
I’m getting an “error converting varchar to int” for fields Q1_c and Q2_c. Those fields are CHAR(1) and the values for those fields are either 1,2,3,4,5, or U, but it will not convert when there is a U, so I am trying to change the value of U to something else like 0. I have also tried CAST(…
Append time from table to getdate() while using case
I am trying to append time from a column to a date and use in a case statment getdate() at time zone ‘Central Standard Time’ this is what i’ve tried so far datatype of endtime column is nvarchar and the format of the time is 21:00 and this is the error that i am getting Incorrect syntax near…
How to get conditional SUM?
I am trying to get a conditional sum based on another column. For example, suppose I have this dataset: If there is a type of 1 then I only want that data for that data, else if there is only 0 then I want that data for that date. So for 12/16/2019 I would want the value 0. For 12/23/2019