1. Trang chủ
  2. » Công Nghệ Thông Tin

Instructor InputsSession 2..Session OverviewThis session includes the following topics: pptx

18 211 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 18
Dung lượng 1,02 MB

Nội dung

Instructor Inputs Session 2 ¤NIIT Instructor Inputs 2.3 This session includes the following topics:  Functions to customize the result set in SQL Server 2005  Best practices  Tips and Tricks  FAQs Slide 1 Installing Windows XP Professional Using Attended Installation Slide 1 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 Objectives In this session, you will learn about: Functions to customize the result set in SQL Server 2005 Best Practices while using procedures and functions in SQL Server 2005 Tips and Tricks that will help you use functions in SQL Server 2005 FAQs related to general data types and functions in SQL Server 2005 Session Overview 2.4 Instructor Inputs ¤NIIT Slide 2 Installing Windows XP Professional Using Attended Installation Slide 2 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 Knowledge Byte SQL Server 2005 provides many in-built functions to Customize the Result Set: String functions: Are used to manipulate the string values in the result set. Date Functions: Are used to manipulate datetime values. Are used either to perform arithmetic operations on date values or parse the date values. Ranking Functions: Are used to generate sequential numbers for each row or to give a rank based on specific criteria. Slide 3 Installing Windows XP Professional Using Attended Installation Slide 3 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 Knowledge Byte (Contd.) System Functions: Are used to query the system tables. System tables are a set of tables that are used by the SQL Server to store information about users, databases, tables, and security. Are used to access the SQL Server databases or us er-related information. ¤NIIT Instructor Inputs 2.5 Slide 4 Installing Windows XP Professional Using Attended Installation Slide 4 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 Best Practices Never start the name of any stored procedure you create, with the SP prefix. This is because all system stored procedures start with the SP prefix. Avoid using the INSERT statement when performing bulk inserts into your database. To reference a table from another database in the same server, prefix the table with the database name. Use the following syntax to refer a table from another database in the same server: SELECT * from [<database name>].[dbo].[< table name>] Slide 5 Installing Windows XP Professional Using Attended Installation Slide 5 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 Tips and Tricks Use SPACE() function for concatenating values in a query. Use VARCHAR(max) data type with LEFT(), RIGHT(), SUBSTRING() functions because these functions do not support ntext and text data types. Analyze all your query plans by using the SQL Query Analyzer to ensure that they are performing at optimum speed. 2.6 Instructor Inputs ¤NIIT Slide 6 Installing Windows XP Professional Using Attended Installation Slide 6 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 Tips and Tricks (Contd.) Avoid the use of nullable columns: The use of the nullable column consumes an extra byte on each column used and while querying data, there is much more overhead with nullable columns. Slide 7 Installing Windows XP Professional Using Attended Installation Slide 7 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 What is the difference between the DELETE and TRUNCATE commands? The DELETE command removes the rows from a table based on the condition provided with the WHERE clause. The TRUNCATE command removes all the rows from a table and does not give an option to selectively delete records. FAQs ¤NIIT Instructor Inputs 2.7 Slide 8 Installing Windows XP Professional Using Attended Installation Slide 8 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 How can you figure out if a string is completely in uppercase? You can find if a string is completely in uppercase by using the ASCII string function. FAQs (Contd.) Slide 9 Installing Windows XP Professional Using Attended Installation Slide 9 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 Can you define any length for a VARCHAR data type, such as VARCHAR(10000)? When the length is specified in declaring a VARCHAR variable or column, the maximum length allowed is 8000 characters. If the length is greater than 8000 characters, you have to use the MAX specifier as the length. FAQs (Contd.) 2.8 Instructor Inputs ¤NIIT Slide 10 Installing Windows XP Professional Using Attended Installation Slide 10 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 If there are VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) data types, are there CHAR(MAX), NCHAR(MAX) and BINARY(MAX) data types also? No, there is no CHAR(MAX), NCHAR(MAX), or BINARY(MAX) data types. The main reason why the MAX specifier is not included for these data types is because these data types are fixed-length data types. If the MAX specifier is included for these data types, it will be a big waste of disk space as each column will consume 2 GB of memory even if only a short string value is assigned to the column. FAQs (Contd.) Slide 11 Installing Windows XP Professional Using Attended Installation Slide 11 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 How can you turn on IDENTITY on an existing column? To change an existing column as an IDENTITY column, perform the following steps: Modify table in object browser. Change column property to IDENTITY “yes”. Save the change. FAQs (Contd.) ¤NIIT Instructor Inputs 2.9 Slide 12 Installing Windows XP Professional Using Attended Installation Slide 12 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 Challenge Identify the output of the following command: Select left(‘SQL Server’,3) Ser SQL ver QL S Answer: SQL Slide 13 Installing Windows XP Professional Using Attended Installation Slide 13 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 Challenge (Contd.) Which function is used to return the length of a string? length lenString StrLen len Answer: len 2.10 Instructor Inputs ¤NIIT Slide 14 Installing Windows XP Professional Using Attended Installation Slide 14 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 Challenge (Contd.) Which string is used to replace a character with another character? charindex Space stuff patindex Answer: stuff Slide 15 Installing Windows XP Professional Using Attended Installation Slide 15 of 21 Ver. 1.0 Querying, Managing, and Administering Databases Using SQL Server 2005 Collaborate Session 2 Challenge (Contd.) Which method returns the current date and time? getdate date gettime time Answer: getdate [...]... into the following categories: Entity integrity: Ensures that each row can be uniquely identified by an attribute called the primary key Domain integrity: Ensures that only a valid range of values is stored in a column It can be enforced by restricting the type of data, the range of values, and the format of the data Referential integrity: Ensures that the values of the foreign key match the value of the. .. discuss the different constraints which can be applied to a table to enforce data integrity Instructor Inputs You can conduct the discussion as follows: Move the discussion toward different categories of data integrity Continue the discussion by mentioning the different types of constraints Relate each constraint with the data integrity category Solution Data integrity is enforced to ensure that the data... Collaborate Session 2 Slide 17 of 21 Instructor Inputs 2.11 Slide 18 Installing Windows and Administering Databases Using SQL Server 2005 Querying, Managing,XP Professional Using Attended Installation Challenge (Contd.) What does >ALL mean in a SELECT statement that is using a subquery? It means greater than the maximum value in the list It means any of the values in the list It means greater than the minimum... 2.12 Instructor Inputs Collaborate Session 2 Slide 19 of 21 NIIT Slide 20 Installing Windows and Administering Databases Using SQL Server 2005 Querying, Managing,XP Professional Using Attended Installation Challenge (Contd.) What should be the size of a transaction log file? 25-40 percent of the database size 25-30 percent of the database size 25-35 percent of the database size 22-40 percent of the. .. not belong to the entity, domain, and referential integrity categories When creating tables, the SQL Server allows you to maintain integrity by: Applying constraints Applying rules Using user-defined types Constraints can be divided into the following types: Primary key constraint: Ensures the entity integrity Unique constraint: Ensures the entity integrity Foreign key constraint: Ensures the domain and... It means greater than the maximum value in the list It means any of the values in the list It means greater than the minimum value in the list It means lesser than the minimum value in the list Answer: It means greater than the maximum value in the list Collaborate Session 2 Ver 1.0 Slide 18 of 21 Slide 19 Installing Windows and Administering Databases Using SQL Server 2005 Querying, Managing,XP Professional... Foreign key constraint sp_bindrule Instructor Inputs 2.15 Collaborative Exercise The major requirement of any organization or an enterprise is to store complete and consistent data Data integrity is the concept of maintaining consistency and completeness of data Data integrity is enforced to ensure that the data in a database is accurate, consistent, and reliable Discuss the broadly classified categories... constant expressions? BETWEEN IN ALL LIKE Answer: IN Ver 1.0 NIIT Collaborate Session 2 Slide 21 of 21 Instructor Inputs 2.13 Solutions to Challenge 1 2 3 4 5 b SQL d len c stuff a getdate c float 2.14 Instructor Inputs NIIT Home Assignment 1 Which join should be used to retrieve records with values satisfying the join condition in the common column? a Outer Join b Inner Join c Cross Join d Equi Join 2 Which... Unique constraint: Ensures the entity integrity Foreign key constraint: Ensures the domain and referential integrity 2.16 Instructor Inputs NIIT Check constraint: Ensures the domain and referential integrity Default constraint: Ensures the domain integrity NIIT Instructor Inputs 2.17 2.18 Instructor Inputs NIIT ... Installation Challenge (Contd.) What is the return type of rand function? numeric int float smallint Answer: float Collaborate Session 2 Ver 1.0 Slide 16 of 21 Slide 17 Installing Windows and Administering Databases Using SQL Server 2005 Querying, Managing,XP Professional Using Attended Installation Challenge (Contd.) Which join returns the Cartesian Product of the rows of two tables? EQUI JOIN INNER . Instructor Inputs Session 2 ¤NIIT Instructor Inputs 2. 3 This session includes the following topics:  Functions to customize the result set in SQL Server 20 05  Best practices. Server 20 05 Collaborate Session 2 What is the difference between the DELETE and TRUNCATE commands? The DELETE command removes the rows from a table based on the condition provided with the WHERE. percent of the database size 22 -40 percent of the database size Answer: 25 -40 percent of the database size Slide 21 Installing Windows XP Professional Using Attended Installation Slide 21 of 21 Ver.

Ngày đăng: 31/07/2014, 15:20

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN