I have some tSQLt tests which are using magic numbers for some static data IDs and I'm trying to make them more self documenting by using a function.
Currently I'm using this but it's a bit more wordy than I would like and was hoping there was a short form method I could use without the extra brackets around the function. I know I could do this more efficiently by declaring the Ids as variables but as this is for tests my priority is more on the readability/self-documenting side.
INSERT INTO dbo.tAccessProfileAreaRight (id, AccessProfileId, AccessAreaRightId)
VALUES (1, 1, (SELECT dbo.GetAccessAreaRightId('Purchase Orders', 'Authorise'))),
(2, 1, (SELECT dbo.GetAccessAreaRightId('Purchase Invoices', 'Authorise'))),
You could do an Insert Into with a Select.
Also you don't have to specify the columns for the INSERT INTO if the select columns match the table columns exactly.