Help me craft a SQL chatgpt prompt for AETL

More
10 months 3 weeks ago - 10 months 3 weeks ago #25766 by prashant
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 
Last edit: 10 months 3 weeks ago by prashant.

Please Log in or Create an account to join the conversation.

More
10 months 3 weeks ago #25767 by Peter.Jonson
A very important point is missing.

Into which object do you insert your SQL?

Screenshot?

Peter Jonson
ETL Developer

Please Log in or Create an account to join the conversation.

More
10 months 3 weeks ago #25768 by prashant
SQL 2022 using transformation ?

different prompt for different places ? like Calculations script vs packages script

Please Log in or Create an account to join the conversation.

More
10 months 3 weeks ago #25770 by Peter.Jonson
1 You can insert it there Use User Defined SQL

www.etl-tools.com/wiki/advanced-etl-proc...pdatedelete-records/

or there sql script

2 www.etl-tools.com/wiki/advanced-etl-proc...s/sql-script-action/

For the first one you must use "?" (it is odbc style syntax)

For the second one it depends on the data base you are working with 

Peter Jonson
ETL Developer

Please Log in or Create an account to join the conversation.

More
10 months 3 weeks ago #25798 by prashant
Hellos,
I am out for 9 days for an intense meditation camp. Will explore this prompt once back :) 

Please Log in or Create an account to join the conversation.

Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Marketing
Set of techniques which have for object the commercial strategy and in particular the market study.
Google
Accept
Decline
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Google Analytics
Accept
Decline
Functional
Tools used to give you more features when navigating on the website, this can include social sharing.
Advertisement
If you accept, the ads on the page will be adapted to your preferences.
Google Ad
Accept
Decline
Save