Hellos,
As I move slowly away from CSV to MS-SQL 2022, I would like to create a CHATGPT prompt similar to my python one to craft better queries .
What are some of the peculiar things to remember
Few Questions
1. Set NOCOUNT ON should be default when using transformations to update
2. When updating via Transformations , a single user query is preferred instead of separate ones for insert/udpate
insert into [items].[basecamp].[checklist_tasks] ("MasterTaskID","hr1_code","DueDate","bc_userid" ) values (?,?,?,? )
update [items].[basecamp].[checklist_tasks] SET "hr1_code"

,"bc_userid"

Where "MasterTaskID"

AND "DueDate"
TO below(where custom logic is being used)
MERGE [items].[basecamp].[checklist_tasks] AS target
USING (
VALUES (?, ?, ?, ?)
) AS source (MasterTaskID, hr1_code, DueDate, BC_UserID)
ON target.MasterTaskID = source.MasterTaskID
AND target.DueDate = source.DueDate
WHEN MATCHED
AND target.Status = 'Not Started'
AND (
ISNULL(target.hr1_code, '') <> ISNULL(source.hr1_code, '')
OR ISNULL(target.BC_UserID, -1) <> ISNULL(source.BC_UserID, -1)
)
THEN
UPDATE SET
hr1_code = source.hr1_code,
BC_UserID = source.BC_UserID,
Status = 'Not Started',
DateModified = GETDATE()
WHEN NOT MATCHED THEN
INSERT (MasterTaskID, hr1_code, DueDate, Status, DateCreated, BC_UserID)
VALUES (source.MasterTaskID, source.hr1_code, source.DueDate, 'Not Started', GETDATE(), source.BC_UserID);
n00b question
Is there a specific lingo preferred when updating ? source.MasterTaskID is how values are identified or we prefer ? ? approach all the time