[Solved] Lots of updates to a large table. How to speed up?

–Requete 40. Performance cost: 3% UPDATE #temp_arbo_of_3 SET PxAchat=NULL, CuTpsAch=NULL WHERE IdBE IS NULL; –Requete 41. Performance cost: 2% UPDATE #temp_arbo_of_3 SET CuTrait = NULL WHERE IdBE IS NOT NULL; –Requete 42. Performance cost: 2% UPDATE #temp_arbo_of_3 SET NrOF_Source = _ofI WHERE IdBE IS NOT NULL; Now if I replace all this by: –Requete 40. … Read more

[Solved] Error when execute query [closed]

The roll number string in your where clause needs to be delimited as a string. This line query = query + ” ” + “WHERE rollNo=” + “2K12-BSCS-37″; should be replaced with query += ” ” + “WHERE rollNo=” + “‘2K12-BSCS-37′”; Note the single quotes. Better still would be to use string format to build … Read more

[Solved] SQL query to get time spent on specific statuses based on single datetime column [closed]

with SQL Server you can use those very usefull windowed functions LEAD and FIRST_VALUE : select * ,[duration(sec)] = DATEDIFF(SECOND ,ticketTime ,LEAD(ticketTime,1,ticketTime)over(partition by ticketNumber order by ticketTime) ) ,[cumulative duration(sec)] = DATEDIFF( SECOND , FIRST_VALUE(ticketTime)over(partition by ticketNumber order by ticketTime) , ticketTime) from (values (1,cast(‘20211101 10:00:01′ as datetime)) ,(1,’20211101 10:00:33′) ,(1,’20211101 10:01:59’) )T(ticketNumber,ticketTime) ticketNumber ticketTime … Read more

[Solved] How to Select A number of data of table record, but before apply a condition on this record?

To expand on my comment about moving the [Gu-Id] IS NULL, try this: ALTER PROC [dbo].[SPFetchAllDisActiveUser] ( @StartRowIndex INT, @MaxRows INT ) AS BEGIN SELECT * FROM ( SELECT *, ROW_NUMBER() OVER(ORDER BY [User-ID] ASC) AS RowNum FROM [User-Tbl] WHERE [Gu-Id] IS NULL ) AS DisActiveUser WHERE RowNum BETWEEN @StartRowIndex + 1 AND @MaxRows; END … Read more

[Solved] Can referential integrity be enforced using alter table?

I’m not sure I understand why you think this is better than foreign keys, but yes, you can implement referential integrity in other (inferior) ways. These will be slower than doing it right and fixing the design. Check constraint + UDF CREATE FUNCTION dbo.IsItAValidWeight(@Son_Weight int) RETURNS bit WITH SCHEMABINDING AS BEGIN RETURN ( SELECT CASE … Read more

[Solved] I have a query with a between clause that is return wrong days [closed]

Let’s break this down: WHERE convert(varchar(10),F_Presence.ts, 120) between ‘2022-03-01’ and ‘2022-03-02’ Converting the column to a string means you will never, ever, ever be able to take advantage of an index on that column, whether it exists yet or not. Using BETWEEN is horrible for date ranges for multiple reasons. Using a format like YYYY-MM-DD … Read more

[Solved] Query to get a output in desired format

Another approach using CTE and Joins. declare @table table(Proce int, type char(1), addi int, sub int, multi int, div int) insert into @table values (1,’A’, 1, 0, 1, 1), (1,’B’, 2, 2, 0, 1); ;with cte_a as ( SELECT proce, max(addi) as Aadd, max(sub) as Asub, max(multi) as Amulti, max(div) as Adiv FROM @table where … Read more

[Solved] how to export specific column after query meets criteria?

Just include the column(s) you want after select instead of using * (“all”): select body from message where date between ‘2001-09-09 00:00:00’ and ‘2001-09-10 00:00:00’ The column(s) you select and the column(s) by which you filter can be two entirely different sets of columns. 1 solved how to export specific column after query meets criteria?

[Solved] How to assign date at each insertion in sql server c# [closed]

Change your database structure like this Table Leave emp_id, leave_id, leave_Type, days_applied, from_date, to_date, date_applied Table Leave Type leave_Type_id, leave_Type Note: Above tables are just for e.g. to solve your problem you can change it. With above structure you can easily calculate leaves taken by employee and also filter by leave type. 5 solved How … Read more

[Solved] SSRS report parameter

A few things to check: SetParameters takes IEnumerable<ReportParameter> not a single ReportParameter object. Call it like this instead: serverReport.SetParameters(new ReportParameter[] { ReportParameter(“dt1”, date.ToString()) } ); Make sure that the parameter does not have the available values filled in as well as the default value. If the date passed is not one of the valid values … Read more

[Solved] Using C# and asp read and write xml [closed]

Take a look at the docs on MSDN, there are examples at the bottom. http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx for getting a dataset from XML see this MSDN article http://msdn.microsoft.com/en-us/library/fx29c3yd.aspx the final part – regarding the writing back to multiple tables can be see from this walk through on MSDN http://msdn.microsoft.com/en-us/library/4esb49b4.aspx 6 solved Using C# and asp read and … Read more

[Solved] Which table contain this data+ SQL

ypercube’s suggestion is exactly correct. Here is an implementation: DECLARE @searchText VARCHAR(100) SET @searchText=”Assumed Life Claims” DECLARE @sqlText VARCHAR(8000) DECLARE @MaxId INT DECLARE @CurId INT DECLARE @possibleColumns TABLE (Id INT IDENTITY(1, 1) NOT NULL PRIMARY KEY ,sqlText VARCHAR(8000)) INSERT INTO @possibleColumns(sqlText) SELECT ‘IF EXISTS (SELECT * FROM ‘ + c.TABLE_NAME + ‘ WHERE ‘ + … Read more