Entorno de sql server 2005


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Entorno de sql server 2005

  1. 1. The SgL Seroer 2005Express Encironment Although its the most junior member 01 the family, SQL Ser ver 2005 Express has more than enough capabtlíües and power to support the majority 01 database-driven applications. You should be aware 01 these key features- along with sorne limitalions - as you build your solulion: " Robust technology platform: SQL Server 2005 Express is built on the same underlying technology platform as all the Microsoft SQL Ser ver products. Thís significantly increases this products effectiveness and stability. " Interoperability and upgradeability: Because SQL Server 2005 Express is built on the underlying SQL Server 2005 platform, you can easily develop solutions that work with any SQL Server 2005 edilion. In addi- tion, you can straightforwardly migrate from this entry-level edilion to a more lull-featured edition wíthout changing your database design or altering any applicalion or stored procedure/trigger codeo " Memory: With memory costs dropping stgníficantly over lime, many administrators now stock thelr computers with large amounts 01 RAM. However, regardless of how much mernory you have, SQL Server 2005 Express doesnt take advantage of any more than 1GB 01 RAM. " Automatic performance tuning: This Is one feature that SQL Server 2005 Express shares with the other database edilions. It lightens the administralive load by automalically updatíng the databases configura- tion based on system activilies and other profiling data. However, no automation can free you from the performance ímplicatíons of an inefficient database or application construction: You are sttll responsíble íor designing your database structure and software logic with speed in mind. " Database size: This is probably the most significant limitation oí SQL Server 2005 Express, because any given database cant be bigger than 4GB. Although thís limitation wont be a probiem for many applicatians, certain data-intensive solutions can test it. Of course, you are free to have multiple databases that are each 4GB. " FuU security capabilities: Heres another area where this edition and the more costly versions of SQL Server 2005 basically have no differences. This means that you can take advantage of a broad band 01 security lea- tures as you go about developing your solutions. These range lrom authentication and auditing all the way through public key management and encryption.
  2. 2. _________ Chapter 1: SOL Server 2005 Express Overview 13 ¡; Multi-processors: Running a computer with more than one central pro- cessing unít (CPU) is a great way to increase performance and through- put. However, SQL Server 2005 Express only takes advantage 01 one CPU, regardless 01 how many are available. ¡; Administrative tools: Microsoft oíters the excel!ent SQL Ser ver Management Studio Express graphical tool to help you monitor and manage your database. Its available tor free download írom Microsofts Web site. ¡; Visual Studio integration: Although SQL Ser ver 2005 Express is consid- ered an entry-Ievel product, youre free to use the fuI! power 01 Microsofts f1agship development platform, Visual Studio. This product is fully ínte- grated with al! the SQL Server 2005 database offeríngs, including Express. Figure 1-1 shows you what this looks like, in the context of building a C# class file. ¡; Full-text searching: This leature helps you index and then query large blocks 01 text-based inforrnatíon. Although its not present in SQL Ser ver 2005 Express, you will find it in SQL Server 2005 Express with Advanced Services. Regardless of which version you use, your applícation can stil! sto re and work with this kind 01 information; the method you use might vary, however.
  3. 3. " High availability features: The enlire SQL Server 2005 product family offers numerous lechnologies lo help keep your dalabase up and run- ning al al! limes. However, Express doesnt offer lhese capabililies, al! of which reduce down lime or help improve performance: • Online restore • Database mirroring • Partitioning • Failover c1ustering • Online indexing If youre building a mission criticaI application and continual uptime is of vilal imporlance lo you, you may want to deploy your solution on one of the other SQL Server 2005 edilions. " Rich prograrnming language choices: The enlire SQL Ser ver 2005 prod- uct líne supports lhe Mlcrosoft Common Language Runlime (CLR). This mean s that you can develop ínternal dala base logre such as stored pro- cedures and lriggers in any one of a number of popular programming languages, rather than in SQL Servers internal programming language: Transacl-SQL. " AnaIysis services: The more advanced edilions of SQL Server 2005 lea- lure business analytic logic that you can use lo help make sense of your information. This is especíally true if your environment sports massive volurnes of dala that need lo be crunched lo come up wíth recognizable patterns. The bad news is that thís ís not present in SQL Server 2005 Express. However, lhe good news is that chances are that if lhese kinds of dala are found in your organizalion, youll have already purchased one of lhe many third-party business inlelligence producls. " Reporl server: Users always want more íníorrnatíon out of their dala- base. Wilh SQL Server 2005s reporling services, you can sel up a wide range of developer-driven and user-driven reports. You can lhen inte- grate and deliver lhese communiqués lhrough a series 01 differenl pre- sentalion lechnologies. Happily, youll find lhese capabllítíes present in SQL Ser ver 2005 Express wíth Advanced Services, whieh should help please lhose ñnícky users. If youre eurious about how lhese features work, take a look al Chapler i8 for lhe detaíls." Integralion services: These features al!ow you lo wrile powerful íntegra- tíon logic that can take íníormatton from a broad range of other dala slorage locattons and lhen store il inside SQL Server. The same holds lrue for oulbound dala. Unforlunalely, you won 1 find lhese services pre- senl in SQL Server 2005 Express. Luckily, thís doesnt mean that you carit íntegrate dala among disparate systems; il just means that you may have to do Sorne more work to achieve the same results." Notification services: This reters lo the capabthty, found only in lhe more fealure-rieh edtttons of SQL Server 2005, lo build sophislicaled publish-and-subscribe applications. Once created, these appliealions
  4. 4. can properly react to a wide variety 01 events, notifying all interested parties that an event has occurred. SQLServer 2005 Express does let you take advantage of replícatlon, but only as a subscriber. " Backup/recovery optíons: Because backup and recovery are a vital part 01 any data integrity and reliability pian, SQLServer 2005 olfers adrnínis- trators a choice among several different recovery models, each 01 which has its own strengths and weaknesses. However, your data-archiving chotees are somewhat more reduced lor SQLServer 2005 Express. You can slill set up a very robust backup and recovery strategy; its just not as lull leatured as in the more advanced editions 01 SQLServer. In partic- ular, because the SQLServer Agent is not present, you worit be able to schedule jobs or configure alerts and operators.Where Does SgL Seroer Express 2005Work Best] SQLServer 2005 Express brings a lot to the table, but when do es it make sense to choose it as your data storage platform? I answer this queslion in this sectíon, Smal! office/Home office (SOHO) Small offices and home olfices (SOHO) are olten caught between a rack and a hard place when dealing with software and solutions. Eíther the technology is underpowered and sirnplistic, not quite meeting their needs, or its expen- sive, overly complex, and resource íntensive. SQLServer 2005 Express strikes a nice balance between simplicity and power, while holding the cost as low as you can possibly gel. Plus, because many small businesses one day find themselves morphed (or acquired) into larger enterprises, making this database server the cornerstone 01 your data storage architecture means that you never outgrow your database: You can easily upgrade to SQL Server 2005 Enterprise. On top 01 that, the lact that SQLServer 2005 Express is a true relational data- base management platform means that you can store and track just about anything in your database. Sorne parlicularly good applications include " Inventor y details " Sales stalistics v Financial rnetrics
  5. 5. ~ Via lhe Internet: If you have a fast Internet connection, you can quickly and easily download SQLServer 200S Express. Heres all you need to do: l. Point your browser lo http://www.microsoft.com/sql. 2. Click lhe DownIoads link. You shouId now see a link lor SQLSer ver 200S Express. 3. Review lhe System Requirements and Instructions before down- Ioading your producto I describe sorne 01 these system requírernents in the next sectíon. YoulI be presented with a potentíally bewildering array of SQLServer 200S Express downloads on Microsofts Web site. Heres a brief overview 01 each 01 the available products: • Baseline SQL Server 2005 Express: This is the standalone, entry- level SQLServer database lound in SQLEXPR. EXE. • SQL Server 2005 Express wilh Advanced Services: This is the nextlevel up in database power and capability, yet its still free! If youre interested in enhanced reporting services and full-text searching, thís míght be the edition ter you (see Chapter 18). Its in a file entitled SQLEXPR_ADV. EXE. • SQL Server Management Studio Express: This ís an excellent, powerful, yet easy-to-use database administratlon and interaction tool. I strongly recommend getling a copy; you wont regret il. • SQL Express tooIkit: It youre interested in developing reports with SQLServer 200S Express with Advanced Services, the Business Inteiligence Development Studio contained in this toolkit is a must-have, Ifyou cant get to SQLServer 200S Express via the preceding instruc- tions, just use the Search feature on the Microsoft Web síte to tind it quickly.~ Via Visual Studio 2005: SQLServer 200S Express is part of a larger group 01 low-priced Microsoft offerings, known as the Express editions. These products are aimed at a wide audience of developers that might not have used these types 01 solutions belore, and include • Visual Basic 200S Express Edilion (which is conveniently on this books CD) • Visual Web Developer 200S Express Edítion • Visual C# 200S Express Editton • Visual CH 200S Express Edilion • Visual J# 200S Express Edition Microsoft also bundles SQLServer 200S Express with Visual Studio 200S, which ís available lor purchase either stand-alone or via the Microsoft Developer Network (MSDN).
  6. 6. " Via the CD lhat ships wilh lhis book: To make things even easier for you, a lully íunctíonal copy 01 SQL Server 2005 Express with Advanced Servíces is on the CD that comes with this book. You can read more about it in Appendix D.Before YOU lnstatl Although popping in the CD or poíntíng your browser at the Microsoft Web site and then downloading and installing SQL Server 2005 Express is tempting, you need to make sure that your computer meets sorne minimal requirements. Otherwise, you could be faced with a long and lrustrating troubleshooling session, trying to figure out why things are running poorly (or even not at allí). Take the time to go through each 01 these rnajor system readiness categories, making sure that you meet or exceed each 01 these prerequisites. Also, if youre installing SQL Server 2005 Express on mulliple machines, remember that the machine that acts as a central server generally requíres faster and better hardware than one that primarily acts as a client. Finally, you need to have administralive privileges on the computer where youre installing SQL Ser ver 2005 Express. " CPU: For optimal performance, you want at least a 600 MHZ CPU, although things might be kind of sluggish at that speed. Using a IGHZ CPU definitely makes things peppier and is recommended. " Memory: Because sufficient memory serves as the loundation of any well-performing relalional database, make sure that you provide 512MB or more, as recommended by Microsoft. You could probably get away with 192MB (minimum), but youre pushing things at that leve!. In gen- eral, just as you cant be too rich or too thin, you cant provide a rela- tíonal database with too much CPU or memory, although SQL Ser ver 2005 Express will not use more than 1GB 01 RAM. " Disk: Given lhat relational databas es use disk drives as their primary storage mechanism, recommending a hard-and-Iast value for the right amount 01 available disk capacity is difficult: Every installalion ís differ- ent. Just the product and its related files take up more than 500MB of disk space: youlllikely want to add one or two gigabytes on top 01 that lor your data. " Operating system: Microsoft gives you a fairly wide choice 01 operaling systems that can run SQL Server 2005 Express. They include • Windows Ser ver 2003 • Windows Small Business Server 2003 • Windows XP Home Edilion • Windows XP Media Center Edítíon
  7. 7. • Windows XP Professional Edition • Windows XP Tablet PC Edition • Windows 2000 Advanced Server • Windows 2000 Professional Edition • Windows 2000 Server Be prepared to apply the latest servíce pack for your operating system; in many cases, SQLServer 2005 Express depends on these patches. Y Supporting software: Because its built on top of sorne of Microsofts newer technologies, SQLServer 2005 Express requires that you install sorne additional software technologies, specifically the Microsoft .NET Framework 2.0. You also may be required to deploy the new Microsoft Windows Installer software. In addition to facilitating software ínstalla- tion, this new product also checks whether your Windows software ís licensed correctly. Both of these products are free, and available for download from the Microsoft Web site. Y lf you plan to use the Advanced Services edilion, and are interested in its reporting capabililies, make sure that you have Microsoft Internet Information Services installed 00 your computer.Instaltint) SgL Sercer 2005 Express Kudos to you if you took the lime to read the previous seclion that described the prerequisites for installing SQLServer 2005 Express. And if you didnt, thats okay, too. Now all you need to do is breeze through a few simple steps, and youre ready to start using your new database. Heres how to get SQL Ser ver 2005 Express up and running: 1. Remove old software. lf youve installed any beta editions of SQLServer 2005 Express or the SQLNalive Client, you need to uninstall them vía the Control Pane!s Add and Remove Prograrns utility. 2. Back up your system. It may seem a bit excessive, but youll never regret taking the time to make a backup copy of your important ínforrnatíon. lf things go wrong, you have a way of restoríng your data. And if things go fine (which they probably will), youve still safeguarded your computer. 3. (Optional) Defragment your dísks. This may not seem like the time to defragment your dísks, but in fact its a great opportuníty to give SQLServer 2005 Express sorne nice, clean, well-organízed space with which to work. Over time, data on your disk drives gets fragmented, and spreads across the entíre disk. This can
  8. 8. hurt performance of all applications; SQL Server 2005 Express is no exceptíon. Heres how to defragment your disk: a. Launch tbe Windows Disk Defragmenter. YoulI find ít vía Start<>Programs<>Accessories<>System Toolsso Disk Defragmenter. b. Click tbe Analyze button, The Disk Defragmenter analyzes your disk and returns a recom- rnendatíon (see Figure 2-1). c. If the Disk Defragmenter recommends tbat you defragment your disk, c1ick the Defragment button. This may take sorne time to complete, but be patient: Its worth ít. f¡ee SpIal 14.1408 ,,~ %Free~ "H. " Estlmated disk usaaa beft!,e defragmentalion" ~111~llllm~I~I[ ~11 Estimated disk usage--ªfiiLde1"r:i..QmenlatiQn" Disk Defragrnanter Figure2-1: AnaIysls;,; COIIlIIet"IQ(~ (C=) A disk that YOJ shcUddeh~ ~~,needs to be defrag- mentad. Il 11~·~F.:g~m:,":"d~~j,~~_===~ t ._._ ..=. ~~~.~. I I "" •••••• I I ===-1------1 0= 4. Install tbe Microsoft .NET Framework. This is the íoundation on whích SQL Ser ver Express was built. You can download It for free frorn the Microsoft Web site. In fact, you will find a handy link to it right on the SQL Ser ver 2005 Express download page. 5. Run tbe SQL Server 2005 Express installer programo lf you install SQL Server 2005 Express via the Visual Studio installer, you may have a slightly different set 01 instructions. After you launch the installer, you see a screen similar to Figure 2-2. Once these initial tasks are out of the way, the SQL Server 2005 Express Installation Wizard launches, which is shown in Figure 2-3.
  9. 9. Part 1:Welcome lo Sal Server 2005 Express _ che best way to make sure that your installation went well is simply to try to connect to your SQLServer 2005 Express database server and then run sorne basic database operations. Just follow these steps: 1. Make sure the SQL Server 2005 Express service is running. Normally, thís servíce ís started as part of the installation process. However, making sure that it started correctly is a good idea. Follow these steps to check it: a. Locate the My Computer icon on your desktop or on !he Start menu. b. Ríght-click it, and choose !he Manage option. c. Expand the Services and Applications folder. d. Double-clíck the Services entry in thís folder. You see a Iist of all servíces (running or not) on your computer, along with whether theyre started automatically or manually. e. Scroll down !he list of services. Look for the SQLServer (SQLEXPRESS) ntry. To see if its runníng, e look in the Status column. You can also see if it automatically launches by checking the Startup Type column. If its runníng, you dont need to go on to the next steps. f. Highlight the SQL Server entry, and then ríght-clíck it. g. Choose the Start option. SQLServer 2005 Express service starts running. Ifyou want to have lhe ser vice start automatically, choose the Properties option and then select the Automatíc oplion from the Startup Type drop- down menu. 2. Launch SQL Server Management Studio Express Edition. Ifyou dorrt have this tool in your environment, I show you how to use the character-based SQLCMDulility in the set of numbered steps follow- ing thís one. 3. Connect to your SQL Server 2005 Express database. When you try to connect to your database, youre prornpted for a server instance connectton string. This can get a Iittle tricky; SQLServer 2005 Express is rather picky about the exact syntax. Assuming you chose the deíaults when installíng, just specify your string Iike this: Computer namesqlexpress
  10. 10. SO, if your computer ís called Ti tan, your server instance connection string would look Iike this: Titansqlexpress 4. Expand !he System Databases folder. 5. Make sure that the four system databases are present: • master • model • msdb • tempdb With these databases in place. youre now ready to create a test data- base 01 your own. 6. Highlight!he Databases folder, and then ríght-click it, 7. Choose the New Database option. 8. Create a database wi!h any name that you Iíke. You dont need to fiddle with the settings; just choose the delaults. If everything goes well, you see this new database Iisted under the Databases lolder. 9. Delete the database. Unless you want to keep this database around lor real work, you can safely delete it: a. Higbligbt tbe new database in the Databases folder, and then ríght-clíck its entry. b. Choose the Delete option from the menu. C. Confirm that you want to delete thís database. 10. You can now close SQL Server Management Studio Express. The database ser ver continues running, even if you disconnect.For those 01 you with no access to SQL Server Management Studio, heresanother way to connect to the database - usíng the SQLCMD utility - andtest your installation. 1. Open a command prompt, You can do thís by choosing Start-okun, and entering cmd. Another way to do this is to choose Start<:>Programs<:>Accessories<:>Command Prompt. After you see the friendly command prompt, its ~ime to launch SQLCMD.
  11. 11. "2. Type SQLCMD, and ínclude the proper parameters. Thís can get a bit conlusing: SQLCMD ís rather picky about the exact syntax that it deigns to runo This ís not surprísing when you realíze that it supports over two dozen parameters. This table híghlíghts a small group 01 key parameters: Parameter Purpose -s Specify the server that you want to connectto -u Provide your username -P Provide your password -d Which database to use lf you get ín hot water, you can always ask SQLCMD for help: SQLCMD !? 3. Type the following SQL: CREATE DATABASE install_test GO lf you receíve another prompt (that ís, no error message), then every- thíng ís fine. [f you want to drop thís test database, just type the follow- ing SQL: DROP DATABASE install_test GOThats all you have to do! You now have a workíng SQL Server 2005 Expressdatabas e server,