SQL Server Exec

Description

The SQL Server Exec component allows you to execute SQL statements against SQL Server to update/delete data.
It is compatible with SQL Server 2005 and above.

mssql2-en

Output Payload








Output PayloadDescription
cv.PayloadIn addition to the input payload, it passes LastInsertId or RowsAffected by the executed SQL statement

LastInsertId is returned when the executed SQL statement was an INSERT statement and the ID generated by the DB could be obtained.
RowsAffected returns the number of records affected by the executed SQL statement. For example, it returns the number of rows deleted when the statement was a DELETE statement.

Component Properties






Property NameDescription
SQLSpecifies the SQL statement to execute
Bulk ModeChoose whether to use bulk mode in executing the SQL statement
Bulk SizeSpecifies the size when using bulk mode
HostSpecifies the host of SQL Server
PortSpecifies the port of SQL Server
UsernameSpecifies the username of SQL Server
PasswordSpecifies the password of SQL Server
DatabaseSpecifies the database
EncryptSpecifies whether to disable encryption (not connect with SSL/TLS), true (connect with SSL/TLS), or false (encrypt login only)
TrustServerCertificateSelect whether to trust the SQL Server's server certificate. If on, it trusts the certificate sent by SQL Server. If off, it verifies the SQL Server certificate against the trust store certificate
Root CertificateSpecifies the root certificate to use. If using AWS's Aurora or RDS, you will need to use the server certificate issued by AWS. This will be the root certificate of that server certificate

Placeholders

You must use placeholders in the SQL statement to be executed and use the value of cv.Playload in the SQL statement.

UPDATE table1 SET name='Updated name' WHERE id=?

The value of cv.Payload is used for the placeholder specified by ?. When cv.Payload contains 1, it updates the record where id is 1.
You can specify more than one placeholder.

UPDATE table1 SET name=? WHERE id=?

To specify values for more than one placeholder, specify the values in an array in cv.Payload.

["First Last", 20]

Text2SQL

Text2SQL is a function that can generate SQL statements from Japanese entered into the prompt using the functionality of OpenAI's ChatGPT.
For how to use it, please refer to the Text2SQL Usage Guide in the Setup Guide.