The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions

You do not need to use ORDER BY in inner query after WHERE clause because you have already used it in ROW_NUMBER() OVER (ORDER BY VRDATE DESC). SELECT * FROM ( SELECT Stockmain.VRNOA, item.description as item_description, party.name as party_name, stockmain.vrdate, stockdetail.qty, stockdetail.rate, stockdetail.amount, ROW_NUMBER() OVER (ORDER BY VRDATE DESC) AS RowNum –< ORDER BY FROM … Read more

Getting total row count from OFFSET / FETCH NEXT

I encountered some performance issues using the COUNT() OVER() method. (I’m not sure if it was the server as it took 40 seconds to return 10 records and then later didn’t have any issues.) This technique worked under all conditions without having to use COUNT() OVER() and accomplishes the same thing: DECLARE @PageSize INT = … Read more

Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 0

If you have a TRY/CATCH block then the likely cause is that you are catching a transaction abort exception and continue. In the CATCH block you must always check the XACT_STATE() and handle appropriate aborted and uncommitable (doomed) transactions. If your caller starts a transaction and the calee hits, say, a deadlock (which aborted the … Read more

SQL Server 2012 column identity increment jumping from 6 to 1000+ on 7th entry [duplicate]

This is all perfectly normal. Microsoft added sequences in SQL Server 2012, finally, i might add and changed the way identity keys are generated. Have a look here for some explanation. If you want to have the old behaviour, you can: use trace flag 272 – this will cause a log record to be generated … Read more

Identity increment is jumping in SQL Server database

You are encountering this behaviour due to a performance improvement since SQL Server 2012. It now by default uses a cache size of 1,000 when allocating IDENTITY values for an int column and restarting the service can “lose” unused values (The cache size is 10,000 for bigint/numeric). This is mentioned in the documentation SQL Server … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)