Dear readers of our blog, we'd like to recommend you to visit the main page of our website, where you can learn about our product SQLS*Plus and its advantages.
 
SQLS*Plus - best SQL Server command line reporting and automation tool! SQLS*Plus is several orders of magnitude better than SQL Server sqlcmd and osql command line tools.
 

REQUEST COMPLIMENTARY SQLS*PLUS LICENCE

Enteros UpBeat offers a patented database performance management SaaS platform. It proactively identifies root causes of complex revenue-impacting database performance issues across a growing number of RDBMS, NoSQL, and deep/machine learning database platforms. We support Oracle, SQL Server, IBM DB2, MongoDB, Casandra, MySQL, Amazon Aurora, and other database systems.

Chapter 1: Register License, Startup Scripts and start working

2 July 2020

Chapter 1: Register License, Startup Scripts and start working

SQLS*Plus for SQL Server: Issue “sqlsplus.exe –r” command and paste your license token to register SQLS*Plus

SQLS*Plus for SQL Server - Register License

Startup Scripts

When SQLS*Plus starts, and after CONNECT commands, the two sql files are being executed:

  1. login.ssp – SQLS*Plus profile
  2. login.sql – User profile

The files may contain SQLS*Plus commands.

Connecting to database server

Database server connect command:

“connect username/password@server\instance:database”

When connecting from inside database session use \\ to prefix instance name:

“connect username/password@server\\instance:database”

Example:

D:\ >sqlsplus sa/password@192.168.1.160 -- Connect to SQL Server instance using database username andpassword
SQLS*Plus: Release 2.0.1.8 - Production on Tue Nov 1 17:07:45 2011

Copyright (c) 2010, 201x, Memfix. All rights reserved.

SQLS*Plus is free for an individual use and a commercial use on a single SQL Server
instance.

Please visit http://www.memfix.com or email support@memfix.com to purchase
required…
Connected to:

Microsoft SQL Server RTM, version 9.00.1399.06, Developer Edition (64-bit), current
database: tempdb

0:sa@192.168.1.160> show dbs; -- “show“ command (sqlsplus) to list all accessible databases

Database Name

AdventureWorks
BusinessServiceIISRepository

BusinessServiceRepository
CapacityPlanner
CompositeWebAppRepository
master
model
msdb
OrderProcessorForwardRepository
OrderProcessorRepository
StockTraderDB
StockTraderWebAppRepository
tempdb

0:sa@192.168.1.160> use AdventureWorks; --“use” command (SQL) to select database
0:sa@192.168.1.160> show db;
database is "AdventureWorks" -- “show“ command (sqlsplus) to show current database
0:sa@192.168.1.160>

Set default database for connection

1) Command line:

sqlsplus.exe sa/<pwd>@192.168.1.160:AdventureWorks

or

sqlsplus.exe sa/<pwd>@192.168.1.160\ SQLSERVER2008:AdventureWorks

2) SQLSDBNAME environment variable

SET SQLSDBNAME=AdventureWorks

3) SQLCMDDBNAME environment variable (sqlcmd variable)

SET SQLCMDDBNAME =AdventureWorks

Connecting with trusted connection / windows authentication

1) Connect from command line:

sqlsplus.exe –E

– connect to default local database instance

or

sqlsplus.exe -E@HOST\SQLSERVER2008

– connect to specified remote database instance

or

sqlsplus.exe -E@HOST\SQLSERVER2008: AdventureWorks

– connect to specified remote database instance and database

2) Connect from SQLS*Plus session

connect -E

connect -E@HOST\\SQLSERVER2008

connect -E@HOST\\SQLSERVER2008: AdventureWorks

Connecting with username or password that contains ‘@’

Unless password is entered interactively, prefix @ with \.

Example:

connect user/pass\@word@ HOST\\SQLSERVER2008

When connecting from inside database session use \\ to prefix @:

0:sa@server\SQLSERVER2008> connect user/pass\\@word@ HOST\\SQLSERVER2008

Start SQLS*Plus with no connection

Use “/nolog” to start SQLS*Plus without connecting to database

This option is useful if connect statement is in the script and for security reasons should not be
externalized in command line

For Example:

sqlsplus /nolog @t4

t4.sql:

connect sa/xxxx@prodsrvr1;

set pages 0;
use tempdb;
db;

define tbl = sys.objects;
select count(*) c1 from &tbl;
quit

Connectivity environmental variables

1) SQLSUSER / SQLCMDUSER
Default connect user

2) SQLSPASSWORD / SQLCMDPASSWORD
Default connect user password

3) SQLSSERVER / SQLCMDSERVER
Default SQL server host and instance

4) SQLSDBNAME / SQLCMDDBNAME
Default database to connect to

5) SQLSPATH / SQLPATH
Environment variables that specify search locations of the SQL scripts. SQLS*Plus searches for the SQL scripts, including “login.ssp” and “login.sql”, starting from the current directory and after that in the directories specified by SQLSPATH first and SQLPATH after it. SQLSPATH and SQLPATH is a semicolon separated list of
directories.

Batch execution of SQL Scripts

Make sure to use double slashes (“\\”) in the path, i.e “d:\\x1.sql”

You can call batch sql file as below:

sqlsplus.exe sa/<pwd>@192.168.1.160 @d:\\x1.sql

In this example we connect to default instance of SQL Server on a server and execute sql script
x1.sql.

or

sqlsplus.exe sa/<pwd>@192.168.1.160\SQLSERVER2008 @d:\\x1.sql

In second case we connect to specific instance (in case there are more than one)

Sample x1.sql content – includes “quit” command to insure that program quits after script execution

--
set pages 200
set lines 200
select * from master.dbo.sysprocesses;
quit

Execute script with no connectivity information on a command line

Use “/nolog” on SQLS*Plus command line and include “connect” command into the SQL script

For example:

sqlsplus.exe /nolog @x1.sql

Note: x1.sql contains connect command, i.e.:

”connect sa/<pwd>@192.168.1.160”

Multiple database sessions support

SQL> connect sa/xxxx@192.168.1.160 --Connect to database

Connected to:

Microsoft SQL Server RTM, version 9.00.1399.06, Developer
Edition (64-bit), current database: tempdb

0:sa@192.168.1.160>
0:sa@192.168.1.160>
0:sa@192.168.1.160> connect -l --List current sessions (1)
0 sa@192.168.1.160
0:sa@192.168.1.160> help --connect Help on “connect”

=====SessionMgr=====

connect - create a new session
disconnect - disconnect session nr

try help -v or <command> -h for detailed help.
0:sa@192.168.1.160> help -v connect --Detailed help on “connect”

=====SessionMgr=====

NAME
connect - create a new session

SYNOPSIS
connect <connectString>
alias: conn|c
-a create additional session, don't disconnect
-l list connections
-s sessNo switch to sessNo (as reported by -l)

DESCRIPTION
Connect creates a database session. You can have multiple
sessions at a time, which may save you some time, when you
need to switch sessions frequently.

The sqlsplus is useful when you run sqlsplus from within emacs
and you started it with a bad connect string.

NAME
disconnect - disconnect session nr

SYNOPSIS
disconnect <sessionNr>
alias: dis

try help -v or <command> -h for detailed help.
0:sa@192.168.1.160> connect -l --List current sessions (1)
0 sa@192.168.1.160
0:sa@192.168.1.160> connect -a sa/xxx@192.168.1.170 --Connect as additional session to new database

Connected to:

Microsoft SQL Server RTM, version 9.00.1399.06, Developer
Edition (64-bit), current database: tempdb1:sa@192.168.1.170> connect -l --List current sessions (2)
0 sa@192.168.1.160
1 sa@192.168.1.170
1:sa@192.168.1.170> connect -s 0 --Switch to session 0
0:sa@192.168.1.160> connect -s 1 --Switch back to session 1
1:sa@192.168.1.170> quit

Multi-line SQLS*Plus commands

The SQLS*Plus commands can span multiple lines, as long as dash “-‘ is used at the end of each
continuing line.

For example:

TITLE LEFT 'User Report' -
> RIGHT 'PAGE:' -
> SQL.PNO SKIP 2

Special data selection functionality

  • Vertical Output – allows to see large column sets as a vertical output “set vout on”
  • Table data “grep” – search for data across all columns
  • Data purge – purge table data in a small chunks

Download SQLS*Plus manual in PDF format


 
Tags: , , , , ,

MORE NEWS

 

Preamble​​NoSql is not a replacement for SQL databases but is a valid alternative for many situations where standard SQL is not the best approach for...

Preamble​​MongoDB Conditional operators specify a condition to which the value of the document field shall correspond.Comparison Query Operators $eq...

5 Database management trends impacting database administrationIn the realm of database management systems, moreover half (52%) of your competitors feel...

The data type is defined as the type of data that any column or variable can store in MS SQL Server. What is the data type? When you create any table or...

Preamble​​MS SQL Server is a client-server architecture. MS SQL Server process starts with the client application sending a query.SQL Server accepts,...

First the basics: what is the master/slave?One database server (“master”) responds and can do anything. A lot of other database servers store copies of all...

Preamble​​Atom Hopper (based on Apache Abdera) for those who may not know is an open-source project sponsored by Rackspace. Today we will figure out how to...

Preamble​​MongoDB recently introduced its new aggregation structure. This structure provides a simpler solution for calculating aggregated values rather...

FlexibilityOne of the most advertised features of MongoDB is its flexibility.  Flexibility, however, is a double-edged sword. More flexibility means more...

Preamble​​SQLShell is a cross-platform command-line tool for SQL, similar to psql for PostgreSQL or MySQL command-line tool for MySQL.Why use it?If you...

Preamble​​Writing an application on top of the framework on top of the driver on top of the database is a bit like a game on the phone: you say “insert...

Preamble​​Oracle Coherence is a distributed cache that is functionally comparable with Memcached. In addition to the basic function of the API cache, it...

Preamble​​IBM pureXML, a proprietary XML database built on a relational mechanism (designed for puns) that offers both relational ( SQL / XML ) and...

  What is PostgreSQL array? In PostgreSQL we can define a column as an array of valid data types. The data type can be built-in, custom or enumerated....

Preamble​​If you are a Linux sysadmin or developer, there comes a time when you need to manage an Oracle database that can work in your environment.In this...

Preamble​​Starting with Microsoft SQL Server 2008, by default, the group of local administrators is no longer added to SQL Server administrators during the...