BSQLDB(1)

πŸ’… bsqldb β€” the batch SQL script processor (a General Commands Manual classic, bestie)

okay so picture this: it's a General Commands Manual page, the utility is called bsqldb, and it is literally a batch SQL script processor that runs on DB-Library. she's iconic, she's efficient, and she's about to make your whole terminal pop off ✨


🌸 NAME 🌸

bsqldb β€” batch SQL script processor using DB-Library 🫢


πŸŽ€ SYNOPSIS πŸŽ€

bsqldb [-hqv] [-S servername] [-D database] [-U username] [-P password]
       [-i input_file] [-o output_file] [-e error_file] [-H hostname]
       [-t field_term] [-R pivot_description]

πŸ¦‹ DESCRIPTION πŸ¦‹

bsqldb is a utility program distributed with FreeTDS. she's the non-interactive equivalent of the "isql" utility programs distributed by Sybase and Microsoft β€” like, same energy, but she doesn't need you hovering over her asking questions πŸ’β€β™€οΈ

just like them, bsqldb uses the command go on a line by itself as a separator between batches. and here's the cute part: the last batch doesn't even need a go after it. she just knows. ✨

bsqldb makes use of the DB-Library API provided by FreeTDS. and this API is, of course, also available to application developers β€” so if you're out here building stuff, this is your moment, bestie πŸ’–


✨ OPTIONS ✨

  • -D database β€” the database to use. pick your girl πŸ’…
  • -H hostname β€” hostname overrides the name of the client that gets sent to the server. lowkey a glow-up for your identity ✨
  • -P password β€” the database server password πŸ”
  • -S servername β€” the database server to which to connect πŸ›°οΈ
  • -U username β€” the database server login name. and listen: if username is not provided, a domain login is attempted for TDS 7+ connections πŸ‘‘
  • -e error_file β€” name of the file for errors πŸ“
  • -h β€” print column headers with the data to the same file πŸ™Œ
  • -i input_file β€” name of the script file, containing SQL πŸ“œ
  • -o output_file β€” name of the output file, holding result data πŸ“¦
  • -q β€” do not print column metadata, return status, or rowcount. and heads up: this one overrides -h πŸ’€
  • -t field_term β€” specifies the field terminator. default is two spaces (' '). the recognized escape sequences are tab ('\t'), carriage return ('\r'), newline ('\n'), and backslash ('\\') πŸŽ€
  • -v β€” verbose mode, for more information about the DB-Library interaction. this also reports the result set metadata, including and return code. all verbose data are written to standard error (or -e), so as not to interfere with the data stream πŸ” (ngl, very considerate of her)
  • -R pivot_description β€” specify pivot trasformation. the format is ⟨down columns⟩ ⟨across columns⟩ ⟨function⟩ ⟨value⟩. columns are specified but numbers. the format of down columns and across columns is a comma separated list of columns. function is either count, sum, min or max πŸŒ€

🌈 ENVIRONMENT 🌈

  • DSQUERY β€” default servername 🏷️

πŸ’œ NOTES πŸ’œ

bsqldb is a filter; she reads from standard input, writes to standard output, and writes errors to standard error. the -i, -o, and -e options override these defaults. periodt. πŸ’…

the source code for bsqldb is intended as a model for DB-Library users. DB-Library has a rich set of functions, and it can be hard sometimes to understand how to use them, particularly the first time β€” and honestly? relatable. 😭 if you find something about the source code unclear, you are encouraged to email the author your comments. she wants the feedback, bestie 🫢


⭐ EXIT STATUS ⭐

bsqldb exits 0 on success, and >0 if the server cannot process the query. no cap.

for messages with severity > 10, bsqldb calls exit(3) with the severity level. like, for example, if the severity level is 16, bsqldb will return an exit status of 16 to the shell. yes she's dramatic about it, but she's precise πŸ”₯


πŸ•°οΈ HISTORY πŸ•°οΈ

bsqldb first appeared in FreeTDS 0.63. a legend from day one πŸ‘‘


🧚 AUTHORS 🧚

the bsqldb utility was written by James K. Lowden <jklowden@freetds.org>. thank you king πŸ™πŸ’–


πŸ’€ BUGS πŸ’€

Microsoft servers as of SQL Server 7.0 SP 3 do not return output parameters unless the RPC functions are used. this means bsqldb cannot return output parameters for stored procedures with these servers. like, she would if she could, but the server said no πŸ™ˆ


okay that's the whole page and you ate, fr fr πŸ“ this was FreeTDS 1.5.20, dated March 26, 2015, page BSQLDB(1) β€” mwah, go run some batches bestie πŸ’…βœ¨

πŸ“¦ where this page comes from