Skip to main content

Posts

Showing posts from 2020

The query has been canceled because the estimated cost of this query () exceeds the configured threshold of 1000.

  Error: The query has been canceled because the estimated cost of this query () exceeds the configured threshold of 1000. Contact the system administrator. Cause: QUERY_GOVERNOR_COST_LIMIT - Is a numeric or integer value specifying the longest time in which a query can run. "Query cost" refers to the estimated elapsed time, in seconds, required to complete a query on a specific hardware configuration. Workthrough: GO   EXEC sp_configure 'show advanced options', 1;   GO   RECONFIGURE ;   GO   EXEC sp_configure 'query governor cost limit', 6000 ;   GO   RECONFIGURE;   GO  

image fallback directive angularjs

  HTML: < img fallback-src = "http://google.com/favicon.ico" ng-src = "{{image}}" /> JS: myApp.directive( 'fallbackSrc' , function ( ) { var fallbackSrc = { link : function postLink ( scope, iElement, iAttrs ) { iElement.bind( 'error' , function ( ) { angular.element( this ).attr( "src" , iAttrs.fallbackSrc); }); } } return fallbackSrc; });

ahara-nidra-bhaya-maithunam

आहर निद्रा भय मैथुनं च सामान्यमेतत पशुभिर्नराणाम् धर्मो हि तेषाम् अधिको विशेषो धर्मेण हीना पशुभिः समाना ahara-nidra-bhaya-maithunam ca samanyam etat pashubhih naranam dharmo hi tesham adhiko vishesho dharmena hina pashubhih samanah Hunger, sleep,fear and sexual desire are the instincts which are common between mankind and beasts (animals). .It is especially 'Dharma;' that mankind possesses additionally, and a person bereft of 'Dharma' is like a beast, “Eating, sleeping, fearing, and mating are the four principles of animal life. These are common both to animals and to human beings. But religion is the extra function of the human being. Without religion, human life is no better than animal life.” -from Mahabharata

Get First Date and Last date of previous Month using javascript

Getting First date of previous Month:  let GetFirstDateOfPreviousMonth=function(refDate){ let FirstDayPrevMonth = new Date(refDate.getFullYear(), refDate.getMonth()-1, 1); return FirstDayPrevMonth; } Getting Last date of previous Month: let GetLastDateOfPreviousMonth=function(refDate){ let LastDayPrevMonth = new Date(refDate.getFullYear(), refDate.getMonth(), 0); return LastDayPrevMonth ; }

Example of STUFF or FOR XML Path in SQL

This query is helpful when you want to make CSV type data for a relational table column Query     DECLARE @culture nvarchar(50)='en'   SELECT REPLACE(STUFF((             SELECT ',' + (CASE WHEN @culture='en' THEN esf.[Name_en] WHEN @culture='jp' THEN esf.[Name_jp] ELSE esf.[Name_jp] END)              FROM [dbo].[Staff.ProfessionalSpeciality] Sps   INNER JOIN [Master.EstimationSpecializedField] esf ON Sps.ProfessionalID = esf.ID    WHERE Sps.IsSelected = 1 AND Sps.StaffID= '875435ad-4851-48ad-8082-e1b687a9c3e3'             FOR XML PATH('')             ), 1, 1, ''),'&amp;','&')

To List down all DB Stored Procedure and Functions

 Here is a SQL Query to List down all DB Stored Procedure and Functions .We can use this to make a small tool to backup stored procedure and functions automatically using windows service . Query: DECLARE MY_CURSOR Cursor FOR SELECT TOP 1000 r.ROUTINE_NAME,r.ROUTINE_TYPE,r.Routine_Definition FROM INFORMATION_SCHEMA.Routines r  OPEN MY_CURSOR     DECLARE @sproc VARCHAR(MAX)  DECLARE @Name VARCHAR(MAX)    DECLARE @Type VARCHAR(MAX)      FETCH NEXT FROM MY_CURSOR INTO @Name, @Type, @sproc     WHILE (@@FETCH_STATUS <> -1)     BEGIN         IF (@@FETCH_STATUS <> -2) PRINT @Name PRINT @Type         PRINT @sproc         FETCH NEXT FROM MY_CURSOR INTO @Name, @Type, @sproc     END CLOSE MY_CURSOR DEALLOCATE MY_CURSOR GO

Delete a table from database having many dependency with others table using Entity framework

 Here is a sample C# code Snippet  : string foreignKeyTableInfo = string.Format("EXEC sp_fkeys '{0}'", "Company");                 IQueryable<ForeignKeyTableReference> fkTable = _dbContext.Database.SqlQuery<ForeignKeyTableReference>(foreignKeyTableInfo).AsQueryable();                 //L                 string disableFkTemplate = "ALTER TABLE [{{tableName}}] NOCHECK CONSTRAINT [{{FoerignKeyName}}];";                 string enableFkTemplate = "ALTER TABLE [{{tableName}}] CHECK CONSTRAINT [{{FoerignKeyName}}];";                 //END                 string disable_template = "ALTER TABLE [{{tableName}}] NOCHECK CONSTRAINT ALL;";                 string enable_template = "ALTER TABLE [{{ta...

Search a string in all stored procedure

 SELECT ROUTINE_NAME, ROUTINE_DEFINITION     FROM INFORMATION_SCHEMA.ROUTINES      WHERE ROUTINE_DEFINITION LIKE '%EXEC(@%' OR  ROUTINE_DEFINITION LIKE '%EXEC (@%'  OR  ROUTINE_DEFINITION LIKE '%EXEC @%'  OR  ROUTINE_DEFINITION LIKE '%sp_executesql%' OR  ROUTINE_DEFINITION LIKE '%EXEC @%' OR  ROUTINE_DEFINITION LIKE '%PRINT @%'     AND ROUTINE_TYPE='PROCEDURE'

Search Whole database sample stored procedure

   ========================CREDIT===================== -- Copyright © 2002 Narayana Vyas Kondreddi. All rights reserved. -- Purpose: To search all columns of all tables for a given search string -- Written by: Narayana Vyas Kondreddi -- Site: http://vyaskn.tripod.com -- Updated and tested by Tim Gaunt -- http://www.thesitedoctor.co.uk -- http://blogs.thesitedoctor.co.uk/tim/2010/02/19/Search+Every+Table+And+Field+In+A+SQL+Server+Database+Updated.aspx -- Tested on: SQL Server 7.0, SQL Server 2000, SQL Server 2005 and SQL Server 2010 -- Date modified: 03rd March 2011 19:00 GMT =============================END===========================  DECLARE @SearchStr nvarchar(100) SET @SearchStr = '9D2BAE6F-062B-4A86-8A92-B64F2AE46CAA' CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))   SET NOCOUNT ON   DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110) SET  @TableName = '' SET @SearchStr2 = QUOTENAME('%' + @...

How to load the script file immediately (dynamically added) before continue?

 y ou can return a promise to chain calls export class HomeComponent { constructor () { this . loadDynmicallyScript () . then (() => { this . doSomethingWhenScriptIsLoaded (); }); } public loadDynmicallyScript (): Promise { var script = document . createElement ( 'script' ); script . src = "../node_modules/xxxxxx/i18n/xx.min.js" ; script . async = false ; document . head . appendChild ( script ); return Promise (( resolve , reject ) => { script . onload = resolve ; }); } or just pass a function to the  onLoad  to be called when the script was loaded export class HomeComponent { constructor () { this . loadDynmicallyScript () } public loadDynmicallyScript (): Promise { var script = document . createElement ( 'script' ); script . src = "../node_modules/xx...