This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get usage statistics on Index using DMVs in SQL Server | |
// Reference: https://www.sqlshack.com/gathering-sql-server-indexes-statistics-and-usage-information/ | |
SELECT OBJECT_NAME(IX.OBJECT_ID) Table_Name | |
,IX.name AS Index_Name | |
,IX.type_desc Index_Type | |
,SUM(PS.[used_page_count]) * 8 IndexSizeKB | |
,IXUS.user_seeks AS NumOfSeeks | |
,IXUS.user_scans AS NumOfScans | |
,IXUS.user_lookups AS NumOfLookups |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This one is bash, bcoz bcp is a cmd line utility | |
# https://docs.microsoft.com/en-us/sql/tools/bcp-utility?view=sql-server-ver15#examples | |
# WideWorldImporters can be downloaded from https://github.com/Microsoft/sql-server-samples/releases/tag/wide-world-importers-v1.0 | |
bcp WideWorldImporters.Warehouse.StockItemTransactions out D:\BCP\StockItemTransactions_character.bcp -c -T | |
# Bulk Insert | |
BULK INSERT YourTargetTable FROM '\\shared\directory\sourcedata.txt'; | |
BULK INSERT Sales.Invoices | |
FROM 'inv-2017-12-08.csv' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR ALTER FUNCTION dbo.AgeStatus | |
( | |
@AGE INT | |
) | |
RETURNS CHAR(10) | |
AS | |
BEGIN | |
DECLARE @status CHAR(5); | |
IF @AGE < 18 | |
SET @category = 'MINOR'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION CUBE(@X INT) | |
RETURNS INT | |
AS | |
BEGIN | |
RETURN @X * @X *@X | |
END | |
/* | |
To execute the above function call it like below | |
SELECT dbo.CUBE(5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- DB to use | |
use Puzzles; | |
-- Remove the Table and the SP if it already exists | |
drop table dbo.generated_table; | |
drop procedure dbo.addRows; | |
-- Define the Table to be populated with generated data | |
CREATE TABLE dbo.generated_table ( | |
id int --PRIMARY KEY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem -Recurse | Select-String -Pattern 'abc' -List | Select-String -Pattern 'pqr' -List | | Select-String -Pattern 'xyz' -List | Select Path | |
# With pipes '|', we are filtering the result set with additional search terms thus acing like the search for terms are AND conditional. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem -Recurse | Select-String -Pattern 'abc', 'pqr', 'xyz' -List | Select Path | |
# Select-String commandlet can take an array list of strings that it can search for existence and returns all files that has any of those strings in its content. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem -Recurse | Select-String -Pattern 'abc' -List | Select Path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
StartServers 10 | |
MinSpareServers 10 | |
MaxSpareServers 10 | |
MaxRequestWorkers 80 | |
MaxConnectionsPerChild 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_evasive20.c> | |
DOSHashTableSize 3097 | |
DOSPageCount 1 | |
DOSSiteCount 3 | |
DOSPageInterval 1 | |
DOSSiteInterval 1 | |
DOSBlockingPeriod 10 | |
#DOSEmailNotify [email protected] | |
#DOSSystemCommand "su - someuser -c '/sbin/... %s ...'" | |
#DOSLogDir "/var/log/mod_evasive" |