Friday, January 29, 2016

SQLCMD vs. Oracle SqlPlus (Microsoft Vs Oracle)

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

CONNECT TO DATABASE
Microsoft SqlCmd

===========================
1. TO CONNECT TO DATABASE
===========================

C:\Users\petera>SQLCMD -S GBI-7696M12\SQLSERVER12 -d master -E

===============
2. TO Check memory
===============

1> SELECT [total_physical_memory_kb] FROM [sys].[dm_os_sys_memory];
2> go
total_physical_memory_kb
------------------------
                16715020

(1 rows affected)
1> exit

===========
3.TO Get help
===========

C:\Users\petera>sqlcmd -?
Microsoft (R) SQL Server Command Line Tool
Version 11.0.2100.60 NT x64
Copyright (c) 2012 Microsoft. All rights reserved.

usage: Sqlcmd            [-U login id]          [-P password]
  [-S server]            [-H hostname]          [-E trusted connection]
  [-N Encrypt Connection][-C Trust Server Certificate]
  [-d use database name] [-l login timeout]     [-t query timeout]
  [-h headers]           [-s colseparator]      [-w screen width]
  [-a packetsize]        [-e echo input]        [-I Enable Quoted Identifiers]
  [-c cmdend]            [-L[c] list servers[clean output]]
  [-q "cmdline query"]   [-Q "cmdline query" and exit]
  [-m errorlevel]        [-V severitylevel]     [-W remove trailing spaces]
  [-u unicode output]    [-r[0|1] msgs to stderr]
  [-i inputfile]         [-o outputfile]        [-z new password]
  [-f <codepage> | i:<codepage>[,o:<codepage>]] [-Z new password and exit]
  [-k[1|2] remove[replace] control characters]
  [-y variable length type display width]
  [-Y fixed length type display width]
  [-p[1] print statistics[colon format]]
  [-R use client regional setting]
  [-K application intent]
  [-M multisubnet failover]
  [-b On error batch abort]
  [-v var = "value"...]  [-A dedicated admin connection]
  [-X[1] disable commands, startup script, environment variables [and exit]]
  [-x disable variable substitution]
  [-? show syntax summary]

=======================
4. TO show active databases
=======================




=============================================

Oracle sqlplus
=====================================================


===========================
1. TO CONNECT TO DATABASE
===========================

C:\Users\petera>sqlplus / as sysdba
OR
C:\Users\petera>sqlplus /nolog

SQL*Plus: Release 12.1.0.2.0 Production on Fri Jan 29 15:56:39 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

SQL> conn sys@orcl as sysdba
Enter password:
Connected.


===============
2. TO Check memory
===============

SQL> select * from V$sga;

NAME                      VALUE     CON_ID
-------------------- ---------- ----------
Fixed Size              3842760          0
Variable Size         989859128          0
Database Buffers     4143972352          0
Redo Buffers           12931072          0

SQL>

===========
3.TO Get help
===========


C:\Users\petera>sqlplus /?

SQL*Plus: Release 12.1.0.2.0 Production on Fri Jan 29 16:22:08 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


SQL*Plus: Release 12.1.0.2.0 Production

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Use SQL*Plus to execute SQL, PL/SQL and SQL*Plus statements.

Usage 1: sqlplus -H | -V

    -H             Displays the SQL*Plus version and the
                   usage help.
    -V             Displays the SQL*Plus version.

Usage 2: sqlplus [ [<option>] [{logon | /nolog}] [<start>] ]

  <option> is: [-C <version>] [-L] [-M "<options>"] [-NOLOGINTIME] [-R <level>]
               [-S]

    -C <version>   Sets the compatibility of affected commands to the
                   version specified by <version>.  The version has
                   the form "x.y[.z]".  For example, -C 10.2.0
    -L             Attempts to log on just once, instead of
                   reprompting on error.
    -M "<options>" Sets automatic HTML markup of output.  The options
                   have the form:
                   HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text]
                   [ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]
    -NOLOGINTIME   Don't display Last Successful Login Time.
    -R <level>     Sets restricted mode to disable SQL*Plus commands
                   that interact with the file system.  The level can
                   be 1, 2 or 3.  The most restrictive is -R 3 which
                   disables all user commands interacting with the
                   file system.
    -S             Sets silent mode which suppresses the display of
                   the SQL*Plus banner, prompts, and echoing of
                   commands.

  <logon> is: {<username>[/<password>][@<connect_identifier>] | / }
              [AS {SYSDBA | SYSOPER | SYSASM | SYSBACKUP | SYSDG | SYSKM}] [EDIT
ION=value]

    Specifies the database account username, password and connect
    identifier for the database connection.  Without a connect
    identifier, SQL*Plus connects to the default database.

    The AS SYSDBA, AS SYSOPER, AS SYSASM, AS SYSBACKUP, AS SYSDG,
    and AS SYSKM options are database administration privileges.

    <connect_identifier> can be in the form of Net Service Name
    or Easy Connect.

      @[<net_service_name> | [//]Host[:Port]/<service_name>]

        <net_service_name> is a simple name for a service that resolves
        to a connect descriptor.

        Example: Connect to database using Net Service Name and the
                 database net service name is ORCL.

           sqlplus myusername/mypassword@ORCL

        Host specifies the host name or IP address of the database
        server computer.

        Port specifies the listening port on the database server.

        <service_name> specifies the service name of the database you
        want to access.

        Example: Connect to database using Easy Connect and the
                 Service name is ORCL.

           sqlplus myusername/mypassword@Host/ORCL

    The /NOLOG option starts SQL*Plus without connecting to a
    database.

    The EDITION specifies the value for Session Edition.


  <start> is: @<URL>|<filename>[.<ext>] [<parameter> ...]

    Runs the specified SQL*Plus script from a web server (URL) or the
    local file system (filename.ext) with specified parameters that
    will be assigned to substitution variables in the script.

When SQL*Plus starts, and after CONNECT commands, the site profile
(e.g. $ORACLE_HOME/sqlplus/admin/glogin.sql) and the user profile
(e.g. login.sql in the working directory) are run.  The files may
contain SQL*Plus commands.

Refer to the SQL*Plus User's Guide and Reference for more information.



select * from v$instance;
===============================================

Thursday, January 28, 2016

NO SQL Server on a domain controller

You may encounter problems when installing SQL Server on a domain controller

Summary
It is not recommended to install SQL Server on a domain controller. There are specific security restrictions when running SQL Server in this configuration and given the resource demands of a domain controller, SQL Server performance may be degraded. Furthermore, SQL Server is not supported on a read-only domain controller. Setup will normally fail. Even if you find methods to work around the problem with setup, SQL Server is not supported on a read-only domain controller. In addition, SQL Server failover clustering is not supported to install on a domain controller.
More information
For more information about the security restrictions for SQL Server on a domain controller, see the section titled Hardware and Software Requirements for Installing SQL Server 2008 R2 Hardware and Software Requirements for Installing SQL Server 2008 R2 in the SQL Server Books Online.

For more information about the products or tools that automatically check for this condition on your instance of SQL Server and on the versions of the SQL Server product, see the following table:

Rule softwareRule titleRule descriptionProduct versions against which the rule is evaluated 
SQL Server 2008 R2 Best Practice Analyzer (SQL Server 2008 R2 BPA)SQL Server installed on PDC/BDC


The SQL Server 2008 R2 Best Practice Analyzer (SQL Server 2008 R2 BPA) provides a rule to detect if SQL Server is installed on a domain controller. The SQL Server 2008 R2 BPA supports both SQL Server 2008 and SQL Server 2008 R2. If you run the BPA tool and encounter a Warning with the title of Engine -SQL Server installed on PDC/BDC- , then your SQL Server 2008 or SQL Server 2008 R2 instance is installed on a domain controller. BPA detects this configuration by querying the domain role property of the win32_computersystem WMI class.SQL Server 2008
SQL Server 2008 R2

SQL Server 2012 Best Practice Analyzer (SQL Server 2012 BPA)SQL Server installed on PDC/BDC

The SQL Server 2012 Best Practice Analyzer (SQL Server 2012 BPA) provides a rule to detect if SQL Server is installed on a domain controller. If you run the BPA tool and encounter a Warning with the title of Engine -SQL Server installed on PDC/BDC- , then your SQL Server 2012 instance is installed on a domain controller. BPA detects this configuration by querying the domain role property of the win32_computersystem WMI class.SQL Server 2012



Properties
Article ID: 2032911 - Last Review: 01/07/2013 21:09:00 - Revision: 3.0
  • Microsoft SQL Server 2008 Analysis Services
  • Microsoft SQL Server 2008 Developer
  • Microsoft SQL Server 2008 Enterprise
  • Microsoft SQL Server 2008 Express
  • Microsoft SQL Server 2008 Express with Advanced Services
  • Microsoft SQL Server 2008 R2 Datacenter
  • Microsoft SQL Server 2008 R2 Developer
  • Microsoft SQL Server 2008 R2 Enterprise
  • Microsoft SQL Server 2008 R2 Express
  • Microsoft SQL Server 2008 R2 Express with Advanced Services
  • Microsoft SQL Server 2012 Analysis Services
  • Microsoft SQL Server 2012 Business Intelligence
  • Microsoft SQL Server 2012 Developer
  • Microsoft SQL Server 2012 Enterprise
  • Microsoft SQL Server 2012 Express
  • Microsoft SQL Server 2012 Standard
  • Microsoft SQL Server 2012 Web
  • SQL Server 2012 Enterprise Core
  • KB2032911

SQL Server 2012 Best Practice Analyzer BPA

Using the Microsoft SQL Server 2012 Best Practice Analyzer


By:    |   Read Comments (4)   |   Related Tips: More > SQL Server Configurations

Problem
Database Administrators are often asked questions like "are all the SQL Servers within the organization configured according to industry standards?" In this tip, you will see how a Database Administrator can quickly use Microsoft SQL Server 2012 Best Practices Analyzer to analyze a SQL Server instance to determine whether it is configured according to best practices or not.
Solution
The Microsoft SQL Server 2012 Best Practices Analyzer (BPA) is an excellent tool which is available as a free download from Microsoft. Using the BPA tool, a DBA can quickly gather information from Microsoft Windows and SQL Server configuration settings. The BPA tool basically uses a predefined set of SQL Server 2012 recommendations and best practices to identify potential issues within the database environment. You can download the latest version of Microsoft SQL Server 2012 Best Practices Analyzer (BPA) for free from the following link.
The following are required for using SQL Server 2012 Best Practices Analyzer:
Prior to the installation of Microsoft SQL Server 2012 Best Practice Analyzer you need to download and install Microsoft Baseline Configuration Analyzer 2.0 otherwise you will see the below screen when you double click SQL2012BPA_Setup64.MSI or SQL2012BPA_Setup32.MSI based on your environment when trying to install Microsoft SQL Server 2012 Best Practice Analyzer.
BPA Installation Error
Once you have successfully installed Microsoft Baseline Configuration Analyzer 2.0 and Microsoft SQL Server 2012 Best Practice Analyzer. You can use the BPA tool by clicking Start > Programs > Microsoft Baseline Configuration Analyzer 2.0. In Microsoft Baseline Configuration Analyzer 2.0, select a product such as SQL Server 2012 BPA as shown in the below snippet.
Configuration Analyzer Screen
Next, click Connect to Another Computer and choose Local Computer and then click OK to close the "Connect to Another Computer" window. Then in the Microsoft Baseline Configuration Analyzer 2.0 window, click Start Scan to begin the scan.
Connect to Another Computer
In the Microsoft Baseline Configuration Analyzer 2.0 Enter Parameters screen, you need to specify the SQL Server Instance Name, for a default instance you need to specify the instance name as MSSQLSERVERand for a Named Instance you need to specify the SQL Server Instance Name as shown in the below snippet.
Using Microsoft SQL Server 2012 Best Practice Analyzer you can scan the SQL Server Database Engine, Analysis Services, Replication, Integration Services, Reporting Servers and SQL Server Setup. You can choose the required parameters and click the Start Scan at the bottom of the screen to begin the scan.
Enter Parameters for BPA Scan
In the below snippet you can see the Microsoft Baseline Configuration Analyzer 2.0 is scanning to identify potential issues.
Once the Microsoft SQL Server 2012 BPA 1.0 has completed the scanning you will be able to see the Baseline Configuration Analyzer Report which will be categorized into Errors and Warnings as shown in the snippet below.
Error and Warning
Once you expand the Error category as shown in the below snippet, you will be able to see different errors that exist on the SQL Server Instance as per the rules configured in the Best Practices Analyzer.
BPA Configuration Analyzer Report
You can click on the Error to view the Detailed Explanation of the issue encountered and to resolve the issue follow the resolution steps mentioned.
BPA Analyzer Report

Advantages of Using SQL Server 2012 Best Practice Analyzer

  • Using this tool a DBA can determine whether the SQL Server is configured as per the best practices recommended by the SQL Server Products Team.
  • This tool validates your instance of SQL Server with certain built-in rules that can help you rectify common installation and configuration issues.
  • This tool recommends fixes for most of the potential problems on an instance of SQL Server and it's an excellent free tool to identify potential bottlenecks within your SQL Server Instance.

Disadvantages of Using SQL Server 2012 Best Practice Analyzer

  • I feel some of the resolution messages are not very clear and if you have any doubts I would recommend you to click the "More Information" option under each Error or Warning to get a complete understanding before implementing the suggestion.
  • This tool is a great starting point to identify issues, but this tools does not address every potential issue for a SQL Server instance.  You still need to educate yourself on best practices for setting up SQL Server.

Troubleshooting Issues with SQL Server 2012 Best Practice Analyzer Installation

  • As a best practice, a person who is installing SQL Server 2012 Best Practice Analyzer must have their Windows Account within the Windows Local Administrator Group and SQL Server Administrator Group on the server where this tool is installed.
  • If you receive any issues related to PowerShell, it is recommended to take a look at the Additional Information section of the Microsoft SQL Server 2012 Best Practice Analyzer Download Page.
Next Steps


Last Update:  





About the author
MSSQLTips author Ashish Kumar MehtaAshish Kumar Mehta has been contributing to the MSSQLTips.com community since 2009 with over 60 tips. 

View all my tips
Related Resources



More SQL Server Solutions



Post a comment or let the author know this tip helped you.
All comments are reviewed, so stay on subject or we may delete your comment.
*Name    *Email    Notify for updates 

Note: your email address is not published. Required fields are marked with an asterisk (*)

Get free SQL tips: 

*Enter Code   refresh code    



Monday, August 24, 2015 - 1:51:46 PM - MarcBack To Top
The tool never enables the "Start Scan" Button after selecting the local Server option. I ran it as local Admin and have sysadmin previleges. Anyone knows why?

Monday, February 25, 2013 - 12:00:53 PM - Greg RobidouxBack To Top
@PF - thanks for that catch.  Spell check strikes again.  The artcile has been updated.
Greg Robidoux

Monday, February 25, 2013 - 9:50:00 AM - PFBack To Top
"...categorized into Errors, Warnings and Complaints as shown in the snippet below."
One complaint about your article: are you aware of the difference between the words 'complaint' and 'compliant'? Microsoft BPA doesn't make complaints - only readers do.

Tuesday, June 26, 2012 - 10:45:30 AM - BillBack To Top
I always found it funny that you can do a fresh install of SQL Server using the MS default settings and then run the BPA and find all sorts of errors.