I have this which works fine:
var firstName = "Greg";
var ipAddress = "0.0.0.0";
var sql = @$"sp_create_enrollment @first_name = '{firstName}',
@ip_address = '{ipAddress}'";
Console.WriteLine(sql);
This produces:
sp_create_enrollment @first_name = 'Greg', @ip_address = '0.0.0.0'
However, if ip_address is null, I need it to produce this:
sp_create_enrollment @first_name = 'Greg', @ip_address = null
Note that there are no quotes around the null, otherwise it gets passed as a string.
How do I achieve that?