Documente Academic
Documente Profesional
Documente Cultură
1.
2. 3.
Click Start, point to Programs, point to Microsoft SQL Server 2005, point toConfiguration Tools, and then click SQL Server Surface Area Configuration. On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections. On the Surface Area Configuration for Services and Connections page, expandDatabase Engine, click Remote Connections, click Local and remote connections, click the appropriate protocol to enable for your environment, and then click Apply. Note Click OK when you receive the following message:
Changes to Connection Settings will not take effect until you restart the Database Engine service.
4.
On the Surface Area Configuration for Services and Connections page, expandDatabase Engine, click Service, click Stop, wait until the MSSQLSERVER service stops, and then click Start to restart the MSSQLSERVER service.
1.
2. 3.
Click Start, point to Programs, point to Microsoft SQL Server 2005, point toConfiguration Tools, and then click SQL Server Surface Area Configuration. On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections. On the Surface Area Configuration for Services and Connections page, click SQL Server Browser, click Automatic for Startup type, and then click Apply. Note When you click the Automatic option, the SQL Server Browser service starts automatically every time that you start Microsoft Windows. Click Start, and then click OK.
4.
Note When you run the SQL Server Browser service on a computer, the computer displays the instance names and the connection information for each instance of SQL Server that is running on the computer. This risk can be reduced by not enabling the SQL Server Browser service and by connecting to the instance of SQL Server directly through an assigned TCP port. Connecting directly to an instance of SQL Server through a TCP port is beyond the scope of this article. For more information about the SQL Server Browser server and connecting to an instance of SQL Server, see the following topics in SQL Server Books Online:
y y y
SQL Server Browser Service Connecting to the SQL Server Database Engine Client Network Configuration
1.
2. 3.
Click Start, point to Programs, point to Microsoft SQL Server 2005, point toConfiguration Tools, and then click SQL Server Configuration Manager. In SQL Server Configuration Manager, click the SQL Server Browser service in the right pane, right-click the instance name in the main window, and then click Properties. On the SQL Server Browser Properties page, click the Advanced tab, locate the instance ID in the property list, and then click OK.
To open Windows Firewall, click Start, click Run, type firewall.cpl, and then click OK.
1.
2. 3.
In Windows Firewall, click the Exceptions tab, and then click Add Program. In the Add a Program window, click Browse. Click the C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe executable program, click Open, and then click OK. Note The path may be different depending on where SQL Server 2005 is installed.MSSQL.1 is a placeholder for the instance ID that you obtained in step 3 of the previous procedure. Repeat steps 1 through 3 for each instance of SQL Server 2005 that needs an exception.
4.
Create an exception for the SQL Server Browser service in Windows Firewall
To create an exception for the SQL Server Browser service in Windows Firewall, follow these steps:
1.
2. 3.
In Windows Firewall, click the Exceptions tab, and then click Add Program. In the Add a Program window, click Browse. Click the C:\Program Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe executable program, click Open, and then click OK. Note The path may be different depending on where SQL Server 2005 is installed.
y y y y
Blocking System resource contention Application design problems Queries or stored procedures that have long execution times
Identifying these causes is typically very time consuming, and you may spend several days evaluating the collected information. The complexity of the performance analysis is not specific to a particular database product or operating system. All applications are subject to performance constraints because of resource, design, or usage factors. For more information, click the following article number to view the article in the Microsoft Knowledge Base: 224587 How to troubleshoot application performance with SQL Server To help identify and troubleshoot the problem, collect the following information at the same time and have the output readily available before you contact Microsoft Product Support Services (PSS):
y y y
Blocker script output SQL Profiler trace log SQL Server Performance Monitor log
Note If you do not collect this information when the performance problem occurs, you may have to gather all the information again. This can delay the troubleshooting process. After the problem occurs, collect the following information and have it available:
y y
In most scenarios, PSS requires this information to understand the environment and the nature of the performance issue. If any part of this information is not available, the troubleshooting process may be prolonged and identifying the performance issue may be delayed. Even if you are currently not experiencing any performance issues, Microsoft recommends that you implement this process. If a performance issue occurs, you can capture the required information as soon as possible. Additionally, if you capture a baseline SQL Profiler log, SQL Server Performance Monitor log, and blocker script when the application is performing as expected, you can use that information for comparison when the application does not perform as expected. If you gather this information in a high traffic SQL Server environment, you may experience some performance degradation. However, you must have this information to identify the cause of the problem and for troubleshooting purposes. The SQL Profiler trace has the most impact on performance. If the performance is severely degraded, you can customize the SQL Profiler trace by reducing the types of events that it captures. Limiting the SQL Profiler trace should provide some improvement. If you have questions or problems setting up and collecting the information, contact PSS.
y y y y
You can use SQL Server Performance Monitor to identify how these potential bottlenecks may affect SQL Server. Additionally, you can use this log to identify when an external process is heavily using the computer running SQL Server and negatively impacting SQL Server performance. Before you start SQL Server Performance Monitor, make sure that the disk counters are on. To do so, run diskperf from a command prompt. If the disk counters are not on, run diskperf -yand then restart the computer. When you create a SQL Server Performance Monitor log, collect the following information:
y y y y y y y y y
Paging file Process Processor All SQL Server counters Memory Threads Logical disk Physical disk System
Note The default interval of 15 seconds should enough time to monitor the server; however, for some timing issues, you may have to reduce the time interval for collecting data. For more information about how to set up a SQL Server Performance Monitor log, click the following article numbers to view the articles in the Microsoft Knowledge Base: 150934 How to create a Performance Monitor log for NT troubleshooting 248345 How to create a log using System Monitor in Windows 2000
Note For more information about monitoring performance in SQL Server 2005, see the "Monitoring and Tuning for Performance" topic in SQL Server 2005 Books Online. Back to the top
sqldiag utility
The sqldiag utility is provided with SQL Server. It collects valuable information about the configuration of the computer running SQL Server, the operating system, and the information that is reported to the SQL Server error logs. For information about how to use the sqldiag utility, see the "sqldiag Utility " topic in SQL Server Books Online. For more information about how to run sqldiag on a clustered SQL Server, click the following article number to view the article in the Microsoft Knowledge Base: 233332 How to run SQLDIAG on a clustered/virtual SQL Server Note In SQL Server 2005, the SQLdiag utility has changed significantly. The command line arguments for this utility are not compatible with SQL Server 2000. This utility may be changed, and applications or scripts that rely on its command line arguments or behavior may not work correctly in future releases. For more information, see the "SQLdiag Utility" topic in SQL Server 2005 Books Online. Back to the top
By Don Schlichting
This article will explore the uses, restrictions and benefits of User Defined Functions in Microsoft SQL Server 2000
Introduction
User Defined Functions are compact pieces of Transact SQL code, which can accept parameters, and return either a value, or a table. They are saved as individual work units, and are created using standard SQL commands. Data transformation and reference value retrieval are common uses for functions. LEFT, the built in function for getting the left part of a string, and GETDATE, used for obtaining the current date and time, are two examples of function use. User Defined Functions enable the developer or DBA to create functions of their own, and save them inside SQL Server.
Before SQL 2000, User Defined Functions (UDFs), were not available. Stored Procedures were often used in their place. When advantages or disadvantages of User Defined Functions are discussed, the comparison is usually to Stored Procedures. One of the advantages of User Defined Functions over Stored Procedures, is the fact that a UDF can be used in a Select, Where, or Case statement. They also can be used to create joins. In addition, User Defined Functions are simpler to invoke than Stored Procedures from inside another SQL statement.
Scalar UDFs
Our first User Defined Function will accept a date time, and return only the date portion. Scalar functions return a value. From inside Query Analyzer, enter: CREATE FUNCTION dbo.DateOnly(@InDateTime datetime) RETURNS varchar(10) AS BEGIN DECLARE @MyOutput varchar(10) SET @MyOutput = CONVERT(varchar(10),@InDateTime,101) RETURN @MyOutput END To call our function, execute: SELECT dbo.DateOnly(GETDATE()) Notice the User Defined Function must be prefaced with the owner name, DBO in this case. In addition, GETDATE can be used as the input parameter, but could not be used inside the function itself. Other built in SQL functions that cannot be used inside a User Defined Function include: RAND, NEWID, @@CONNCECTIONS, @@TIMETICKS, and @@PACK_SENT. Any built in function that is non-deterministic. The statement begins by supplying a function name and input parameter list. In this case, a date time value will be passed in. The next line defines the type of data the UDF will return.
Between the BEGIN and END block is the statement code. Declaring the output variable was for clarity only. This function should be shortened to: CREATE FUNCTION testDateOnly(@InDateTime datetime) RETURNS varchar(10) AS BEGIN RETURN CONVERT(varchar(10),@InDateTime,101) END
MS SQL
May 7, 2004
By Don Schlichting
Multi Statement User Defined Functions are very similar to Stored Procedures. They both allow complex logic to take place inside the function. There are a number of restrictions
Next Steps
credit union ?
a cooperative depository financial institution whose members can obtain loans from their combined savings
Building Society ?
A building society is a financial institution, owned by its members, that offers banking and other financial services, especially mortgage lending. Re: Difference between sql server 2000 and sql server 2005?
1. In SQL Server 2000 the Query Analyzer and Enterprise Manager are seperate,whereas in SQL Server 2005 both were combined as Management Studio. 2. In Sql 2005,the new datatype XML is used,whereas in Sql 2000 there is no such datatype 3. In Sql server2000 we can create 65,535 databases,whereas in Sql server2005 2(pow(20))-1 databases can be created. How to simulate a deadlock for testing purposes? <top>
CREATE TABLE t1 (i int) CREATE TABLE t2 (i int) INSERT t1 SELECT 1 INSERT t2 SELECT 9 Open a new window (say Window1) in Query Analyzer, paste the following SQL statements: BEGIN TRAN UPDATE t1 SET i = 11 WHERE i = 1 WAITFOR DELAY '00:00:20' UPDATE t2 SET i = 99 WHERE i = 9 COMMIT Open another window (say Window2) in Query Analyzer and paste the following code: BEGIN TRAN UPDATE t2 SET i = 99 WHERE i = 9 WAITFOR DELAY '00:00:20' UPDATE t1 SET i = 11 WHERE i = 1 COMMIT Now run the code from Window1, followed by Window2 simultaneously. Briefly after 20 seconds, one of the windows will What is index segmentation?
A segment is a part of relational data base and consists of one or more extents. Each extent is further divided into blocks. Every segment has an index for holding all of its data for quick data retrieval. Index segments can be created explicitly by using the CREATE INDEX command. Storage parameters for the extents of the index segment can be specified along with this command.
ensuring your results are valid. Creating an automated task to restore the database regularly (weekly, daily or even several times a day as needed) will save lots of time and guarantee that you do not miss any necessary restore steps. At a high level, you should complete the following steps to refresh a test or development environment using backup and restore as the refresh method: 1. Back up the production database: You should already have a scheduled process that creates daily full backups, so use the backup files that are already in place. 2. Copy all the users in test environment to some other table in master data base 2. Kill connections to database: In order to do a restore, there can be no active connections to the database. All connections to the database must be killed before you start the restore. 3. Restore the database: Issue the restore command. 4. Re-link users and logins: Users and logins are associated by SIDs (security identifiers). These may not be the same on your production and test environments, so you will need to re-lid
So, if these services are not running, you should run them. 4. If an alert is not firing, make sure that it is enabled. The alert can be enabled or disabled. To check if an alert is enabled, you can do the following: 1. Run SQL Server Enterprise Manager. 2. Expand a server group; then expand a server. 3. Expand Management; then expand SQL Server Agent. 4. Double-click the appropriate alert to see if the alert is enabled. 5. Check the history values of the alert to determine the last date that the alert worked. To view the history values of the alert, you can do the following: 1. Run SQL Server Enterprise Manager. 2. Expand a server group; then expand a server. 3. Expand Management; then expand SQL Server Agent. 4. Double-click the appropriate alert to see the alert history. 6. Verify that the counter value is maintained for at least 20 seconds. Because SQL Server Agent polls the performance counters at 20 second intervals, if the counter value is maintained for only a few seconds (less than 20 seconds), there is a high likelihood that the alert will not fire. 7. Check the SQL Server error log, SQL Server Agent error log, and Windows NT or Windows 2000 application log to get a more detailed error description. Comparing the dates and times for alert failure events between the SQL Server error log, the SQL Server Agent error log, and the Windows NT or Windows 2000 application log can help you to determine the reason of the failure. 8. If the alert fires, but the responsible operator does not receive notification, try to send 'e-mail', 'pager', or 'net send' message to
this operator manually. In most cases, this problem arises when you have entered an incorrect 'e-mail', 'pager', or 'net send' addresses. If you can send an 'email', 'pager', or 'net send' message manually to this operator, check the account the SQL Server Agent runs under, as well as the operator's on-duty schedule. 9. If the alert fires, but the notification is not timely, decrease the 'Delay between responses' setting for the alert and try to send notifications to as few operators as possible. To decrease the 'Delay between responses' setting for the alert, you can do the following: 1. Run SQL Server Enterprise Manager. 2. Expand a server group; then expand a server. 3. Expand Management; then expand SQL Server Agent. 4. Double-click the appropriate alert and choose the 'Response' tab. 5. Specify a new 'Delay between responses' setting. 10. Alert cannot send e-mail notification with xp_logevent or RAISERROR. This is an SQL Server 7.0 and SQL Server 2000 bug. This happens if the alert is defined to be restricted to a specific database other than the master database. To work around this, you can define the alert on the master database, or all databases. To define the alert on all databases, you can do the following: 1. Run SQL Server Enterprise Manager. 2. Expand a server group; then expand a server. 3. Expand Management; then expand SQL Server Agent. 4. Double-click the appropriate alert and choose '(All Databases)' in the Database name combobox. 11. Alerts are triggered incorrectly when Security Auditing is enabled. This is an SQL Server 7.0 and SQL Server 2000 bug. This bug was fixed in SQL Server 2000 service pack 1 and in SQL Server 7.0 service pack
4. To work around this problem, you can disable Security Auditing, or you can install the service packs. 12. After Installing SQL Server 7.0 service pack 3, SQL Server Agent alerts may fail to work. This is an SQL Server 7.0 service pack 3 bug. To work around this, you should install SQL Server 7.0 service pack 4. 13. Responses for performance condition alerts are sent every 20 seconds, regardless of the 'Delay between responses' setting for the alert. This is an SQL Server 7.0 bug. To work around this, you should install SQL Server 7.0 service pack 1 or higher.
What is an extended stored procedure? Can you instantiate a COM object by using TSQL? An extended stored procedure is a function within a DLL (written in a programming language like C, C++ using Open Data Services (ODS) API) that can be called from TSQL, just the way we call normal stored procedures using the EXEC statement. See books online to learn how to create extended stored procedures and how to add them to SQL Server. Yes, you can instantiate a COM (written in languages like VB, VC++) object from T-SQL by using sp_OACreate stored procedure. Also see books online for sp_OAMethod, sp_OAGetProperty, sp_OASetProperty, sp_OADestroy. For an example of creating a COM object in VB and calling it from T-SQL, see My code library section of this site. Re: Define Check points and End Points?
CheckPoints:Whenever we perform any DML operations in the database,it will go to the checkpoint and then commit in the database.If we don't have checkpoints,the data will get store in transaction log file,once it got fill full,it will make the database performance issues. Endpoints:Endpoints are objects that represent a communication point between the server and a client. 1. What is a "constraint"? - A constraint allows you to apply simple referential integrity checks to a table. There are four primary types of constraints that are currently supported by SQL Server: PRIMARY/UNIQUE - enforces uniqueness of a particular table column. DEFAULT - specifies a default value for a column in case an insert operation does not provide one. FOREIGN KEY - validates that every value in a column exists in a column of another table. CHECK - checks that every value stored in a column is in some specified list. Each type of constraint performs a specific type of action. Default is not a constraint. NOT
NULL is one more constraint which does not allow values in the specific column to be null. And also it the only constraint which is not a table level constraint.
What is a deadlock and what is a live lock? How will you go about resolving deadlocks?
1.
Deadlock is a situation when two processes, each having a lock on one piece of data, attempt to acquire a lock on the other's piece. Each process would wait indefinitely for the other to release the lock, unless one of the user processes is terminated. SQL Server detects deadlocks and terminates one user's process. A livelock is one, where a request for an exclusive lock is repeatedly denied because a series of overlapping shared locks keeps interfering. SQL Server detects the situation after four denials and refuses further shared locks. A livelock also occurs when read transactions monopolize a table or page, forcing a write transaction to wait indefinitely.
Data Intigrity
Enforcing data integrity ensures the quality of the data in the database. For example, if an employee is entered with an employee_id value of 123, the database should not allow another employee to have an ID with the same value. If you have an employee_rating column intended to have values ranging from 1 to 5, the database should not accept a value of 6. If the table has a dept_id column that stores the department number for the employee, the database should allow only values that are valid for the department numbers in the company. Two important steps in planning tables are to identify valid values for a column and to decide how to enforce the integrity of the data in the column. Data integrity falls into these categories:
y y y y
Entity integrity
Domain integrity
Referential integrity
User-defined integrity
Entity Integrity
Entity integrity defines a row as a unique entity for a particular table. Entity integrity enforces the integrity of the identifier column(s) or the primary key of a table (through indexes, UNIQUE constraints, PRIMARY KEY constraints, or IDENTITY properties).
Domain Integrity
Domain integrity is the validity of entries for a given column. You can enforce domain integrity by restricting the type (through data types), the format (through CHECK constraints and rules), or the range of possible values (through FOREIGN KEY constraints, CHECK constraints, DEFAULT definitions, NOT NULL definitions, and rules).
Referential Integrity
Referential integrity preserves the defined relationships between tables when records are entered or deleted. In Microsoft SQL Server 2000, referential integrity is based on relationships between foreign keys and primary keys or between foreign keys and unique keys (through FOREIGN KEY and CHECK constraints). Referential integrity ensures that key values are consistent across tables. Such consistency requires that there be no references to nonexistent values and that if a key value changes, all references to it change consistently throughout the database.
When you enforce referential integrity, SQL Server prevents users from:
y y y
Adding records to a related table if there is no associated record in the primary table.
Changing values in a primary table that result in orphaned records in a related table.
Deleting records from a primary table if there are matching related records.
For example, with the sales and titles tables in the pubs database, referential integrity is based on the relationship between the foreign key (title_id) in the salestable and the primary key (title_id) in the titles table.