Custom values for VALUES clause
I write a LOT of unit tests, usually at the rate of 15:1 to 20:1 to my executing code. I have these standardized and templated to make them easier and more consistent to build. e.g. @GUID UNIQUEIDENTIFIER = NEWID(),
@Char CHAR(1) = 'A',
@Int INT = 1,
@Datetime DATETIME = CURRENTTIMESTAMP,
@Decimal DECIMAL(18,10) = 1.0,
@Date DATE = CURRENTTIMESTAMP,
@Time TIME = CURRENT_TIMESTAMP,
@Bit BIT = 1,
@Money MONEY = 1.00,
@Binary VARBINARY(18) = 0x01,
These go into my VALUES clause for INSERT statements, but I current have to do all of this manually, which takes a LOT of time when you're writing several thousand of these every single week. What I'd like to do is configure SQL Prompt to use my custom set instead of default values when it generates an INSERT statement.
So instead of seeing:
VALUES (0, -- ID - int
N'' , -- Code - nvarchar(256)
SYSDATETIME(), -- CreatedUTC - datetime2(7)
NULL, -- RowVersion - varbinary(18)
I'd like to see
VALUES (@Int, -- ID - int
@Char, -- Code - nvarchar(256)
@Datetime, -- CreatedUTC - datetime2(7)
@Binary, -- RowVersion - varbinary(18)
-
Jeff Humphreys commented
That took me a minute to figure out what you wanted. Maybe better test variable names: @TestChar10, @Test003DateTime, @TestMinLegalDate.
Unit Testing is a complex generation.