library for work with Microsoft SQL Server
(license MIT) library for work with Microsoft SQL Server, full example - see example.js
type_exec_table_resultArray.<number>functionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunctionKind: global class
* Server_mssql
* .connected : boolean
* .timezone_offset : number
* .init(connection_config, callback)
* [.exec(queries, [options], callback)](#Server_mssql+exec)
* ~exec_result
* .action_add(action) ⇒ string
* .action_del(key)
* .action_check(key) ⇒ type\_action\_find
* .action_exec(key, params, callback)
* .schedule_go(job)
* .schedule_delete(job_key)
* .get_newid(callback)
* [.date_in_sql([d])](#Server_mssql+date_in_sql) ⇒ Date
Server\_mssql Server\_mssql Kind: instance method of Server\_mssql
| Param | Type | Description |
| --- | --- | --- |
| connection_config | type\_connection\_config | connection setting |
| callback | callback\_error | |
Kind: instance method of Server\_mssql
| Param | Type | Description |
| --- | --- | --- |
| queries | string \| Array.<string> | query or array of queries (for run on one open connection) |
| [options] | type\_exec\_option | |
| callback | callback\_exec | |
#### exec~exec\_result
Kind: inner property of exec
Privare: @type {type_exec_result}
Kind: instance method of Server\_mssql
Returns: string - error that prevented load action
| Param | Type | Description |
| --- | --- | --- |
| action | type\_action | single action |
Kind: instance method of Server\_mssql
| Param | Type | Description |
| --- | --- | --- |
| key | string | action key |
Kind: instance method of Server\_mssql
| Param | Type | Description |
| --- | --- | --- |
| key | string | action key |
Kind: instance method of Server\_mssql
| Param | Type | Description |
| --- | --- | --- |
| key | string | uniq key of action |
| params | any | |
| callback | callback\_action | |
Kind: instance method of Server\_mssql
| Param | Type |
| --- | --- |
| job | lib\_vschedule.type\_job |
Kind: instance method of Server\_mssql
| Param | Type |
| --- | --- |
| job_key | string |
Kind: instance method of Server\_mssql
| Param | Type | Description |
| --- | --- | --- |
| callback | callback\_get\_newid | error, guid |
Kind: instance method of Server\_mssql
| Param | Type | Description |
| --- | --- | --- |
| [d] | Date | local date regarding which to get the date on the server, default - now |
type\_exec\_table\_result| Param | Type |
| --- | --- |
| from | type\_exec\_table\_result |
| Param | Type |
| --- | --- |
| table | type\_exec\_table\_result |
| type_ext | boolean |
Array.<number>| Param | Type |
| --- | --- |
| nums | Array.<number> |
| Name | Type | Description |
| --- | --- | --- |
| server | string | MS SQL instance, for example - 'server\\instance1' |
| password | string | passrord for ms sql authentication or windows authentication |
| [login] | string | login for ms sql authentication, if empty - os authentication |
| database | string | name database for connect, default - 'tempdb' |
| [app_name] | string | app name, which will be visible in profiler |
| [connection_timeout] | number | connection timeout in milliseconds, default - 15000 |
| [execution_timeout] | number | execution timeout in milliseconds, default - 0 (infinity) |
| [encrypt_connection] | boolean | encrypt connection, default - false |
| [useUTC] | boolean | default - true |
| [action_allow] | boolean | use action subsystem, default - false |
| [again_connect_count] | number | count to try to connect to the server if the connection is unavailable, default - 0 (again try connect is disabled) |
| [again_connect_timeout] | number | timeout in milliseconds between attempts to connect to the server, default - 2000 |
| Name | Type | Description |
| --- | --- | --- |
| key | string | action uniq key |
| sql_script | string | |
| [sql_param] | string | |
| [sql_param_note] | string | |
| [sql_result] | string | |
| [sql_lock] | string | one thread - name |
| [sql_lock_wait] | number | one thread - wait timeout in milliseconds (0 - no wait), default 0 |
| [sql_lock_message] | string | one thread - message if lock exists |
| [js_script] | string | |
| title | string | action title |
| [note] | string | action title |
| [keys_next] | string | exec this actions after exec this action, example - 'key1;key2' |
| [correction_utc_mode] | string | |
| [extented_property] | Object | |
| Name | Type |
| --- | --- |
| [action_class_template] | string |
| [class_name] | string |
functionfunction| Param | Type |
| --- | --- |
| error | Error |
| Name | Type | Description |
| --- | --- | --- |
| [correction_utc] | type\_exec\_correction\_utc\_option | |
| [lock] | type\_exec\_lock\_option | one thread subsystem |
| [noname_row_beautify] | boolean | default - false |
| [chunk_rows] | number | return result by chunk, default - off (undefined) |
| [chunk_msec] | number | return result by chunk, default - off (undefined) |
| [check_database_after_exec] | boolean | return database name, which is active at the time the script is finished, default - false |
| [check_spid] | boolean | return spid, for (example) kill process, default - false |
| [check_print] | boolean | return PRINT and RAISERROR, default - false |
| [type_ext] | boolean | create properties "type_name", "type_title", "type_charlen" in schema |
| Name | Type |
| --- | --- |
| [key] | string |
| [wait] | number |
| [message] | string |
| Name | Type |
| --- | --- |
| [key] | string |
| [wait] | number |
| [message] | string |
| allow | boolean |
| Name | Type | Description |
| --- | --- | --- |
| [offset] | number | correct field with datetime type by this value (in minutes) |
| [mode] | string | which fields correct by utc offset, example - '{#all}{}{fdm;ldm}' - in first table correct all datetime fields, second table is missing, in the third table correct only two fields |
| Name | Type | Description |
| --- | --- | --- |
| [offset] | number | correct field with datetime type by this value (in minutes) |
| [mode] | string | which fields correct by utc offset, example - '{#all}{}{fdm;ldm}' - in first table correct all datetime fields, second table is missing, in the third table correct only two fields |
| Name | Type |
| --- | --- |
| step | number |
| error | Error |
| point | 'connect' \| 'sql' \| 'kill' \| 'action' |
| Name | Type |
| --- | --- |
| [lock_on] | string |
| [lock_off] | string |
| queue | Array.<string> |
| [name_server] | string |
| [name_database] | string |
| [name_database_after_exec] | string |
| [spid] | number |
| [spguid] | string |
| get_plain_query | function |
| Name | Type |
| --- | --- |
| schema | Object |
| step | number |
| table_index | number |
| rows | Array.<Object> |
function| Param | Type |
| --- | --- |
| error | Error |
| xml | string |
function| Param | Type | Description |
| --- | --- | --- |
| [full_file_name] | string | //if empty, see xml as a string in callback |
| table_name_list | Array.<string> | |
| callback | function\_tables\_to\_xml\_file1 | |
| Name | Type |
| --- | --- |
| perfomance_exec_before | number |
| perfomance_exec_after | number |
| duration_exec_millisecond | Array.<number> |
| Name | Type |
| --- | --- |
| handle_error | type\_exec\_error\_result |
| [lock] | type\_exec\_lock\_result |
| [script] | type\_exec\_script\_result |
| [correction_utc] | type\_exec\_correction\_utc\_result |
| performance | type\_performance |
| [tables] | Array.<type\_exec\_table\_result> |
| [tables_to_xml] | function\_tables\_to\_xml\_file2 |
| Name | Type |
| --- | --- |
| type | 'spid' \| 'print' \| 'table' |
| [spid] | type\_exec\_spid |
| [print] | type\_exec\_print |
| [table] | type\_exec\_table\_result |
| Name | Type |
| --- | --- |
| spguid | string |
| spid | number |
| exists | boolean |
| killed | boolean |
| Name | Type |
| --- | --- |
| message | string |
| procname | string |
| is_error | boolean |
function| Param | Type |
| --- | --- |
| error | Object |
function| Param | Type |
| --- | --- |
| result | type\_exec\_result |
| runtime | type\_exec\_runtime |
function| Param | Type |
| --- | --- |
| runtime | type\_exec\_runtime |
function| Param | Type |
| --- | --- |
| print | type\_exec\_print |
function| Param | Type |
| --- | --- |
| table | type\_exec\_table\_result |
function| Param | Type |
| --- | --- |
| result | type\_exec\_result |
| named_tables | Array.<Object> |
| warning | Array.<string> |
function| Param | Type |
| --- | --- |
| error | Error |
| connection_pool | lib\_sql.ConnectionPool |
function| Param | Type |
| --- | --- |
| error | Error |
| connection_pool | lib\_sql.Request |
| Name | Type |
| --- | --- |
| key | string |
| title | string |
| sql_result_list | Array.<string> |
| note | string |
| error_list | Array.<string> |
function| Param | Type |
| --- | --- |
| error | Error |
| guid | string |