Categories
MSSQL

TSQL Min, Max, AVG and Last Value in single query

declare @MyTable table ( SN INT ,[Month] INT ,Acc INT ,Bal INT ) — GO INSERT INTO @MyTable VALUES (1, 7, 101, 1000), (2, 7, 101, 800), (3, 7, 101, 1700), (4, 8, 101, 1200), (5, 8, 101, 900), (6, 9, 101, 2500) — GO select distinct Acc, [Month], MinBal, AvgBal, MaxBal, LastVal from ( […]

Categories
C# Notes

Basic Controller Variables

If controller is related to central only i.e it contains dbCore only it should inherit from BaseAsyncController If controller is related to Organisation also i.e it contains both dbCore and dbOrg it should inherit from BaseAsyncFOController While inheriting Any Controller from BaseAsyncController or BaseAsyncFOController, it should initialise base controller with respective variables also. eg For […]

Categories
Uncategorized

Fix user, Role already exists in mssql db

Whenever we restore db but user doesn’t exists and user is created after db restore only. following error appears. sp_change_users_login ‘AUTO_FIX’, ‘coop_sahakari_paanch’

Categories
Uncategorized

MVC5 Async RedirectToAction

use Async Task Run for async return redirecttoaction return await Task.Run<ActionResult>(() => { return RedirectToAction(“MultipleLoanEODFix”); });

Categories
MSSQL

Some useful Commands for Check and Maintain MSSQL Database

— Shrink Database DBCC SHRINKDATABASE (AdventureWorks2008R2, TRUNCATEONLY); — Rebuild All Index on a table ALTER INDEX ALL ON Production.Product REBUILD WITH (FILLFACTOR = 80, SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = ON); — Reorganize all indexes on the HumanResources.Employee table. ALTER INDEX ALL ON HumanResources.Employee REORGANIZE ; — Check DB for database consistency DBCC CHECKDB — Reclaims […]

Categories
C# Notes

Basic Pattern for application

PDF File Link: App Pattern Use AsyncControllers Use await, ToListAsync, SaveChangesAsync, FindAsync