Maintenance and Management

Technical Article

#sp_shrinkdata

  • Script

Unlike shrinking transaction log, shrinking a data file seems to be tough. A lot of people complained about the "shrink database" option in EM not working, or DBCC SHRINKDATABASE not working, or DBCC SHRINKFILE not working. I have found that a data file will eventually shrink given enough try, time and patience. I've put everything […]

You rated this post out of 5. Change rating

2003-01-14

402 reads

Technical Article

Inherriting objects from an updated MODEL database

  • Script

If new objects are created in the model database then these new objects only get created for new databases.Similarly, if objects are removed from user databases then getting them back into the database can be a pain.The following two stored procs copy objects from model to the current database if they do not already exist.

You rated this post out of 5. Change rating

2003-01-10

35 reads

Technical Article

Copying Backups using XP_CMDSHELL

  • Script

This script is designed to backup the database, and copy it over the network to our backup server.  The requirement for this particular database is 7 days of data kept on the LAN.  The share on the backup server is mapped to the Y:\ drive.  The datename function is used over the datepart function for […]

You rated this post out of 5. Change rating

2002-12-08

357 reads

Technical Article

Setting permissions (Updated: UDF's now set)

  • Script

Here is a script I wrote to automate updating of permission on a database. Often running as sa I forget to set the rights for objects when distributing db objects. It provides the capability to process only certain object types, and whether or not to print and execute the persmissions change or just print out […]

You rated this post out of 5. Change rating

2002-11-22

448 reads

Technical Article

Grant/Revoke EXEC permissions  for all procs in DB

  • Script

Useful in dev environments when you need to periodically assign execute permissions on all procs in a db (drop/create scripts may have been run without re-assigning permissions)Accepts DB name, ProcLike for matching 'starts with' pattern against proc names in DB, revoke (optional - defaults to 0/True) specifies wheter to GRANT or REVOKE permissions

You rated this post out of 5. Change rating

2002-11-21

392 reads

Technical Article

DBA_EverywhereRun

  • Script

Runs a SQL statement against each database based on a LIKE pattern for the name of the database.Features:* IsLike and IsNotLike parameters let you specify both a matching pattern and an exclusion pattern for the database name.* Script_Only mode generates the script of what the stored proc executes.  Especially useful for DDL statements.* List_Only mode […]

You rated this post out of 5. Change rating

2002-11-14

389 reads

Technical Article

sp_kill

  • Script

This stored proc has helped me a lot when I needed to restore db, reconfigure replication, and do other database jobs. SQL server KILL command can only act on a single spid. This sp compiles KILL commands in a cursor to kill a group of spids based on database name, login name, host machine name […]

You rated this post out of 5. Change rating

2002-11-11

5,761 reads

Blogs

How to find free space in Azure PosgreSQL

By

I wanted to figure out how big (or approximately how big) my dump file...

T-SQL Tuesday #180: Good enough is perfect Roundup

By

This month, I prompted bloggers to discuss whether good enough is perfect. Thank you to all...

Using SQL Compare with Read-only Access

By

Recently a customer asked if SQL Compare and SQL Data Compare can be used...

Read the latest Blogs

Forums

Announcing SQL Server 2025

By Steve Jones - SSC Editor

Comments posted to this topic are about the item Announcing SQL Server 2025

Running Steve's Code

By Steve Jones - SSC Editor

Comments posted to this topic are about the item Running Steve's Code

New SQL Server 2022 Functions

By Steve Jones - SSC Editor

Comments posted to this topic are about the item New SQL Server 2022 Functions

Visit the forum

Question of the Day

Running Steve's Code

Can you run this code in any of your SQL Server 2019 databases without error?

CREATE OR ALTER PROCEDURE [dbo].[StevesAmazingProc]
AS
    
        SELECT Consumer_ID ,
               Trend_Category ,
               Bit_Trace
        FROM    NewWorldDB.dbo.MarketTrend;
    
GO

See possible answers