Script to check whats hogging the system
This script takes 2 samples over a 10 second period to identify what spids are using most resources. It's probably not 100% accurate but it's helped me out a few times.
2003-05-15
530 reads
This script takes 2 samples over a 10 second period to identify what spids are using most resources. It's probably not 100% accurate but it's helped me out a few times.
2003-05-15
530 reads
If you have environment where you restrict access to database objects based on user roles and if you have a lot of databases on different servers in the same domain. The following script can generate roles from a given database in a format that can be used to create roles on different servers where the […]
2003-05-14
210 reads
Mod to Find the Nth Occurence of a characterFixes when you are looking for the third character and there is only one, was setting @pos back to 0 if there was only 1 of the characters. Also provided for the @occurence to be 0.
2003-05-13
394 reads
This script identifies the blocking locks at the top of the blocking chain and kills them. Specifically, it reports what the top blocking spids are doing, kills them, waits three seconds and then reports on current blocking status. If you have a situation where single connections are causing a huge blocking chain and you want […]
2003-05-12
4,506 reads
This is a followup to the script submitted by srallapalli. One can return a record set of all tables in a database using the following:USE MyDatabaseSELECT so.name AS TableName, sc.name AS ColumnName, st.name AS ColumnDatatype, convert(int, sc.length) AS ColumnLength FROM syscolumns sc, sysobjects so , systypes st WHERE so.type='U' AND OBJECTPROPERTY(so.id,'ismsshipped') = 0 AND sc.id=so.id […]
2003-05-10
172 reads
In instances where you have over 16 data files, or you need to move data files to a new location when you are moving a database you must use a CREATE...FOR ATTACH statement. This script will generate the CREATE...FOR ATTACH statement dynamically given a database name. It will take into consideration the file sizes, growths […]
2003-05-07
249 reads
For each user database rebuild indexes, update statistics and shrink. The script will use the system catalog to produce a list of databases. If you want to excluce a database add the excluded db name to the 'not in' list. You can also adjust the target fillfactor.
2003-05-07
1,882 reads
This set of procedures allow you to control simultaneous access to any resource you are using. It mimics the behaviour of a Semaphore in programming.A typical problem where you need this, is when you have a computational intensive procedure you only want to be started a limited number of times.First, add a record to the […]
2003-05-07
301 reads
This script enables you to return data from SQL Server's table without specyfing the name of the column .All you only need to supply is the column number, that you want the data from. In the example we want to chose all rows from the second column (categories table - northwind) Column number is based […]
2003-05-07
189 reads
For each user database remove all the freespace and truncate the transaction log. The script will use the system catalog to produce a list of databases. If you want to excluce a database add the excluded db name to the 'not in' list below.
2003-05-07
1,581 reads
By Steve Jones
It’s time for T-SQL Tuesday again and this is a great prompt to start...
By alevyinroc
T-SQL Tuesday is a monthly blog party hosted by a different community member each...
How I used AI for this postChatGPT to generate images based on info specifically...
Comments posted to this topic are about the item Databricks Genie Spaces for SQL...
Comments posted to this topic are about the item The Costs of Multiple Platforms
Comments posted to this topic are about the item RegEx Functions II
I have this data in a table in a SQL Server 2025 database:
EmailAddressID EmailAddress 7 dylan0@ADVENTURE-WORKS.COM 8 Diane1@ADVENTURE-WORKS.COMIf I run this query, which row(s) are returned?
SELECT top 10 * FROM person.EmailAddress WHERE REGEXP_LIKE(EmailAddress, '^d') AND BusinessEntityID IN (7,8)See possible answers