Clinton Herring

Format a DOS date as yyyymmdd

Do you run jobs that call BAT files where you wish you could include a formatted date stamp in the output name of an OSQL file? Well, you can using the DOS 'FOR' command. I named a variable FILEDATE and use it as: path\Filename_%FILEDATE%.txt (Note: A BAT file requires double %% in the 'FOR' command […]

4.5 (2)


1,070 reads


This stored procedure does a quick table comparison between 2 databases that are supposed to be the same. Tables found on either db but missing from the other are reported as are record count differences for matching tables. Establish a linked-server with appropriate permissions to compare across servers. Compile in master.


114 reads


Returns database user information as a runnable script for the specified database. The default is master. Great for restoring user access and permissions after a restore to a development server. Run prior to the restore and save the output to an sql file.


1,016 reads

Find and replace column constraints

I submit this script as an example of how one might go about generating 'Alter Table' statements that find and replace specific column constraints. In my case I had to find all occurrences in a production db of suser_name() as a column constraint and replace it with suser_sname(). This script is only an example and […]


223 reads


An update to sp_spaceused2. This update fixes some problems related to dbs that are non-accessible such being offline. This stored proc can be run from any database when compiled in master and can report information on all databases at once. Get information on all dbs, one db, one db and all its tables or one […]


273 reads


Backup your SQL instances configurations to GIT with dbatools – Part 2 – Add parallelism


We have seen how we can export and save the results to a folder...

Data Visualization, Context, and Domain Expertise


I recently posted a graph to twitter and asked people to explain it. Let’s...

Approaches to running Databricks ETL code from Azure ADF


Databricks is fantastic, but there is a small issue with how people use it....

Read the latest Blogs


Worker Threads Per Session

By alex.sqldba

Morning All, Is it possible to determine how many threads are spawned by a...

Is it acceptable to use the presence of a value in a NULLable column as a flag?

By edwardwill

I have a stored procedure that processes rows in a table. The stored procedure...

Invalid object name OPENJSON


I have an Express edition of SQL 2019 Microsoft SQL Server 2019 (RTM-GDR) (KB4517790)...

Visit the forum


SQL Server Q&A from the SQLServerCentral community

Get answers

Question of the Day

Minus Query

See possible answers