I had the following declaration:
DECLARE @orderGUID VARCHAR(50) = NEWID(),
@deliveryId VARCHAR(50) = NEWID(),
@orderChildGUID VARCHAR(50) = NEWID(),
@deliveryIdChild VARCHAR(50) = NEWID(),
@triggerFileName VARCHAR(50) = 'trigger_[X].txt',
@triggerTime TIME = GETDATE(),
@triggerDate DATE = GETDATE(),
@dateTimeText CHAR(17) = rfa.dbo.FormatDate(@triggerDate, 'YYYYMMDD')
+ LEFT(REPLACE(REPLACE(@triggerTime,':',''),'.',''),9);
Which gives the following error: Must declare the scalar variable "@triggerDate"
I tried this and it works but just doesn't seem as nice:
DECLARE @triggerTime TIME = GETDATE(),
@triggerDate DATE = GETDATE();
DECLARE @orderGUID VARCHAR(50) = NEWID(),
@deliveryId VARCHAR(50) = NEWID(),
@orderChildGUID VARCHAR(50) = NEWID(),
@deliveryIdChild VARCHAR(50) = NEWID(),
@triggerFileName VARCHAR(50) = 'trigger_[X].txt',
@dateTimeText CHAR(17) = rfa.dbo.FormatDate(@triggerDate, 'YYYYMMDD')
+ LEFT(REPLACE(REPLACE(@triggerTime,':',''),'.',''),9);
Is it possible to do this with only one declaration?
VARCHAR(50)??? Why not use the proper datatype ofUNIQUEIDENTIFIER?????