Beginning SQL Server 2012 for Developers by Robin Dewson
Author:Robin Dewson
Language: eng
Format: epub
Publisher: Apress®
Published: 2012-04-24T16:00:00+00:00
In the following exercise, you will use SQL Server Management Studio to see the effects of not populating a field defined as NOT NULL. The exercise also demonstrates how to edit rows of data using SSMS and how there can be dangers in this approach. You will see what happens to the IDENTITY values when an insertion has a problem and is not inserted. It is important to see these effects, and so you need to see errors being generated.
When using SQL Server Management Studio, it is not always immediately apparent what data are valid in each column or if a column is NULL or NOT NULL. If you enter invalid data or leave a column empty, when in fact it should have data (i.e., isn't set to accept NULL values), you will receive an error message. An IDENTITY column is protected.
Editing data within SSMS can be quick and easy and has the potential of some trouble when entering data. SQL Server provides the ability to edit data by displaying an editable grid, not dissimilar to basic Excel. A new toolbar will be displayed, providing you with the options to let you work with the data. You will see this in the following exercise and how you can use this toolbar to access the underlying T-SQL that is used to provide the data for the grid. Once the toolbar is visible, by individually clicking the first four buttons, you can see your Management Studio display alter to show more and different information. You will be able to toggle the visibility of a pane diagramming the tables and relationships, the selection criteria, the SQL, and finally the results. This toolbar comes into its own when working with data, as you are seeing, but also when building views; you will see the toolbar again in Chapter 11. When you use the grid for working with data, as you will do when developing a system, then you may find these buttons useful, especially the SQL button.
TRY IT OUT: NULL VALUES AND SQL SERVER MANAGEMENT STUDIO
Ensure that SQL Server Management Studio is running and that you are logged in with an account that allows the insertion of records. Any of your users can do this.
Expand the ApressFinancial node in Object Explorer so you can see the CustomerDetails.Customers table. Right-click this table and select Edit Top 200 Rows.
In the main pane on the right, you should now see a grid similar to Figure 9-3. This grid would usually show all the rows of data that are within the table, but as this table contains no data, the grid is empty and ready for the first record to be entered. Notice that a star appears on the far left-hand side. The star is the record marker and denotes which record the grid is actually pointing to and working with for insertion. It will change to an arrow shortly. The arrow denotes which record you are viewing. When the marker changes to a pencil, it denotes that
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
What's Done in Darkness by Kayla Perrin(25499)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(18219)
Shot Through the Heart by Mercy Celeste(18160)
The Fifty Shades Trilogy & Grey by E L James(17774)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(13189)
The Subtle Art of Not Giving a F*ck by Mark Manson(12912)
Scorched Earth by Nick Kyme(11831)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(11040)
Drei Generationen auf dem Jakobsweg by Stein Pia(10216)
Suna by Ziefle Pia(10185)
Scythe by Neal Shusterman(9259)
International Relations from the Global South; Worlds of Difference; First Edition by Arlene B. Tickner & Karen Smith(8608)
Successful Proposal Strategies for Small Businesses: Using Knowledge Management ot Win Govenment, Private Sector, and International Contracts 3rd Edition by Robert Frey(8419)
This is Going to Hurt by Adam Kay(7694)
Dirty Filthy Fix: A Fixed Trilogy Novella by Laurelin Paige(6453)
He Loves Me...KNOT by RC Boldt(5804)
How to Make Love to a Negro Without Getting Tired by Dany LaFerrière(5378)
Interdimensional Brothel by F4U(5304)
Thankful For Her by Alexa Riley(5161)