Lession 2 starting with mssqlserver

753 views
667 views

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
753
On SlideShare
0
From Embeds
0
Number of Embeds
395
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Lession 2 starting with mssqlserver

  1. 1. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn23Lession 2: Starting Microsoft SQL ServerThe MSSQLSERVER ServiceAfter installing Microsoft SQL Server, you can start using it.Because Microsoft SQL Server works as a service to the operating system, in order to use it, you mustmake sure its service has started. To check it (on Microsoft Windows XP Professional, Windows Vista,Windows Server 2003, or Windows Server 3008) you can open Control Panel and the AdministrativeTools. In the Administrative Tools window, you can open the Services. In the Services window, checkthe status of the SQL Server (MSSQLSERVER) item:If the MSSQLSERVER service is stopped, you must start it. To do this, you can right-click it andclick Start. If it fails to start, check the account with which you logged in:If you are using Microsoft Windows XP Professional and you logged in as Administrator but didnot provide a password, you should open Control Panel, access User Accounts, open theAdministrator account, and create a password for it
  2. 2. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn24If 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 serviceOnce the service has started, it should be labeled Started:Opening Microsoft SQL ServerTo launch Microsoft SQL Server, you can click Start -> (All) Programs -> Microsoft SQLServer 2008 -> SQL Server Management Studio
  3. 3. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn25When it starts, it would present a dialog box that expects you to log in.Practical Learning: Launching Microsoft SQL Server1. Start the computer2. Log in with the account you used to install Microsoft SQL Server3. To launch Microsoft SQL Server, click Start -> (All) Programs -> Microsoft SQLServer 2008 -> SQL Server Management Studio. A splash screen will appear:4. On the Connect to Server dialog box, click CancelThe Microsoft SQL Server Management StudioIntroduction
  4. 4. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn26There are many tools you will use in Microsoft SQL server. One of them is called MicrosoftSQL Server Management Studio. To access it, you can click Start -> (All) Programs ->Microsoft SQL Server 2008 -> SQL Server Management Studio. A dialog box would comeup but you can click Cancel on it:The top section of the SQL Server Management Studio displays the classic title bar of aregular window, with an icon on the left, followed by the title of the application, and thesystem buttons on the right side.The Main MenuUnder the title bar, the menu bar displays categories of menus that you will use toperform the various necessary operations.The Standard ToolbarThe Standard toolbar displays under the main menu:The Standard toolbar is just one of the available ones. Eventually, when you perform anaction that would benefit from another toolbar, the Microsoft SQL Server ManagementStudio 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 comeup:
  5. 5. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn27The Object ExplorerThe left side of the interface displays, by default, the Object Explorer window, with its titlebar labeled Object Explorer. If you dont 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 toanother side on the interface. To do this, you can click and drag its title bar to a locationof your choice. When you start dragging, small boxes that represent the possibleplaceholders would come up:
  6. 6. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn28You can drag and drop to one of those placeholders.The Object Explorer is also floatable, which means you can place it somewhere in themiddle of the interface:To place the window back to its previous position, you can double-click its title bar. Thewindow can also be tabbed. This means that the window can be positioned eithervertically or horizontally.At any time, if you do not want the Object Explorer, you can close or hide it. To close theObject Explorer, click its close button.On the right side of the Object Explorer title, there are three buttons. If you click the firstbutton that points down, a menu would appear:
  7. 7. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn29The menu allows you to specify whether you want the window to be floated, docked, ortabbed.The right side of the window is made of an empty window. This area will be used todisplay either the contents of what is selected in the Object Explorer, or to show a resultof some operation. As you will see later on, many other windows will occupy the rightsection but they will share the same area. To make each known it will be represented witha tab and the tab shows the name (or caption) of a window.Connection to a ServerUsing Connect to ServerIn order to do anything significant in Microsoft SQL Server, you will have to log in. If youstart Microsoft SQL Server Management Studio from the Start button, the Connect ToServer dialog box would come up. If you had started from the Start button but clickedCancel, to connect to a server:On the main menu, click File -> Connect Object ExplorerOn the Standard toolbar, click the New Query buttonIn the Object Explorer, click the arrow of the Connect button and click one of theoptions, such as Database Engine...Any of these actions would display the Connect to Server dialog box:
  8. 8. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn30From there, select the name of the server and the type of authentication to use.Once you are ready, click Connect. If you log in successfully, the Object Explorer wouldappear with a few nodes: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 clickCloseOn the right side of the title bar, click the system Close buttonOn the main menu, click File -> ExitPress Alt, F, XUsing the Command Prompt
  9. 9. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn31Besides the SQL Server Management Studio, you can also work on Microsoft SQL Serverfrom the DOS command prompt. This is done using an application or command namedSQLCMD.EXE. To use it, open the Command Prompt, type SQLCMD (case-insensitive) andpress Enter.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 EnterClick the system Close buttonUsing the Windows PowerShellWhen Microsoft SQL Server 2008 is installed, it also installs the Windows PowerShell 1.0,which is a new command-based application from Microsoft. Besides the SQL ServerManagement Studio and the Command Prompt, you can use PowerShell to create andmanage databases. To access it, you can click Start -> (All) Programs -> WindowsPowerShell 1.0 -> Windows PowerShell. A DOS window would display:Notice that the title bar displays Windows PowerShell.To access Microsoft SQL Server from PowerShell, type SQLCMD and press Enter:
  10. 10. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn32Notice that, this time, the title bar displays SQLCMD, which indicates that the applicationis ready to receive commands that relate to Microsoft SQL Server.After using the PowerShell, to exit from Microsoft SQL Server, type Quit (case-insensitive)and press Enter:To close PowerShell and the DOS window, you can:Type Exit (case-insensitive) and press EnterClick the system Close buttonMicrosoft SQL Server LoginsIntroductionIn order to access something (such as a computer or a database), the object must beauthenticated. Such an object can use a username and a password. In the adsence ofthis, a user would receive an error:
  11. 11. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn33An object can also take advantage of the group it belongs to. For this reason, the abilityto be authenticated in order to access the database or resource is called a login.Creating a LoginBefore creating a login, the person for whom you want to create the account must have auser account on the computer. If you are using Microsoft Windows XP-7, the person musthave a loca user account on the computer. If you are working on a server, the personmust have an account in the domain. You can create a login either visually or with code.To visually create a login, in the Object Explorer, expand the Security node. Right-clickLogin and click New Login...
  12. 12. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn34This would display the Login - New dialog box. In the Login Name text box, type the username of the person whose account you are creating. The account must have been createdalready in the computer (Microsoft Windows XP-7) or on the server. If you provide a username that cannot be found in the system, when trying to finalize, you would receive anerror:After entering the user name, you must specify how the user would be authenticated. Youhave a choice between the operating system and Microsoft SQL Server.The formula to programmatically create a login is:CREATE LOGIN loginName { WITH <option_list1> | FROM <sources> }<option_list1> ::=PASSWORD = { password | hashed_password HASHED } [ MUST_CHANGE ][ , <option_list2> [ ,... ] ]<option_list2> ::=SID = sid| DEFAULT_DATABASE =database| DEFAULT_LANGUAGE =language| CHECK_EXPIRATION = { ON | OFF}
  13. 13. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn35| CHECK_POLICY = { ON | OFF}| CREDENTIAL =credential_name <sources> ::=WINDOWS [ WITH <windows_options>[ ,... ] ]| CERTIFICATE certname| ASYMMETRIC KEY asym_key_name<windows_options> ::=DEFAULT_DATABASE =database| DEFAULT_LANGUAGE =languageTo let Microsoft SQL Server generate skeleton code for you, on the Standard toolbar, clickNew Query to get a text editor. in the Template Explorer, expand the Login node, dragCreate SQL Login Must Change Password and drop it in the empty text editor:-- =================================================-- Create SQL Login Must Change Password template-- =================================================CREATE LOGIN <SQL_login_name, sysname, login_name>WITH PASSWORD = N<password, sysname, Change_Password>MUST_CHANGE,CHECK_POLICY = <check_policy,ON or OFF, ON>;GOYou start with the CREATE LOGIN expression, followed by the user name. To specify apassword after that, type PASSWORD = N . In the single-quotes, enter the desiredpassword. When creating a login, you must specify a password. You can just set atemporary password. One of the options you can specify is to make the user change his orher password the next time he or she logs on. To apply this, after the password, addthe MUST_CHANGE flag.Practical Learning: Creating a Login1. In the Object Explorer, expand the server name if necessary and expand Security2. Right-click Login and click New Login...3. In the Login Name text box, type operez4. Click SQL Server Authentication5. In the Password text box, type Password1 and press Tab6. In the Confirm Password text box, type Password1
  14. 14. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn367. Accept the three check boxes and make sure User Must Change Password At NextLogin is checked.Click OK8. On the Standard toolbar, click the New Query button9. To programmatically create a login, type the following:10. CREATE LOGIN rkouma11. WITH PASSWORD = NPassword1;GO
  15. 15. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn3712.On the Standard toolbar, click the Execute button13.Click inside the Query window and press Ctrl + A14.To create two more accounts with three options, type the following:15. CREATE LOGIN pkatts16. WITH PASSWORD = NPassword117. MUST_CHANGE,18. CHECK_POLICY = ON,19. CHECK_EXPIRATION = ON;20. GO21. CREATE LOGIN gdmonay22. WITH PASSWORD = NPassword123. MUST_CHANGE,24. CHECK_POLICY = ON,25. CHECK_EXPIRATION = ON;GO
  16. 16. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn3826.Press F5 to execute27.In the Object Explorer, expand Login under Security if necessary. To refresh it, right-click Logins and click RefreshMake sure you have logins for the gdmonay, the pkatts, the operez, the rkouma, andthe sa accounts
  17. 17. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn3928.Close Microsoft SQL Server29.When asked whether you want to save something, click NoUsing a LoginAfter creating a login, a person can use it to connect to the server. There are manyoptions.After launching Microsoft SQL Server, in the Connect To Server dialog box, in theAuthentication combo box, the person can (must) select SQL Server Authentication, thenenter his/her login name and a password.Remember that when Microsoft SQL Server is installed, it creates a default account namedsa. You can also use it as a login and provide its password:If the SQL Server Management Studio is already opened, to log in, on the Standardtoolbar, a person can click Connect -> Database Engine...This would open the Connect to Server dialog box. The person must select SQL ServerAuthentication in the Authentication combo box, enter or select a login name in the Logincombo box, and type a password:
  18. 18. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn40Then click Connect. In the same way, you can create as many connections as possible,using valid login accounts.Another alternative is to switch user (Start -> Switch User) and log in with a differentaccount. In this case, if a person launches Microsoft SQL Server, the Authentication canbe set as Windows Authentication:The person would not have to enter a password.Practical Learning: Using a Login1. To start it again, click Start -> (All) Programs -> Microsoft SQL Server 2008 -> SQLServer Management Studio2. In the Authentication combo box, select SQL Server Authentication
  19. 19. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn413. In the Login combo box, type operez4. In the Password text box, type Password15. Click Connect6. In the dialog box that comes up, enter the password as P@ssword1 and press Tab7. In the other text box, type P@ssword18. Click OK9. In the Object Explorer, click Connect and click Database Engine...10.In the Authentication combo box, select SQL Server Authentication11.In the Login combo box, type rkouma12.In the Password text box, type Password113.Click Connect14.In the dialog box that comes up, enter the password as P@ssword1 and press Tab
  20. 20. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn4215.In the other text box, type P@ssword116.Click OK17.In the same way, connect to the database engine using the pkatts and the gdmonayaccountsDisconnecting From a ServerAfter using a server or to take a break (such as stepping out from the computer), theperson can disconnect from it. To do this:On the main menu, click File -> Disconnect Object ExplorerIn the Object Explorer, right-click the connection node and click DisconnectDisconnecting neither closes Microsoft SQL Server nor shuts down the server. It simplycloses the connection to the server. If a persons wants to use the server again, she mustconnect.Using the Microsoft SQL Server Management StudioThe Object ExplorerThe Object Explorer displays a list of items as a tree-style. One of the most regularly useditems will be the name of the server you are using. If you are just starting to learndatabase development or you are a junior database developer, you may use or see onlyone server. In some cases, you may be dealing with many servers. Regardless, youshould always know what server you are currently connecting to. This is easy to checkwith the first node of the Object Explorer. In the following example, the server is namedCentral:The name of the server is followed by parentheses.In the previous section, we saw that, to establish a connection to a server, you mustauthenticate yourself. In some cases you may use the same account over and over again.In some other cases you may have different accounts that you use for different scenarios,
  21. 21. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn43such as one account for database development, one account for database management,and/or one account for database testing. When many connections have been made, eachconnection is represented in the Object Explorer by its own node and each connection hasits own objects (sub-nodes):As mentioned previously, to close a connection, you can right-click it and click Disconnect:Some operations cannot be performed by some accounts. When performing someoperations, you should always know what account you are using. You can check this in the
  22. 22. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn44parentheses of the server name. In the following connection, an account calledAdministrator is currently logged in to a server named Central:Practical Learning: Disconnecting1. In the Object Explorer, right-click ComputerName (SQL Server ... - operez) and clickDisconnect2. Right-click ComputerName (SQL Server ... - rkouma) and click Disconnect3. Close Microsoft SQL Server4. Start it again5. Select Windows Authentication6. Click ConnectObject Explorer DetailsWe saw that, by default, the right area of Microsoft SQL Server Management Studiodisplays an empty gray window. When you select something in the Object Explorer, youcan use that right area to display more detailed information about the select item. To dothis, on the main menu, you can click View -> Object Explorer Details. The main are onthe right side would then be filled with information:
  23. 23. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn45Probably the most regular node you will be interested in, is labeled Databases. This nodeholds the names of databases on the server you are connected to. Also, from that node,you can perform almost any necessary operation of a database. To see most of theregularly available actions, you can expand the Databases node and some of its children.You can then right-click either Databases or one of its child nodes. For example, to startPowerShell, you can right-click the Databases node or the server name and clickPowerShell:
  24. 24. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn46When the PowerShell comes up, what it displays depends on what you had right-clicked.Introduction to CodeAlthough you will perform many of your database operations visually, some otheroperations will require that you write code. To assist with with this, Microsoft SQL Serverprovides a code editor and various code templates.To open the editor:On the main menu, you can click File -> New -> Query With Current ConnectionOn the Standard toolbar, click the New Query buttonIn the Object Explorer, right-click the name of the server and click New QueryThis would create a new window and position it on the right side of the interface. Whetheryou have already written code or not, you can save the document of the code editor atany time. To save it:You can press Ctrl + SOn the main menu, you can click File -> Save SQLQueryX.sql...On the Standard toolbar, you can click the Save buttonYou will be required to provide a name for the file. After saving the file, its name wouldappear on the tab of the document.The Structured Query LanguageIntroduction
  25. 25. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn47After establishing a connection, you can take actions, such as creating a database and/ormanipulating data. To provide the ability to create and manipulate a database, you usedata manipulation language (DML). There are many of them on the market. TheStructured Query Language, known as SQL, is a DML used on various computer systemsto create and manage databases.SQL can be pronounced Sequel or S. Q. L. In our lessons, we will consider the Sequelpronunciation. For this reason, the abbreviation will always be considered as a word,which would result in “A SQL statement” instead of "An SQL statement". Also, we willregularly write, “The SQL” instead of “The SQL language, as the L already representsLanguage.Like other non-platform specific languages such as C/C++, Pascal, or Java, the SQL youlearn can be applied to various database systems. To adapt the SQL to Microsoft SQLServer, the company developed Transact-SQL as Microsofts implementation of SQL.Transact-SQL is the language used internally by Microsoft SQL Server and MSDE.Although SQL Server highly adheres to the SQL standards, it has some internal detailsthat may not be applied to other database systems like MySQL, Oracle, or even MicrosoftAccess, etc; although they too fairly conform to the standard.The SQL we will learn and use here is Transact-SQL. In other words, we will assume thatyou are using Microsoft SQL Server as your platform for learning about databases. Thismeans that, unless specified otherwise, most of the time, on this site, the word SQL refersto Transact-SQL or the way the language is implemented in Microsoft SQL Server.The SQL InterpreterAs a computer language, the SQL is used to give instructions to an internal program calledan interpreter. As we will learn in various sections, you must make sure you give preciseinstructions. SQL is not case-sensitive. This means that CREATE, create, and Create meanthe same thing. It is a tradition to write SQLs own words in uppercase. This helps todistinguish SQL instructions with the words you use for your database.As we will learn in this and the other remaining lessons of this site, you use SQL bywriting statements. To help you with this, Microsoft SQL Server provides a window, alsoreferred to as the Query Window, that you can use to write your SQL code. To access it,on the left side of the window, you can right-click the name of the server and click NewQuery. In the same way, you can open as many instances as the New Query as you want.When the Query window comes up, it display a blank child window in which you can writeyour code. The code you write is a document and it can be saved as a file. The file wouldhave the extension .sql. Every time you open a new query, it is represented with a tab. Toswitch from one code part to another, you can click its tab. To dismiss an instance of thequery, first access it (by clicking its tab), then, on the right side, click the close button .If you had written code in the query window, when you close it, you would be asked tosave your code. If you want to preserve your code, then save it. If you had alreadyexecuted the code in the window (we will learn how to write and execute SQL code), youdont have to save the contents of the window.Executing a StatementIn the next sections and lessons, we will learn various techniques of creating SQLstatements with code. By default, when a new query window appears, it is made of a widewhite area where you write your statements:
  26. 26. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn48After writing a statement, you can execute it, either to make it active or simply to test it.To execute a statement:You can press F5On the main menu, you can click Query -> ExecuteOn the SQL Editor toolbar, you can click the Execute buttonYou can right-click somewhere in the code editor and click ExecuteWhen you execute code, code editor becomes divided into two horizontal sections:
  27. 27. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn49Also, when you execute code, the interpreter would first analyze it. If there is an error, itwould display one or more red lines of text in its bottom section. Here is an example:If there is no error in the code, what happens when you execute a statement depends onthe code and the type of statement.Accessories for SQL Code WritingCommentsA comment is text that the SQL interpreter would not consider as code. As such, acomment is written any way you like. What ever it is made of would not be read.Transact-SQL supports two types of comments. The style of comment that starts with /*
  28. 28. Lecturer: Tran Dinh Vuong Home page: www.fit.vimaru.edu.vn/~vuongtdPhone : 0982.113.274 Email : vuongtd@vimaru.edu.vn50and ends with */ can be used. To apply it, start a line with /*, include any kind of text youlike, on as many lines as you want. To close the commented section, type */. Here is anexample of a line of comment:/* First find out if the database we want to create exists already */A comment can also be spread on more than one line, like a paragraph. Here is anexample:/* First find out if the MotorVehicleDivision database wewant to create exists already.If that database exists, we dont want it anymore. So,delete it from the system. */Transact-SQL also supports the double-dash comment. This comment applies to only oneline of text. To use it, start the line with --. Anything on the right side of -- is part of acomment and would not be considered as code. Here is an example:-- =============================================-- Database: MotorVehicleDivision-- =============================================/* First find out if the MotorVehicleDivision database wewant to create exists already.If that database exists, we dont want it anymore. So,delete it from the system. */-- Now that the database is not in the system, create itThe End of a StatementIn SQL, after writing a statement, you can end it with a semi-colon. In fact, if you plan touse many statements in one block, you should end each with a semi-colon. When manystatements are used, some of them must come after others.Time to GOTo separate statements, that is, to indicate when a statement ends, you can usethe GOkeyword (in reality and based on SQL standards, it is the semi-colon that would berequired, but the Microsoft SQL Server interpreter accepts GO as the end of a statement).Practical Learning: Closing Microsoft SQL ServerTo close Microsoft SQL Server, on the main menu, click File Exit.If you are asked whether you want to save something, click No

×