Wednesday, August 6, 2014

Some scripts

http://www.pinaldave.com/sql-script-bank/best-sql-blog-sql-server-script1/


SQL SERVER – Index Created on View not Used Often – Observation of the View
SQL SERVER – Server Side Paging in SQL Server Denali Performance Comparison
SQL SERVER – Server Side Paging in SQL Server Denali – A Better Alternative
SQL SERVER – Solution – Challenge – Puzzle – Usage of FAST Hint
SQL SERVER – Solution – Puzzle – Challenge – Error While Converting Money to Decimal
SQL SERVER – Information Related to DATETIME and DATETIME2
SQL SERVER – Get All the Information of Database using sys.databases
SQL SERVER – Finding Last Backup Time for All Database
SQL SERVER – Taking Multiple Backup of Database in Single Command – Mirrored Database Backup
SQL SERVER – Find Total Number of Transaction on Interval
SQL SERVER – Get Query Running in Session
SQL SERVER – View Over the View Not Possible with Index View – Limitations of the View 11
SQL SERVER – Keywords View Definition Must Not Contain for Indexed View – Limitation of the View 10
SQL SERVER – SELF JOIN Not Allowed in Indexed View – Limitation of the View 9
SQL SERVER – Get Numeric Value From Alpha Numeric String – Get Numbers Only
SQL SERVER – Outer Join Not Allowed in Indexed Views – Limitation of the View 8
SQL SERVER – Cross Database Queries Not Allowed in Indexed View – Limitation of the View 7
SQL SERVER – UNION Not Allowed but OR Allowed in Index View – Limitation of the View 6
SQL SERVER – COUNT(*) Not Allowed but COUNT_BIG(*) Allowed – Limitation of the View 5
SQL SERVER – SELECT * and Adding Column Issue in View – Limitation of the View 4
SQL SERVER – Disabled Index and Index Levels and B-Tree
SQL SERVER – Find Automatically Created Statistics – T-SQL
SQL SERVER – Find Row Count in Table – Find Largest Table in Database – Part 2
SQL SERVER – Index Created on View not Used Often – Limitation of the View 3
SQL SERVER – Adding Column is Expensive by Joining Table Outside View – Limitation of the Views Part 2
SQL SERVER – ORDER BY Does Not Work – Limitation of the Views Part 1
SQL SERVER – Computed Columns – Index and Performance
SQL SERVER – Computed Column – PERSISTED and Storage – Part 2
SQL SERVER – Function to Retrieve First Word of Sentence – String Operation
SQL SERVER – Negative Identity Seed Value and Negative Increment Interval
SQL SERVER – Computed Column and Performance – Part 3
SQL SERVER – SHRINKDATABASE For Every Database in the SQL Server
SQL SERVER – Computed Column – PERSISTED and Performance – Part 2
SQL SERVER – Computed Column – PERSISTED and Performance
SQL SERVER – Introduction to BINARY_CHECKSUM and Working Example
SQL SERVER – Find Queries using Parallelism from Cached Plan
SQL SERVER – Datetime Function TODATETIMEOFFSET Example
SQL SERVER – Datetime Function SWITCHOFFSET Example
SQL SERVER – The Self Join – Inner Join and Outer Join
SQL SERVER – Outer Join Not Allowed in Indexed Views
SQL SERVER – Default Statistics on Column – Automatic Statistics on Column
SQL SERVER – Data Pages in Buffer Pool – Data Stored in Memory Cache
SQL SERVER – Difference Between DATETIME and DATETIME2 – WITH GETDATE
SQL SERVER – Difference Between DATETIME and DATETIME2
SQL SERVER – Difference Between GETDATE and SYSDATETIME
SQL SERVER – Merge Operations – Insert, Update, Delete in Single Execution
SQL SERVER – Subquery or Join – Various Options – SQL Server Engine Knows the Best – Part 2
SQL SERVER – Subquery or Join – Various Options – SQL Server Engine knows the Best
SQL SERVER – Convert IN to EXISTS – Performance Talk
SQL SERVER – Disabled Index and Update Statistics
SQL SERVER – DATE and TIME in SQL Server 2008
SQL SERVER – Simple Example of Snapshot Isolation – Reduce the Blocking Transactions
SQL SERVER – Understanding ALTER INDEX ALL REBUILD with Disabled Clustered Index
SQL SERVER – Size of Index Table for Each Index – Solution 3 – Powershell
SQL SERVER – Size of Index Table for Each Index – Solution 2
SQL SERVER – Get Latest SQL Query for Sessions – DMV
SQL SERVER – Get Latest SQL Query for Sessions – DMV
SQL SERVER – SHRINKFILE and TRUNCATE Log File in SQL Server 2008
SQL SERVER – Disable Clustered Index and Data Insert
SQL SERVER – T-SQL Script to Take Database Offline – Take Database Online
SQL SERVER – Create Primary Key with Specific Name when Creating Table
SQL SERVER – Difference Between ROLLBACK IMMEDIATE and WITH NO_WAIT during ALTER DATABASE
SQL SERVER – Performance Comparison – INSERT TOP (N) INTO Table – Using Top with INSERT
SQL SERVER – ALTER DATABASE dbname SET SINGLE_USER WITH ROLLBACK IMMEDIATE
SQL SERVER – Find the Size of Database File – Find the Size of Log File
SQL SERVER – Find Statistics Update Date – Update Statistics
SQL SERVER – Unique Nonclustered Index Creation with IGNORE_DUP_KEY = ON – A Transactional Behavior
SQL SERVER – Find Location of Data File Using T-SQL
SQL SERVER – Get Date of All Weekdays or Weekends of the Year
SQL SERVER – ORDER BY Clause and TOP WITH TIES
SQL SERVER – Comma Separated Values (CSV) from Table Column – Part 2
SQL SERVER – Comma Separated Values (CSV) from Table Column
SQL SERVER – Interesting Observation – TOP 100 PERCENT and ORDER BY
SQL SERVER – Removing Key Lookup – Seek Predicate – Predicate – An Interesting Observation Related to Datatypes
SQL SERVER – Recently Executed T-SQL Query 

http://www.pinaldave.com/sql-script-bank/best-sql-blog-sql-server-script2/

SQL SERVER – Enable Automatic Statistic Update on Database
SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup – Part 3
SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup – Part 2
SQL SERVER – Query Optimization – Remove Bookmark Lookup – Remove RID Lookup – Remove Key Lookup
SQL SERVER – Interesting Observation – Query Hint – FORCE ORDER
SQL SERVER – Interesting Observation – Index on Index View Used in Similar Query
SQL SERVER – Get Query Plan Along with Query Text and Execution Count
SQL SERVER – Measure CPU Pressure – CPU Business
SQL Server – Multiple CTE in One SELECT Statement Query
SQL SERVER – Two Methods to Retrieve List of Primary Keys and Foreign Keys of Database
SQL SERVER – Interesting Observation of Logon Trigger On All Servers – Solution
SQL SERVER – List All Objects Created on All Filegroups in Database
SQL SERVER – Create Multiple Filegroup For Single Database
SQL SERVER – Interesting Observation of Logon Trigger On All Servers
SQL SERVER – How to Drop Primary Key Contraint
SQL SERVER – Reseed Identity of Table – Table Missing Identity Values – Gap in Identity Column
SQL SERVER – 2008 – SCOPE_IDENTITY Bug with Multi Processor Parallel Plan and Solution
SQL SERVER – UDF – Pad Ride Side of Number with 0 – Fixed Width Number Display
SQL SERVER – Interesting Observation of ON Clause on LEFT JOIN – How ON Clause Effects Resultset in LEFT JOIN
SQL SERVER – Pad Ride Side of Number with 0 – Fixed Width Number Display
SQL SERVER – 2008 – Find Relationship of Foreign Key and Primary Key using T-SQL – Find Tables With Foreign Key Constraint in Database
SQL SERVER – Enable and Disable Index Non Clustered Indexes Using T-SQL
SQL SERVER – Find Current Location of Data and Log File of All the Database
SQL SERVER – List All Server Wide Configurations Values
SQL SERVER – T-SQL Script for FizzBuzz Logic
SQL SERVER – Generate A Single Random Number for Range of Rows of Any Table – Very interesting Question from Reader
SQL SERVER – Remove Duplicate Entry from Comma Delimited String – UDF
SQL SERVER – Find Number of Rows and Disk Space Reserved – Using sp_spaceused Interesting Observation
SQL SERVER – Find Row Count in Table – Find Largest Table in Database – T-SQL
SQL SERVER – Time Delay While Running T-SQL Query – WAITFOR Introduction
SQL SERVER – 2008 – 2005 – Find Longest Running Query – TSQL
SQL SERVER – Find Table in Every Database of SQL Server – Part 2
SQL SERVER – Better Performance – LEFT JOIN or NOT IN?
SQL SERVER – Generate Foreign Key Scripts For Database
SQL SERVER – 2008 – Row Constructors – Load Temp Tables From Stored Procedures
SQL SERVER – 2005 – Transferring Ownership of a Schema to a User
SQL SERVER – 2005 – List All Column With Indentity Key In Specific Database
SQL SERVER – 2005 – Introduction to sys.dm_exec_query_optimizer_info
SQL SERVER – 2005 – Find Index Fragmentation Details – Slow Index Performance
SQL SERVER – 2005 – Find Highest / Most Used Stored Procedure
SQL SERVER – Add Column With Default Column Constraint to Table
SQL SERVER – 2005 – Retrieve Any User Defined Object Details Using sys.objects Database
SQL SERVER – 2005 – Find Nth Highest Record from Database Table
SQL SERVER – Simple Example of Cursor – Sample Cursor Part 2
SQL SERVER – SELECT 1 vs SELECT * – An Interesting Observation
SQL SERVER – Find All The User Defined Functions (UDF) – Part 2
SQL SERVER – UDF to Return a Calendar for Any Date for Any Year
SQL SERVER – Get Current Database Name
SQL SERVER – 2005 – Find Unused Indexes of Current Database
SQL SERVER – Simple Example of WHILE Loop with BREAK and CONTINUE
SQL SERVER – Find All The User Defined Functions (UDF) in a Database
SQL SERVER – 2005 – Database Table Partitioning Tutorial – How to Horizontal Partition Database Table
SQL SERVER – 2005 – Get a row per file of a database as stored in the master database
SQL SERVER – Introduction to Statistical Functions – VAR, STDEVP, STDEV, VARP
SQL SERVER – 2005 – Change Compatibility Level – T-SQL Procedure
SQL SERVER – Reclaim Space After Dropping Variable-Length Columns Using DBCC CLEANTABLE
SQL SERVER – 2005 – Display Fragmentation Information of Data and Indexes of Database Table
SQL SERVER – Execute Same Query and Statement Multiple Times Using Command GO
SQL SERVER – 2005 – Export Data From SQL Server 2005 to Microsoft Excel Datasheet
SQL SERVER – 2005 – Introduction and Explanation to SYNONYM – Helpful T-SQL Feature for Developer
SQL SERVER – 2005 – Last Ran Query – Recently Ran Query
SQL SERVER – Difference Between Index Rebuild and Index Reorganize Explained with T-SQL Script
SQL SERVER – Enabling Clustered and Non-Clustered Indexes – Interesting Fact
SQL SERVER – DISTINCT Keyword Usage and Common Discussion
SQL SERVER – Get Information of Index of Tables and Indexed Columns
SQL SERVER – T-SQL Script to Find Details About TempDB
SQL SERVER – UDF – Remove Duplicate Chars From String
SQL SERVER – 2005 – List All Stored Procedure in Database
SQL SERVER – Simple Example of WHILE Loop With CONTINUE and BREAK Keywords
SQL SERVER – T-SQL Script to Add Clustered Primary Key
SQL SERVER – 2005 – Explanation of TRY…CATCH and ERROR Handling With RAISEERROR Function
SQL SERVER – Introduction and Example for DATEFORMAT Command
SQL SERVER – 2005 – List All The Constraint of Database – Find Primary Key and Foreign Key Constraint in Database
SQL SERVER – UDF – User Defined Function – Get Number of Days in Month
SQL SERVER – 2005 – Find Tables With Primary Key Constraint in Database

http://www.pinaldave.com/sql-script-bank/best-sql-blog-sql-server-script3/

SQL SERVER – DISABLE and ENABLE user SA
SQL SERVER – Find Next Running Time of Scheduled Job Using T-SQL
SQL SERVER – Change Collation of Database Column – T-SQL Script
SQL SERVER – Find Collation of Database and Table Column Using T-SQL
SQL SERVER – Interesting Interview Questions
SQL SERVER – Default Collation of SQL Server 2008
SQL SERVER – Simple Use of Cursor to Print All Stored Procedures of Database Including Schema
SQL SERVER – DECLARE Multiple Variables in One Statement
SQL SERVER – Simulate INNER JOIN using LEFT JOIN statement – Performance Analysis
SQL SERVER – Transaction and Local Variables – Swap Variables – Update All At Once Concept
SQL SERVER – Introduction to CLR – Simple Example of CLR Stored Procedure
SQL SERVER – Retrieve – Select Only Date Part From DateTime – Best Practice – Part 2
SQL SERVER – Get Common Records From Two Tables Without Using Join
SQL SERVER – Get Numeric Value From Alpha Numeric String – UDF for Get Numeric Numbers Only
SQL SERVER – 2008 – Enhenced TRIM() Function – Remove Trailing Spaces, Leading Spaces, White Space, Tabs, Carriage Returns, Line Feeds
SQL SERVER – 2008 – Find If Index is Being Used in Database
SQL SERVER – Example of PIVOT UNPIVOT Cross Tab Query in Different SQL Server Versions
SQL SERVER – Get Answer in Float When Dividing of Two Integer
SQL SERVER – 2008 – Creating Primary Key, Foreign Key and Default Constraint
SQL SERVER – 2008 – Creating Full Text Catalog and Full Text Search
SQL SERVER – 2008 – Introduction to Filtered Index – Improve performance with Filtered Index
SQL SERVER – 2008 – Introduction to Table-Valued Parameters with Example
SQL SERVER – Few Useful DateTime Functions to Find Specific Dates
SQL SERVER – 2008 – Introduction to Merge Statement – One Statement for INSERT, UPDATE, DELETE
SQL SERVER – 2008 – Configure Database Mail – Send Email From SQL Database

SQL SERVER – Disable All the Trigger of Current Database
SQL SERVER – EXCEPT Clause in SQL Server is Similar to MINUS Clause in Oracle
SQL SERVER – 2005 – Difference Between INTERSECT and INNER JOIN – INTERSECT vs. INNER JOIN
SQL SERVER – 2008 – Get Current System Date Time
SQL SERVER – 2008 – Find Current System Date Time and Time Offset
SQL SERVER – SQL SERVER – Simple Example of Recursive CTE – Part 2 – MAXRECURSION – Prevent CTE Infinite Loop
SQL SERVER – Simple Example of Recursive CTE
SQL SERVER – 2008 – Introduction to SPARSE Columns – Part 2
SQL SERVER – 2008 – Introduction to SPARSE Columns
SQL SERVER – 2008 – Two Convenient Features Inline Assignment – Inline Operations
SQL SERVER – 2008 – Introduction to Row Compression
SQL SERVER – 2008 – Insert Multiple Records Using One Insert Statement – Use of Row Constructor
SQL SERVER – Find Current Identity of Table
SQL SERVER – 2008 – Inline Variable Assignment
SQL SERVER – 2008 – Compound Assignment Operators
SQL SERVER – Create a Comma Delimited List Using SELECT Clause From Table Column
SQL SERVER – Create Default Constraint Over Table Column
SQL SERVER – 2005 – Use of Non-deterministic Function in UDF – Find Day Difference Between Any Date and Today
SQL SERVER – Find Last Day of Any Month – Current Previous Next
SQL SERVER – 2005 – Find Stored Procedure Create Date and Modified Date
SQL SERVER – 2005 – List All The Column With Specific Data Types
SQL SERVER – 2005 – List Tables in Database Without Primary Key
SQL SERVER – Stop SQL Server Immediately Using T-SQL
SQL SERVER – UDF – Get the Day of the Week Function
SQL SERVER – SPACE Function Example
SQL SERVER – 2005 – Use ALTER DATABASE MODIFY NAME Instead of sp_renameDB to rename
SQL SERVER – Result of EXP (Exponential) to the POWER of PI – Functions Explained
SQL SERVER – Running Batch File Using T-SQL – xp cmdshell bat file
SQL SERVER – 2005 List All Tables of Database
SQL SERVER – Explanation and Comparison of NULLIF and ISNULL
SQL SERVER – Find Length of Text Field
SQL SERVER – LEN and DATALENGTH of NULL Simple Example
SQL SERVER – UDF – Function to Display Current Week Date and Day – Weekly Calendar
SQL SERVER – 2005 Find Table without Clustered Index – Find Table with no Primary Key
SQL SERVER – Script/Function to Find Last Day of Month
SQL SERVER – Math Functions for 2005
SQL SERVER – Disable Index – Enable Index – ALTER Index
SQL SERVER – Binary Sequence Generator – Truth Table Generator
SQL SERVER – UDF – Function to Parse AlphaNumeric Characters from String
SQL SERVER – Fix : Error : Msg 6263, Level 16, State 1, Line 2 Enabling SQL Server 2005 for CLR Support
SQL SERVER – UDF – User Defined Function to Find Weekdays Between Two Dates
SQL SERVER – Collate – Case Sensitive SQL Query Search
SQL SERVER – Query to Retrieve the Nth Maximum Value
SQL SERVER – CASE Statement/Expression Examples and Explanation
SQL SERVER – Restore Database Backup using SQL Script (T-SQL)
SQL SERVER – Find Stored Procedure Related to Table in Database – Search in All Stored Procedure
SQL SERVER – Simple Cursor to Select Tables in Database with Static Prefix and Date Created
SQL SERVER – Auto Generate Script to Delete Deprecated Fields in Current Database
SQL SERVER – Query to Find ByteSize of All the Tables in Database
SQL SERVER – Query to Display Foreign Key Relationships and Name of the Constraint for Each Table in Database 

Favourite scripts

http://www.pinaldave.com/sql-script-bank/best-sql-blog-sql-server-script/

SQL SERVER – Server Side Paging in SQL Server Denali – A Better Alternative
SQL SEVER – Finding Memory Pressure – External and Internal
SQL SERVER – Quickest Way to Identify Blocking Query and Resolution – Dirty Solution
SQL SERVER – Index Levels and Delete Operations – Page Level Observation
SQL SERVER – SHRINKDATABASE For Every Database in the SQL Server 
SQL SERVER – SELECT * FROM dual – Dual Equivalent
SQL SERVER – Index Levels, Page Count, Record Count and DMV - sys.dm_db_index_physical_stats
SQL SERVER – Data Pages in Buffer Pool – Data Stored in Memory Cache
SQL SERVER – Precision of SMALLDATETIME – A 1 Minute Precision
SQL SERVER – Find Most Expensive Queries Using DMV
SQL SERVER – Get Latest SQL Query for Sessions – DMV
SQL SERVER – SHRINKFILE and TRUNCATE Log File in SQL Server 2008
SQL SERVER – 2008 – Introduction to Snapshot Database – Restore From Snapshot 
SQL SERVER – Introduction to Extended Events – Finding Long Running Queries
SQL SERVER – Data and Page Compressions – Data Storage and IO Improvement
SQL SERVER – INSERT TOP (N) INTO Table – Using Top with INSERT
SQL SERVER- IF EXISTS(Select null from table) vs IF EXISTS(Select 1 from table)
SQL SERVER – Plan Recompilation and Reduce Recompilation – Performance Tuning
SQL SERVER – Get the List of Object Dependencies – sp_depends and information_schema.routines and sys.dm_sql_referencing_entities
SQL SERVER – Difference Temp Table and Table Variable – Effect of Transaction
SQL SERVER – Difference TempTable and Table Variable – TempTable in Memory a Myth
SQL SERVER – Understanding Table Hints with Examples
SQL SERVER – Stored Procedure are Compiled on First Run – SP taking Longer to Run First Time
SQL SERVER – How to Enable Index – How to Disable Index – Incorrect syntax near ‘ENABLE’
SQL SERVER – Outer Join in Indexed View – Question to Readers
SQL SERVER – Insert Values of Stored Procedure in Table – Use Table Valued Function
SQL SERVER – Intorduction to Service Broker and Sample Script
SQL SERVER – Mirrored Backup and Restore and Split File Backup
SQL SERVER – Difference between Line Feed (\n) and Carriage Return (\r) – T-SQL New Line Char
SQL SERVER – 2005 – 2008 – Delete Duplicate Rows
SQL SERVER – 2008 – Optimize for Ad hoc Workloads – Advance Performance Optimization
SQL SERVER – Simple Example of Reading XML File Using T-SQL
SQL SERVER – Simple Example of Creating XML File Using T-SQL 
SQL SERVER – Quickest Way to – Kill All Threads – Kill All User Session – Kill All Processes
SQL SERVER – 2008 – 2005 – Rebuild Every Index of All Tables of Database – Rebuild Index with FillFactor
SQL SERVER – 2008 – 2005 – Find Longest Running Query – TSQL – Part 2
SQL SERVER – Find Currently Running Query – T-SQL
SQL SERVER – How to Rename a Column Name or Table Name
SQL SERVER – UDF – Function to Convert Text String to Title Case – Proper Case – Part 2
SQL SERVER – Get Date Time in Any Format – UDF – User Defined Functions
SQL SERVER – 2000 – SQL SERVER – Delete Duplicate Records – Rows – Readers Contribution
SQL SERVER – Find Nth Highest Salary of Employee – Query to Retrieve the Nth Maximum value
SQL SERVER – 2005 – Find Nth Highest Record from Database Table – Using Ranking Function ROW_NUMBER
SQL SERVER – 2005 – A Simple Way To Defragment All Indexes In A Database That Is Fragmented Above A Declared Threshold
SQL SERVER – How to Retrieve TOP and BOTTOM Rows Together using T-SQL
SQL SERVER – Import CSV File Into SQL Server Using Bulk Insert – Load Comma Delimited File Into SQL Server
SQL SERVER – Three T-SQL Script to Create Primary Keys on Table
SQL SERVER – 2005 – Search Stored Procedure Code – Search Stored Procedure Text
SQL SERVER – Insert Data From One Table to Another Table – INSERT INTO SELECT – SELECT INTO TABLE
SQL SERVER – Count Duplicate Records – Rows
SQL SERVER – 2005 – List All Stored Procedure Modified in Last N Days
SQL SERVER – 2005 – UDF – User Defined Function to Strip HTML – Parse HTML – No Regular Expression
SQL SERVER – Retrieve – Select Only Date Part From DateTime – Best Practice
SQL SERVER – Insert Multiple Records Using One Insert Statement – Use of UNION ALL
SQL SERVER – Query to Find First and Last Day of Current Month
SQL SERVER – UDF – Function to Convert List to Table
SQL SERVER – Creating Comma Separate Values List from Table – UDF – SP
SQL SERVER – Random Number Generator Script – SQL Query
SQL SERVER – TRIM() Function – UDF TRIM()
SQL SERVER – Fix : Error : 40 – could not open a connection to SQL server.
SQL SERVER – UDF – User Defined Function to Extract Only Numbers From String
SQL SERVER – Query to find number Rows, Columns, ByteSize for each table in the current database – Find Biggest Table in Database 

No comments:

Post a Comment