SQL Options

SQL Options

/[commands=]insert|update|delete|merge

Use this option to specify generated commands in the make and import modes.

For example:

gsqlcmd make yahoo.db 1min-aapl.csv *-insert.sql /insert /table=yahoo1min /echoOutputFileName
gsqlcmd make yahoo.db 1min-aapl.csv *-update.sql /update /table=yahoo1min /echoOutputFileName
gsqlcmd make yahoo.db 1min-aapl.csv *-delete.sql /delete /table=yahoo1min /echoOutputFileName
gsqlcmd make yahoo.db 1min-aapl.csv *-merge.sql  /merge  /table=yahoo1min /echoOutputFileName

The default option is /insert.

Use the /insert option (or omit it) to generate commands to execute stored procedures or custom code.

For example:

gsqlcmd make yahoo.db 1min-aapl.csv *-custom.sql /insert /table=custom-code.sql /echoOutputFileName

Note, you may define columns used in the WHERE clause using the keys option like

gsqlcmd make yahoo.db 1min-aapl.csv *-insert.sql /insert /table=yahoo1min /echoOutputFileName
gsqlcmd make yahoo.db 1min-aapl.csv *-update.sql /update /table=yahoo1min /echoOutputFileName /keys=symbol,time
gsqlcmd make yahoo.db 1min-aapl.csv *-delete.sql /delete /table=yahoo1min /echoOutputFileName /keys=symbol,time
gsqlcmd make yahoo.db 1min-aapl.csv *-merge.sql  /merge  /table=yahoo1min /echoOutputFileName /keys=symbol,time

/groupSize=<number of rows>

Use this option to define a number of rows separated by the GO batch separator.

/insertIdentity

Use this option to include identity columns into INSERT and MERGE commands generated in the make and import modes.

/insertNulls

Use this option to keep NULL values in INSERT commands generated in the make and import modes.

/keys=<field>[;...]

Use this option to define primary key fields in the make-create mode.

For example:

gsqlcmd make-create data.csv create-table.sql /table=dbo.data /mssql /keys=FirstName,LastName

Also, use this option to define fields to use in the WHERE clause of generated UPDATE and DELETE commands in the make and import modes.

For example, you may use this option to synchronize data between different databases using fields like email or SSN instead of primary key fields.

For example:

gsqlcmd make db emails.csv merge.sql /merge /table=dbo.emails /keys=email

/table=<table|view|stored procedure|SQL template file>

Use this option to define the target database table, view, stored procedure, or SQL template file for code generation.

For example:

gsqlcmd make db data.csv insert.sql /insert /table=dbo.payments

This option is obligatory in the import, make, and make-create modes.

This website is using cookies. By continuing to browse, you give us your consent to our use of cookies as explained in our Cookie Policy.