This seemed like a straight-forward issue, and it was, after I straightened out the curves. I had a simple logging mechanism, a SQL stored procedure something like this:
CREATE PROCEDURE [dbo].[LogError] @Message VARCHAR(500) , @Id UNIQUEIDENTIFIER AS INSERT INTO ErrorLog (Message, Id) VALUES (@Message, @Id)
And in a calling stored procedure:
EXEC LogError 'An invalid response was returned.', NEWID
Both stored procedures compiled just fine. However, when I attempted to log the message, I got the error
Error converting data type varchar to uniqueidentifier.
It turns out that just because my SP compiled fine didn’t mean it was actually going to work. Just using “NEWID” wasn’t enough. Instead, I had to modify my logging function to use a variable of type UNIQUEIDENTIFIER, like so:
DECLARE @NewId UNIQUEIDENTIFIER SET @NewId = NEWID() EXEC LogError 'An invalid response was returned.', @NewId