IF (@XXXId = -1) -- No Record Found, Insert
BEGIN
IF (@TransactionId IS NOT NULL)
BEGIN
SET @programBegins = GETDATE ()
SET @programEnds = dateadd (day, 90, @programBegins)
END
--Create/Update User Login & Contact Record if Needed
INSERT INTO @outputTable
EXEC CreateXXX @loginId,
@bypassUserCreation,
@className,
@sectionNumber,
@grade,
@year,
@isImport,
@programBegins,
@programEnds,
@emailInfo,
@excludeRankings,
@teamVendorId,
@VendorType,
@isPlaceHolder,
@docEntry,
@docNum,
@PONumber,
@BPCode,
@XXXTeamId OUTPUT
DECLARE @errorText AS NVARCHAR (100)
SET @errorText =
'An error occured Pushing record: '
+ cast (@teamVendorId AS NVARCHAR (50))
IF @@error <> 0
BEGIN
RAISERROR (@errorText, 1, 1)
RETURN
END
END
DECLARE @XXX TABLE
(
[rowNum] [int],
[RowId] [int],
[Id] [nvarchar] (50),
[XXXId] [nvarchar] (50),
[XXXId] [nvarchar] (50),
[LocalId] [nvarchar] (50),
[Name] [nvarchar] (100),
[Grade] [int],
[RowState] [tinyint],
[LastModified] [datetime],
[YYYId] [int],
[YYYName] [nvarchar] (50),
[State] [nvarchar] (30),
[Email] [nvarchar] (100),
[UserId] [nvarchar] (100),
[Password] [nvarchar] (25)
)
I want to disclaim that I am not a TSQL expert, and maybe there's a workaround for this particular issue. But these procs were written by someone who is, and there are so many issues like this (with intellisense, compile time type checking, debugging experience, refactoring tools, built in operators, things you can't do in a UDF, no function chaining syntax, insane parenthesis usage, insane CAST requirements, etc.) that my general feeling is that building a complex application in TSQL is a very perilous business, no matter how clever you are.