I will explain with tables result. I have a table “emp” which consists of columns (number of employee”id_emp” ,”date” and ‘”type”): id_emp Date Type 5 2019-08-01 NULL 5 …
Tag: sql-server
SQL query to get top 1 (most recently updated)
I have two tables apps and builds apps app_guid name state created_at updated_at foundation builds guid app_guid app_name state created_at updated_at foundation One app can have multiple builds, …
Get every 2 weeks on particular days SQL Server
I have a query getting the days in particular day that I selected and show the days in a month. My problem is that I need every two weeks of the month. And I also need to get long date format: dddd, …
How can i optimize the Trigger
I have checked a lot of Question asked Previously but was not able to get how do optimize this trigger ALTER trigger [dbo].[Expample] on [dbo].[AdminUsers] for update as begin declare @Id int …
SQL Server: hidden “Sort” inserted in execution plan in left join query
SQL 2017 Standard i have a database in a star schema model (data warehouse) to fill in a fact table, i have a stored procedure with a temporary table having around 470,0000 rows. to fill in the …
How to structure this case when expression in the where clause?
I have a parameter where there are three available options, “ecom”, “nonecom”, and “both”. When the parameter is set to “ecom”, I want there to be a where clause where it says Customer_Number = ‘…
Merging Rows containing ColumnA predicated by next result(s) of ColumnA
I want the result to display the amount of instances a particular service has been booked for. If the following row has the same service then they should be summed together. Sample Data Expected …
Count decline Attempts with CURSOR in Sql Server
Hi i am stuck at this problem, i have worked a solution through CURSOR in SQL SERVER but my rows are around 400K and output is taking hours, can anyone do this faster? maybe through CROSS APPLY or …
Remove duplicates and fix foreign keys in T-SQL
I have the following tables: Foo_1 Id | Created | Dupe 1 | 2019-01-01 | ‘one’ 2 | 2019-01-03 | ‘one’ 3 | 2019-01-01 | ‘two’ 4 | 2019-01-02 | ‘one’ 5 | 2019-01-02 | ‘three’ Bar_1 Id | BarId …
Is there a way to search for a matching string with multiple variants in a column?
I have a table that contains the colum “CompanyName”. I want to get all rows that mach with a specific string. +—-+———————-+——————-+———+———+ | Id | CompanyName …