Insert Result Into Hash/Temp Table- Sql Server

Jul 22, 2019 BY xtreme

Insert Result Of Another Store Procedure CREATE TABLE #Result ( Status nvarchar(100), Id INT, Name nvarchar(200) ) INSERT INTO #Result EXEC dbo.rpt_get_result @id,@filter Insert Result of Dynamic Query CREATE TABLE #Result ( Status nvarchar(100), ...

Compatibility Level Check / Set - performance Issue - Sql Server

Jul 22, 2019 BY xtreme

To Compatible Transact-SQL and query processing behaviors with the specified version of the SQL Server Database Engine. -- To check the compatibility level: select compatibility_level from sys.databases where name = '' -- To set the compatibility level: alter database database_name...

Format Date in Tsql - Sql Server

Jul 22, 2019 BY xtreme

SQL Server 2012 or above versions SELECT TOP 1 FORMAT (GETDATE(), 'd', 'en-us') --US -MM/DD/YYYY SELECT TOP 1 FORMAT (GETDATE(), 'd', 'fr-FR') --FR -DD/MM/YYYY SELECT TOP 1 FORMAT (GETDATE(), 'd', 'ja-JP') --JP -YYYY/MM/DD SELECT TOP 1 FORMAT (GETDATE(), 'D', 'en-us') --...

Get Object Updated or Created in last N Days - Sql Server

Jul 22, 2019 BY xtreme

Store Procedure / Tables Updated in Last 30 Days select dateadd(day, -30, getdate()) ,* from sys.objects where (type = 'P' ) and modify_date > dateadd(day, -30, getdate()) and name like '%Table_Name%' order by modify_date desc NOTE- Use U for User Defined Ta...

Condition check in Linq Query- Linq

Jul 13, 2019 BY xtreme

Check if Match Foundpublic Student GetStudentDetails(int id) { using (DbContextModel _db = new DbContextModel()) { var result = _db.student.Where(x => x.is_active && !x.is_deleted).Select(x => new StudentModel { id = x.id, mode = x.status.ToString().Contains("paid") ...

Aggregate methods in Linq Query - Linq

Jul 13, 2019 BY xtreme

1. ANY Method Returns a Boolean value. Returns True even if a single element satisfies the condition. Return False if none of the elements satisfies the condition.. Linq to sqlpublic bool CheckStudents() { bool check = false; using (DbContextModel _db = new DbContextModel()) ...

Call Local Function in LInq Query - Linq

Jul 12, 2019 BY xtreme

Call function in Linqpublic Student GetStudentDetails(int id) { using (DbContextModel _db = new DbContextModel()) { var result = _db.student.Where(x => x.is_active && !x.is_deleted).Select(x => new StudentModel { id = x.id, source = x.source != null ? GetSource(x.sou...