Context: I am preparing this dataset to be used for an SSRS report, my goal is to split the list into about multiple parts (equally) for employees to receive. It will be used as a “task list” of sorts. I have tried two different ways, both of which are causing issues. Attempt #1 – Error is ‘incorrect syntax’: Attempt #2
Tag: sql-server-2008
Is it Possible to save results from a CASE Query in a Table?
Is it possible to make a case query and save it also into the table in the same query? thanks for help! Answer You need to use INSERT INTO
Looping through a column to check if a cast succeeds in SQL Server
I am trying to check if an entire column which is varchar and make sure it can be cast to float. I have a cursor portion like so: For some reason, it is always returning 1. I already in a previous part of the cursor (not shown but above), verified that the column passed in (@ColumnName) is NOT NULL at
TSQL CTE error ”Types don’t match between the anchor and the recursive part”
Would someone help me understand the details of the error below..? This is for SQL Server 2008. I did fix it myself, and found many search hits which show the same fix, but none explain WHY this happens in a CTE. Types don’t match between the anchor and the recursive part in column “txt” of recursive query “CTE”. Here is
SQL difference between cell values (LAG function not working)
Unfortunately I can’t use the lag function due to using SQL Server 2008. I need to find machine based difference between two values at different times. I have a table like that: I need to find a difference (76340-75000 = 1340) between id 1 and 3. Tried these before: but it compares with t1.id with the whole table. I can’t
Select into a temporary table efficiency is faster than direct query
Case: Query below sql need 10.56 sec, and 236 rows were queried. Estimated Execution Plan: Most cost: After I try to use select into temporary table then it just need 0.03 sec Estimated Execution Plan: Then I’ve tried add below index, but it still no change. hct_mlots table create sql,total rows 88790 mf_mo table create SQL Answer I made an
INSERT INTO SELECT AND VALUES
Error: “Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.” Answer The error is pretty clear. The outer select returns too many rows. You can just remove it: Note that the constant values are included in the select.
Getting the correct data to be stored into temp table by comparing timerange
Currently, I need to get the correct data to be inputted into temp table. There are 3 datetimes that I need to compare. However not all values are populated. Example-Assume that all dates are the same Data1 DateTime1 DateTime2 DateTime3 First 2020-08-24 14:00:00.000 2020-08-24 14:30:00.000 2020-08-24 15:30:00.000 Second NULL 2020-08-24 13:00:00.000 2020-08-24 14:30:00.000 Third NULL NULL 2020-08-24 10:00:00.000 From the
Input selected row and ignore duplicate row
I have a problem that I need to insert a selected row from the table to another table based on last_update data or last_transaction_product. last_update is the data updated from the table, and last_transaction_product is the latest transaction from my shop, and then my row has duplicate data but has a different last_update column here, this duplicate data must not
Apply multiple count conditionally in SQL Server query
I have a task table which contains some DateTime type columns like completed, pending, exception. It joins user table and I want to bring userName, AllTaskCount, AllPendingTaskCount, …