sp_GetLastBackup
This will get the last date a database was backuped. It allows you to report this date on all databases on a server, or pass in a db name, and it'll report the date that db was last backed up
2002-03-07
442 reads
This will get the last date a database was backuped. It allows you to report this date on all databases on a server, or pass in a db name, and it'll report the date that db was last backed up
2002-03-07
442 reads
I use this SP to return full directory information into a table. FilePath, FileName, Filedate and FileSize are parsed from a 'dir /n/on/-c ' command. FilesInDir is the table created. usage: exec LoadFileDetailsIntoTable 'c:\winnt'select * from FilesInDir where filesize > 100000select min(fileDate) from FilesInDirThe Return Code will equal the number of files found.
2002-03-05
459 reads
spGetFieldsExists takes a tablename and a field name, and checks if that field exists in that table.It simply returns 0 or 1 (false or true).
2002-03-05
167 reads
spFindTableInfo is a great proc for finding info about your database. It will accept parameters like tablename, fieldname, size, datatype. So you can run it with no params, and it'll report every table, every field in those tables, and the size, datatype and whether its nullable or not. You can filter it by Table name […]
2002-03-05
378 reads
spDropField does exactly the opposite of spAddField. It checks for existence, then drops it, if it does exist.
2002-03-05
137 reads
spAddField is the proc I use to add all fields to the db in our upgrade scripts. With this proc, you pass it the tablename, fieldname, datatype, and null or not null. This will call spGetFieldsExists and see if the fields exists or not. If it does, spAddField will drop that column. Then it readds […]
2002-03-05
217 reads
Pass a datetime value and receive back a formatted string. Much like the Format$ function in Visual Basic.I put this together to provide a date string to add to filename. Also handy when you are creating text files that require datetime data to be output in weird character formats like yyddmm or yyyymm.eg: fnDate2Char(GetDate(), 'dmy', […]
2002-02-27
822 reads
Andy read this book recently and gave it a great review. Even though it's not a SQL book! Seriously, take a look at the review. It's a good book that is fun to read.
2002-02-26
3,270 reads
This script is very helpful for anyone trying to recreate particular SQL Server Database Versions for Testing. It allows you to automatically recompile any stored procedures or views saved with drop, create and permission statements. The scripts must all be sitting in one directory and end in the same extension. I have found this very […]
2002-02-25
684 reads
This stored procedure detaches and re-attaches a database without specifying a filename for the transaction log. This causes SQL Server to create log file with default size of 512kb.After playing around with SHRINKDATABASE, SHRINKFILE, forcing the virtual log to wrap around, etc... I found this was the quickest and most reliable method of reclaiming the […]
2002-02-25
2,607 reads
I wanted to figure out how big (or approximately how big) my dump file...
This month, I prompted bloggers to discuss whether good enough is perfect. Thank you to all...
By Steve Jones
Recently a customer asked if SQL Compare and SQL Data Compare can be used...
Comments posted to this topic are about the item Announcing SQL Server 2025
Comments posted to this topic are about the item Running Steve's Code
Comments posted to this topic are about the item New SQL Server 2022 Functions
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; GOSee possible answers