Download presentation
Presentation is loading. Please wait.
Published byRichard Taylor Modified over 9 years ago
1
1 Working with MS SQL Server II
2
2 The sqlcmd Utility Command line utility for MS SQL Server databases. Previous version called osql Available on classroom and lab PCs. Free download from Microsoft google sqlcmd download In Windows command window Connect to a Database Server Enter SQL commands on the command line. Results output to the console.
3
3 Getting and Installing sqlcmd Included with Management Studio Express. Free download from Microsoft, Documentation available in SQL Server 2005 Books Online Free download from Microsoft. In Visual Studio 2008 Help search for sqlcmd.
4
Visual Studio Search Result
5
5 The SQL Language The following slides demonstrate SQL commands using the sqlcmd program. Remember SQL is used everywhere we interact with a database server: Command line Database management programs Including Visual Studio Server Explorer Our own programs (in the form of strings)
6
Using sqlcmd In order to use sqlcmd with the SQL Server on scorpius you will need a VPN connection. See: http://www.cse.usf.edu/~turnerr/Software_Systems_Development/ 073a_Working_with_MS_SQL_Server.pdf http://www.cse.usf.edu/~turnerr/Software_Systems_Development/ 073a_Working_with_MS_SQL_Server.pdf The following slides use the addresses table that we created and populated in a previous class. Slides 9 - 37 of same presentation.
7
7 Using sqlcmd The Server My Username Password entered here Execute commands in buffer
8
8 SQL Command Line Example View a subset of the columns.
9
9 Retrieve Specific Entries Find all addresses with zip code 33707
10
10 Wildcard Selection Find all addresses with last name beginning with S
11
11 Wildcard Selection All addresses with last name containing an s
12
12 Case Sensitivity Typically SQL commands and keywords are not case sensitive. Data is case sensitive Characters are stored as upper case or lower case. Sorting order is a mode Default is not case sensitive Search comparisons same as sorting order. http://sqlserver2000.databases.aspfaq.com/how-can-i-make-my- sql-queries-case-sensitive.html http://sqlserver2000.databases.aspfaq.com/how-can-i-make-my- sql-queries-case-sensitive.html
13
13 Case Sensitivity
14
Case Sensitive Select 14
15
Case Sensitivity You can make the default for a column case sensitive. See: http://social.msdn.microsoft.com/Forums/en- US/sqlsetupandupgrade/thread/850deb43-18ff-492b-bec0-b2b9a7ad76ac http://social.msdn.microsoft.com/Forums/en- US/sqlsetupandupgrade/thread/850deb43-18ff-492b-bec0-b2b9a7ad76ac Or google mssql collate 15
16
16 Sorting the Output Zip_Code is a string. So sort is lexicographic, not numeric.
17
17 Counting Rows How many addresses are there with zip code 33707?
18
18 Updating Records
19
19 Updating Records
20
20 Updating Multiple Fields
21
21 Deleting a Record
22
22 SQL Commands in Visual Studio We can also use Visual Studio to issue arbitrary SQL commands to the server. On the Data menu select New Query
23
23 SQL Commands in Visual Studio
24
24 SQL Commands in Visual Studio Click here
25
25 SQL Commands in Visual Studio Enter SQL command here.
26
26 SQL Commands in Visual Studio Click here to execute the command.
27
27 SQL Commands in Visual Studio Results appear below the Query window.
28
28 Learning SQL Many books available One that I recommend: Teach Yourself SQL in 24 Hours (Third Edition) Ryan Stephens and Ron Plew, SAMS, 2003 Lots of information on the web A sampling: http://en.wikipedia.org/wiki/SQL http://www.w3schools.com/sql/default.asp http://db.grussell.org/ch3.html
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.