Sql-server - Database

Java-Examples

                                                                                                                                                                                                                    Show all | Close all
  • Introduction

    • SQL SERVER

      Microsoft SQL Server is a relational database management system developed by Microsoft. As a database, it is a software product whose primary function is to store and retrieve data as requested by other software applications, be it those on the same computer or those running on another computer across a network (including the Internet). There are at least a dozen different editions of Microsoft SQL Server aimed at different audiences and for different workloads (ranging from small applications that store and retrieve data on the same computer, to millions of users and computers that access huge amounts of data from the Internet at the same time).
      Microsoft SQL Server is an application used to create computer databases for the Microsoft Windows family of server operating systems. Microsoft SQL Server provides an environment used to generate databases that can be accessed from workstations, the Internet, or other media such as a personal digital assistant (PDA).

      To follow our lessons, you must have access to a computer in which Microsoft SQL Server 2008 is installed. To start, you must have a computer that runs an appropriate operating system. If you are just learning, you can use a computer that runs Microsoft Windows XP Professional, Microsoft Windows Vista, Microsoft Windows 7 (Professional or Ultimate), Microsoft Windows Server 2003, or Microsoft Windows Server 2008.

      Before installing Microsoft SQL Server 2008, make sure you have installed all service packs on your operating system.
    • why we use java

      Java is a programming language and computing platform first released by Sun Microsystems in 1995. It is the underlying technology that powers state-of-the-art programs including utilities, games, and business applications. Java runs on more than 850 million personal computers worldwide, and on billions of devices worldwide, including mobile and TV devices.
      Why do I need Java?
      There are lots of applications and websites that won't work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!
    • Usage

      Java technology is a high-level programming and a platform independent language. Java is designed to work in the distributed environment on the Internet. Java has a GUI features that provides you better "look and feel" over the C++ language, moreover it is easier to use than C++ and works on the concept of object-oriented programming model. Java enable us to play online games, video, audio, chat with people around the world, Banking Application, view 3D image and Shopping Cart. Java find its extensive use in the intranet applications and other e-business solutions that are the grassroots of corporate computing. Java , regarded as the most well described and planned language to develop an applications for the Web. Java is a well known technology which allows you for software designed and written only once for an "virtual machine" to run on a different computers, supports various Operating System like Windows PCs, Macintoshes, and Unix computers. On the web aspect, Java is popular on web servers, used by many of the largest interactive websites. Java is used to create standalone applications which may run on a single computer or in distributed network. It is also be used to create a small application program based on applet, which is further used for Web page. Applets make easy and possible to interact with the Web page.
  • Histroy

    James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991.[12] Java was originally designed for interactive television, but it was too advanced for the digital cable television industry at the time.[13] The language was initially called Oak after an oak tree that stood outside Gosling's office; it went by the name Green later, and was later renamed Java, from Java coffee, said to be consumed in large quantities by the language's creators.[14] Gosling aimed to implement a virtual machine and a language that had a familiar C/C++ style of notation.[15] Sun Microsystems released the first public implementation as Java 1.0 in 1995[1]. It promised "Write Once, Run Anywhere" (WORA), providing no-cost run-times on popular platforms. Fairly secure and featuring configurable security, it allowed network- and file-access restrictions. Major web browsers soon incorporated the ability to run Java applets within web pages, and Java quickly became popular. With the advent of Java 2 (released initially as J2SE 1.2 in December 1998-1999), new versions had multiple configurations built for different types of platforms. For example, J2EE targeted enterprise applications and the greatly stripped-down version J2ME for mobile applications (Mobile Java). J2SE designated the Standard Edition. In 2006, for marketing purposes, Sun renamed new J2 versions as Java EE, Java ME, and Java SE, respectively. In 1997, Sun Microsystems approached the ISO/IEC JTC1 standards body and later the Ecma International to formalize Java, but it soon withdrew from the process.[16] Java remains a de facto standard, controlled through the Java Community Process.[17] At one time, Sun made most of its Java implementations available without charge, despite their proprietary software status. Sun generated revenue from Java through the selling of licenses for specialized products such as the Java Enterprise System. Sun distinguishes between its Software Development Kit (SDK) and Runtime Environment (JRE) (a subset of the SDK); the primary distinction involves the JRE's lack of the compiler, utility programs, and header files. On November 13, 2006, Sun released much of Java as free and open source software, (FOSS), under the terms of the GNU General Public License (GPL). On May 8, 2007, Sun finished the process, making all of Java's core code available under free software/open-source distribution terms, aside from a small portion of code to which Sun did not hold the copyright.[18] Sun's vice-president Rich Green said that Sun's ideal role with regards to Java was as an "evangelist."[19] Following Oracle Corporation's acquisition of Sun Microsystems in 2009-2010, Oracle has described itself as the "steward of Java technology with a relentless commitment to fostering a community of participation and transparency".[20] This did not hold Oracle, however, from filing a lawsuit against Google shortly after that for using Java inside the Android SDK (see Google section below). Java software runs on laptops to data centers, game consoles to scientific supercomputers. There are 930 million Java Runtime Environment downloads each year and 3 billion mobile phones run Java.[21] On April 2, 2010, James Gosling resigned from Oracle.[22]
  • Architecture

    This architecture of MS SQL Server contains different layers and services.

    Protocol layer
    Protocol layer implements the external interface to SQL Server. All operations that can be invoked on SQL Server are communicated to it via a Microsoft-defined format, called Tabular Data Stream (TDS). TDS is an application layer protocol, used to transfer data between a database server and a client. Initially designed and developed by Sybase Inc. for their Sybase SQL Server relational database engine in 1984, and later by Microsoft in Microsoft SQL Server, TDS packets can be encased in other physical transport dependent protocols, including TCP/IP, Named pipes, and Shared memory. Consequently, access to SQL Server is available over these protocols. In addition, the SQL Server API is also exposed over web services
    Data storage
    The main unit of data storage is a database, which is a collection of tables with typed columns. SQL Server supports different data types, including primary types such as Integer, Float, Decimal, Char (including character strings), Varchar (variable length character strings), binary (for unstructured blobs of data), Text (for textual data) among others. The rounding of floats to integers uses either Symmetric Arithmetic Rounding or Symmetric Round Down (Fix) depending on arguments: SELECT Round(2.5, 0) gives 3. Microsoft SQL Server also allows user-defined composite types (UDTs) to be defined and used. It also makes server statistics available as virtual tables and views (called Dynamic Management Views or DMVs). In addition to tables, a database can also contain other objects including views, stored procedures, indexes and constraints, along with a transaction log. A SQL Server database can contain a maximum of 231 objects, and can span multiple OS-level files with a maximum file size of 260 bytes.[38] The data in the database are stored in primary data files with an extension .mdf. Secondary data files, identified with a .ndf extension, are used to store optional metadata. Log files are identified with the .ldf extension.[38] Storage space allocated to a database is divided into sequentially numbered pages, each 8 KB in size. A page is the basic unit of I/O for SQL Server operations. A page is marked with a 96-byte header which stores metadata about the page including the page number, page type, free space on the page and the ID of the object that owns it. Page type defines the data contained in the page - data stored in the database, index, allocation map which holds information about how pages are allocated to tables and indexes, change map which holds information about the changes made to other pages since last backup or logging, or contain large data types such as image or text. While page is the basic unit of an I/O operation, space is actually managed in terms of an extent which consists of 8 pages. A database object can either span all 8 pages in an extent ("uniform extent") or share an extent with up to 7 more objects ("mixed extent"). A row in a database table cannot span more than one page, so is limited to 8 KB in size. However, if the data exceeds 8 KB and the row contains Varchar or Varbinary data, the data in those columns are moved to a new page (or possibly a sequence of pages, called an Allocation unit) and replaced with a pointer to the data.[49] For physical storage of a table, its rows are divided into a series of partitions (numbered 1 to n). The partition size is user defined; by default all rows are in a single partition. A table is split into multiple partitions in order to spread a database over a cluster. Rows in each partition are stored in either B-tree or heap structure. If the table has an associated index to allow fast retrieval of rows, the rows are stored in-order according to their index values, with a B-tree providing the index. The data is in the leaf node of the leaves, and other nodes storing the index values for the leaf data reachable from the respective nodes. If the index is non-clustered, the rows are not sorted according to the index keys. An indexed view has the same storage structure as an indexed table. A table without an index is stored in an unordered heap structure. Both heaps and B-trees can span multiple allocation units.[50]

    Buffer management
    SQL Server buffers pages in RAM to minimize disc I/O. Any 8 KB page can be buffered in-memory, and the set of all pages currently buffered is called the buffer cache. The amount of memory available to SQL Server decides how many pages will be cached in memory. The buffer cache is managed by the Buffer Manager. Either reading from or writing to any page copies it to the buffer cache. Subsequent reads or writes are redirected to the in-memory copy, rather than the on-disc version. The page is updated on the disc by the Buffer Manager only if the in-memory cache has not been referenced for some time. While writing pages back to disc, asynchronous I/O is used whereby the I/O operation is done in a background thread so that other operations do not have to wait for the I/O operation to complete. Each page is written along with its checksum when it is written. When reading the page back, its checksum is computed again and matched with the stored version to ensure the page has not been damaged or tampered with in the meantime.[51]>

    Logging and Transaction
    SQL Server ensures that any change to the data is ACID-compliant, i.e. it uses transactions to ensure that the database will always revert to a known consistent state on failure. Each transaction may consist of multiple SQL statements all of which will only make a permanent change to the database if the last statement in the transaction (a COMMIT statement) completes successfully. If the COMMIT successfully completes the transaction is safely on disk. SQL Server implements transactions using a write-ahead log. Any changes made to any page will update the in-memory cache of the page, simultaneously all the operations performed will be written to a log, along with the transaction ID which the operation was a part of. Each log entry is identified by an increasing Log Sequence Number (LSN) which is used to ensure that all changes are written to the data files. Also during a log restore it is used to check that no logs are duplicated or skipped. SQL Server requires that the log is written onto the disc before the data page is written back. It must also ensure that all operations in a transaction are written to the log before any COMMIT operation is reported as completed. At a later point the server will checkpoint the database and ensure that all pages in the data files have the state of their contents synchronised to a point at or after the LSN that the checkpoint started. When completed the checkpoint marks that portion of the log file as complete and may free it (see Simple transaction logging vs Full transaction logging). This enables SQL Server to ensure integrity of the data, even if the system fails. On failure the database log has to be replayed to ensure the data files are in a consistent state. All pages stored in the roll forward part of the log (not marked as completed) are rewritten to the database, when the end of the log is reached all open transactions are rolled back using the roll back portion of the log . The database engine usually checkpoints quite frequently. However, in a heavily loaded database this can have a significant performance impact. It is possible to reduce the frequency of checkpoints or disable them completely but the rollforward during a recovery will take much longer
    Concurrency and locking
    SQL Server allows multiple clients to use the same database concurrently. As such, it needs to control concurrent access to shared data, to ensure data integrity - when multiple clients update the same data, or clients attempt to read data that is in the process of being changed by another client. SQL Server provides two modes of concurrency control: pessimistic concurrency and optimistic concurrency. When pessimistic concurrency control is being used, SQL Server controls concurrent access by using locks. Locks can be either shared or exclusive. Exclusive lock grants the user exclusive access to the data - no other user can access the data as long as the lock is held. Shared locks are used when some data is being read - multiple users can read from data locked with a shared lock, but not acquire an exclusive lock. The latter would have to wait for all shared locks to be released. Locks can be applied on different levels of granularity - on entire tables, pages, or even on a per-row basis on tables. For indexes, it can either be on the entire index or on index leaves. The level of granularity to be used is defined on a per-database basis by the database administrator. While a fine grained locking system allows more users to use the table or index simultaneously, it requires more resources. So it does not automatically turn into higher performing solution. SQL Server also includes two more lightweight mutual exclusion solutions - latches and spinlocks - which are less robust than locks but are less resource intensive. SQL Server uses them for DMVs and other resources that are usually not busy. SQL Server also monitors all worker threads that acquire locks to ensure that they do not end up in deadlocks - in case they do, SQL Server takes remedial measures, which in many cases is to kill one of the threads entangled in a deadlock and rollback the transaction it started.[38] To implement locking, SQL Server contains the Lock Manager. The Lock Manager maintains an in-memory table that manages the database objects and locks, if any, on them along with other metadata about the lock. Access to any shared object is mediated by the lock manager, which either grants access to the resource or blocks it. SQL Server also provides the optimistic concurrency control mechanism, which is similar to the multiversion concurrency control used in other databases. The mechanism allows a new version of a row to be created whenever the row is updated, as opposed to overwriting the row, i.e., a row is additionally identified by the ID of the transaction that created the version of the row. Both the old as well as the new versions of the row are stored and maintained, though the old versions are moved out of the database into a system database identified as Tempdb. When a row is in the process of being updated, any other requests are not blocked (unlike locking) but are executed on the older version of the row. If the other request is an update statement, it will result in two different versions of the rows - both of them will be stored by the database, identified by their respective transaction IDs
  • How to install MicroSoft sql server

    1. Start the computer
    2. Log in using an account with administrative rights. If you followed the previous lesson, log in using the phkatts account. If the computer you are using is connected to a network, make sure you specify the domain. If you are logged in locally, make sure you use the name of the computer.
      If you are installing in Microsoft Windows XP-7, make sure you log in with a password, otherwise the installation will fail.
      For our installation, we will log in as Administrator (in either Microsoft Windows 7 Professional/Ultimate or in a domain named functionx.local)
    3. Insert the DVD in the drive. You may (should) receive a dialog box with a Run SETUP.EXE link:

      AutoPlay

      If so, click Run SETUP.EXE
    4. The installation will start. You may get a message that the .NET Framework needs to be installed. If you get that message, click OK. You will be prompted to start the installation:
      Microsoft .NET Framework 3.5 SP1 Setup
      After clicking the ACCEPT button, you can click Install. The installation of the .NET Framework would start. When the installation of the .NET Framework is over, you would receive a message:
      .NET Framework
      From there, you can click Exit. If you are installing in either Microsoft Windows XP or Microsoft Windows Server 2003, you may be asked to install a hotfix:
      Hotfix
      Hotfix
      In this case, accept to install it by clicking Next and following the wizard. When the installation is over, you may be asked to restart:
      Hotfix
      Which you should do.
    5. To start the installation, put the Microsoft SQL Server 2008 DVD in the drive. A window would come up:

      Installation
    6. In the left section, click Installation

      Installation
    7. If you are only interested in studying database design and development in Microsoft SQL Server, on the right side, click New SQL Server Stand-Alone... The installation would start:

      Installation
    8. After the message box, click OK

      Setup
    9. Another message box would come up. When it finishes, the next page of the wizard would come up. If you are using the evaluation version, read the message and click the first radio button

      Product Key

      If you are installing with a product key, click the second radio button and enter the key

      Product Key
    10. Click Next
    11. The License Terms page is presented to you. Read it. If you don't agree with the license, click Cancel. Otherwise, click the I Accept check box:

      License Agreement

      License Agreement
    12.  Click Next

      Microsoft SQL Server 2008 Setup
    13. Read the messages and click Install:

      Microsoft SQL Server 2008 Setup
    14. You may receive a warning message about the firewall:

      Firewall warning

      For now, ignore it (there is no true justfication in trying to disable the firewall, the installation will proceed fine).
      If you are installing on the only computer you use as your server, you may receive a warning that it is not recommended to install Microsoft SQL Server on a domain controller:

      Domain Controller Warning

      Ignore the warning for now.
      Click Next
      (We are not encouraging you to ignore warnings; just these ones)
    15. If you had previously installed Microsoft SQL Server Express, you may receive a message box asking you to specify an instance name. If so, specify it as MSSQLSERVER.
      The next page allows you to specify what you want to install and what would be left out. For our example, we select all, then removed Reporting Services.

      The eventual location of Microsoft SQL Server is specified in the bottom text box:

      Feature Selection

      If you are installing the Developer Edition and if you to change the directory of Microsoft SQL Server, you can type it in the Shared Feature Directory text box, or you can click the browse button to select it.

      Feature Selection

      If you are installing the Enterprise Edition, if you to change the directory of Microsoft SQL Server, click the broser button on the right side of the Shared Feature Directory text box and locate the directory you want.

      After making your selections, click Next
    16. The next page allows you to name the instance of Microsoft SQL Server (and to specify where the server would be installed). In most cases, you should accept the suggested name of the instance as MSSQLSERVER:

      Instance

      After making your selections, click Next
    17. The next page mostly allows you to check and confirm the disk space:

      Disk Space

      After checking it, click Next
    18. The next page allows you to specify the account that is performing the installation:

      Server Configuration

      Click Use the Same Account For All Server Services
    19. A dialog box would come up.
      If you are installing in Microsoft Windows 7 and you want to use a local account, in the Account Name text box, enter the name of the computer, followed by a back slash, followed by the user name, and press Tab. In the Password text box, enter the password:

      Log In

      If you are installing in Microsoft Windows Server 2008, in the Account Name text box, enter the name of the domain, followed by a back slash, followed by the user name, and press Tab. In the Password text box, enter the password:

      Log In
    20. Click OK

      Log In

      Log In
    21. Click Next
    22. After making your selections, click Next
    23. In the next page, specify how authentication would be made. You should also specify the account used as the administrator. To do this, you can click Add Current User:

      Database Engine Configuration
    24. Microsoft SQL Server provides a default user named sa. To prepare that user for database authentication, click the Mixed Mode
    25. Type a password in the Enter Password text box. For this exercise, you can use P@assword1 and press Tab
    26. Enter the same password in the Confirm Password text box
    27. To add an additional account, click Add...
      A dialog box would display. In the bottom text box, type the (complete) user name of a user and click Check Names. In the same way, you can add as many users as possible

      Database Engine Configuration
    28. Click Next
    29. The next step allows you to specify an account for the analysis services. Click Add Current User

      Analysis Services Configuration

      To add an additional account, click Add... In the bottom text box, type the (complete) user name of a user and click Check Names. In the same way, you can add as many users as possible

      Analysis Services Configuration
    30. Click Next
    31. In the Reporting Services Configuration page, click the last radio button to install but without configuring the reporting:

      Reporting Services Configuration
    32. Click Next.
      The next page allows you to specify whether you want and installation report to be sent to Microsoft:

      Error and Usage Reporting
    33. Read it and click Next
    34. The next page gives you a summary of tests that were performed before the installation:

      Installation Rules
    35. After reading, click Next.
      This would indicate that the installation is ready to proceed:

      Ready to Install
    36. To start the installation, click Install. The installation would start and a progress bar would indicate the evolution. This can take a while

      Installation Progress

      Installation Progress
    37. When this phase is over, a message box will let you know. After reading it, you can click Next. The last page of the wizard should announce that the installation was complete

      Installation
    38. After reading the message, click Close
  • Microsoft Sqlserver Service

    In the Services window, check the status of the SQL Server (MSSQLSERVER), the SQL Server Agent (MSSQLSERVER), and the SQL Server Browser:
    If the MSSQLSERVER service is stopped, you should start it. To do this, you can right-click it and click Start. If it fails to start, check the account with which you logged in:
    • If you are using Microsoft Windows XP-7 and you logged in as Administrator but did not provide a password, you should open Control Panel, access User Accounts, open the Administrator account, and create a password for it
    • If you are using a server (Microsoft Windows Server 2003 or Microsoft Windows Server 2008), make sure you logged in with an account that can start a service
    Once the service has started, it should be labeled Started:
  • open Sql- server

    To launch Microsoft SQL Server, you can click Start -> (All) Programs -> Microsoft SQL Server 2008 -> SQL Server Management Studio
    Launching Microsoft SQL Server 2008
    When it starts, it would present a dialog box that expects you to log in.
  • SQL Server Management Studio

    SQL Server Management Studio is a GUI tool included with SQL Server 2005 and later for configuring, managing, and administering all components within Microsoft SQL Server. The tool includes both script editors and graphical tools that work with objects and features of the server.[76] SQL Server Management Studio replaces Enterprise Manager as the primary management interface for Microsoft SQL Server since SQL Server 2005. A version of SQL Server Management Studio is also available for SQL Server Express Edition, for which it is known as SQL Server Management Studio Express (SSMSE).[77] A central feature of SQL Server Management Studio is the Object Explorer, which allows the user to browse, select, and act upon any of the objects within the server.[78] It can be used to visually observe and analyze query plans and optimize the database performance, among others.[79] SQL Server Management Studio can also be used to create a new database, alter any existing database schema by adding or modifying tables and indexes, or analyze performance. It includes the query windows which provide a GUI based interface to write and execute queries
    Introduction
    There are many tools you will use in Microsoft SQL server. One of them is called Microsoft SQL Server Management Studio. To access it, you can click Start -> (All) Programs -> Microsoft SQL Server 2008 -> SQL Server Management Studio. A dialog box would come up but you can click Cancel on it:
    Microsoft SQL Server Management Studio
    The top section of the SQL Server Management Studio displays the classic title bar of a regular window, with an icon on the left, followed by the title of the application, and the system buttons on the right side.
    The Main Menu
    Under the title bar, the menu bar displays categories of menus that you will use to perform the various necessary operations.
    The Standard Toolbar
    The Standard toolbar displays under the main menu:
    The Standard toolbar displays under the main menu
    The Standard toolbar is just one of the available ones. Eventually, when you perform an action that would benefit from another toolbar, the Microsoft SQL Server Management Studio would display that toolbar. Still, if you want to show any toolbar, you can right-click any menu item on the main menu or any button on a toolbar. A menu would come up:
    Context-Sensitve Menu
    The Object Explorer
    The left side of the interface displays, by default, the Object Explorer window, with its title bar labeled Object Explorer. If you don't see it, on the main menu, you can click View -> Object Explorer.
    The Object Explorer is a dockable window, meaning you can move it from the left side to another side on the interface. To do this, you can click and drag its title bar to a location of your choice. When you start dragging, small boxes that represent the possible placeholders would come up:
    Dragging
    You can drag and drop to one of those placeholders.
    The Object Explorer is also floatable, which means you can place it somewhere in the middle of the interface:
    To place the window back to its previous position, you can double-click its title bar. The window can also be tabbed. This means that the window can be positioned either vertically or horizontally.
    At any time, if you do not want the Object Explorer, you can close or hide it. To close the Object Explorer, click its close button.
    On the right side of the Object Explorer title, there are three buttons. If you click the first button that points down, a menu would appear:
    Object Explorer
    The menu allows you to specify whether you want the window to be floated, docked, or tabbed.
    The right side of the window is made of an empty window. This area will be used to display either the contents of what is selected in the Object Explorer, or to show a result of some operation. As you will see later on, many other windows will occupy the right section but they will share the same area. To make each known it will be represented with a tab and the tab shows the name (or caption) of a window.
  • Business Intelligence Development Studio

    Business Intelligence Development Studio (BIDS) is the IDE from Microsoft used for developing data analysis and Business Intelligence solutions utilizing the Microsoft SQL Server Analysis Services, Reporting Services and Integration Services. It is based on the Microsoft Visual Studio development environment but is customized with the SQL Server services-specific extensions and project types, including tools, controls and projects for reports (using Reporting Services), Cubes and data mining structures (using Analysis Services
  • Close Microsoft SQL Server

    After using Microsoft SQL Server Management Studio, you can close it. To do this:
    • Click the icon on the left side of Microsoft SQL Server Management Studio and click Close
    • On the right side of the title bar, click the system Close button Close
    • On the main menu, click File -> Exit
    • Press Alt, F, X
  • The SQL Command Prompt

    Besides the SQL Server Management Studio, you can also work on Microsoft SQL Server from the DOS Command Prompt. To access the command Prompt, click the Start button:
    • If you are using Microsoft Windows XP or 7, click the box that appears, type cmd and press Enter
    • If you are using Microsoft Windows Server, click Command Prompt
    Once at the Command Prompt, type SQLCMD (case-insensitive) and press Enter.
    The Command Prompt
    To see the names of the computers that have Microsoft SQL Server in your network, type SQLCMD -L and press Enter:
    The Command Prompt
    Unlike the SQL Server Management, the SQLCMD utility allows you to connect to only one SQL Server instance at a time.
    After using Microsoft SQL Server from the command prompt, to close it, type Quit (case-insensitive) and press Enter. To close the DOS window:
    • Type Exit (case-insensitive) and press Enter
    • Click the system Close button Close
  • The Windows PowerShell

    The Windows PowerShell
    When Microsoft SQL Server 2008 installs, it also installs an application named Windows PowerShell, which is a command-based application from Microsoft. Besides the SQL Server Management Studio and the Command Prompt, you can use PowerShell to create and manage databases. To access it:
    • Access the Command Prompt as seen above, type sqlps, and press Enter
      Windows PowerShell
      At the Command Prompt, type SQLCMD and press Enter
    • Click Start -> (All) Programs -> Windows PowerShell 1.0 -> Windows PowerShell
    • If you had already started Microsoft SQL Server, in the Object Explorer, right-click the name of the computer or the Databases node and click Start PowerShell
    In both cases, a DOS window would display:
    Windows PowerShell
    Notice that the title bar displays Windows PowerShell. To access Microsoft SQL Server from PowerShell, type SQLCMD and press Enter:
    Windows PowerShell
    Notice that, this time, the title bar displays SQLCMD, which indicates that the application is ready to receive commands that relate to Microsoft SQL Server.
    As mentioned for the SQL Server Management Studio, Windows PowerShell allows you to connect to more than one SQL Server instance at the same time. As a result, you can create a SQL script that is meant to target more than one database in different servers, store the script in a file, and then execute at the Windows PowerShell to perform many operations on different databases.
    After using the PowerShell, to exit from Microsoft SQL Server, type Quit (case-insensitive) and press Enter:
    Windows PowerShell
    To close PowerShell and the DOS window, you can:
    • Type Exit (case-insensitive) and press Enter
    • Click the system Close button Close
  • Download...

    Click here to download Sql-server 2012


    Click Here to download new version of sql server