<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4994764928445852078</id><updated>2012-01-12T03:57:51.744-08:00</updated><category term='Table valued function'/><category term='FOREIGN KEY'/><category term='NOT NULL'/><category term='sql job owner'/><category term='sql server objects'/><category term='how to find users wise permissions in sql server'/><category term='Book reference for MCITP'/><category term='truncate_only'/><category term='Data Normalization'/><category term='RAID 1'/><category term='Windows Monitor'/><category term='deterministic'/><category term='Filestream'/><category term='discontinued feature from Sql server 2008'/><category term='Rebuild Index'/><category term='sql server views'/><category term='LEFT OUTER JOIN'/><category term='SQL SERVER 2008 R2 FEATURES'/><category term='db restore'/><category term='Schema Binding View'/><category term='resource'/><category term='sql version inforamtion'/><category term='Sql Server 2005 new concept'/><category term='coalesce'/><category term='count of view'/><category term='CROSS JOIN'/><category term='JOINS IN SQL SERVER'/><category term='Master and Resource'/><category term='Book reference for MCTS'/><category term='2008'/><category term='SQL SErver 2005'/><category term='Filestream in Sql Server 2008'/><category term='Scalar Function'/><category term='where clause'/><category term='sql server cursor'/><category term='difference between inner join and union'/><category term='JOBS'/><category term='Sql server installation on RAID'/><category term='synchronization'/><category term='new index features in sql serer 2005'/><category term='Defragmentation'/><category term='RAID 3'/><category term='int'/><category term='UNPIVOT'/><category term='having clause'/><category term='job notification details'/><category term='deadlock and livelock'/><category term='joins'/><category term='RAID 0+1'/><category term='SQL Server 2005 New Features'/><category term='system databases in sql server'/><category term='Jobs informations'/><category term='online index in sql server 2005'/><category term='T-SQL'/><category term='multi statement function'/><category term='notification'/><category term='Log shrink'/><category term='job information'/><category term='Job failure'/><category term='count of functions'/><category term='Shrink log'/><category term='findout job history in SQl server'/><category term='jobs duration'/><category term='Sql server queries'/><category term='orphan users'/><category term='New Data types in Sql Server 2008'/><category term='failed jobs'/><category term='Sql Server 2008 new features'/><category term='Statistics'/><category term='performance improve in sql server'/><category term='Index Features'/><category term='msdb'/><category term='difference between master and resource'/><category term='defragment tables'/><category term='codd rules'/><category term='views in sql server'/><category term='DEFAULT'/><category term='2008 R2'/><category term='Default Key'/><category term='Job Monitor'/><category term='materialized view'/><category term='covering index'/><category term='non deterministic'/><category term='How to configure PERFMON'/><category term='identify the time of restoration of sql server db'/><category term='Grant'/><category term='Sql Server certifications'/><category term='Apply Operator'/><category term='Log size reduce'/><category term='Sql server objects count'/><category term='Transact Query Language'/><category term='Dbcc Shrink Log'/><category term='Sql Server 2008 Certification'/><category term='find database objects count'/><category term='list of users with their permissions'/><category term='sql learn'/><category term='SQL Server Contsraints'/><category term='what is PERFMON'/><category term='join'/><category term='sql server history'/><category term='shrink file'/><category term='Sql Server 2008 Certification Details'/><category term='INNER JOIN'/><category term='RAID 0'/><category term='CTE'/><category term='SELF JOIN'/><category term='PERFMON'/><category term='Online index'/><category term='sql server performance increase'/><category term='database restoration time in sql server'/><category term='Arithemetic Opreators'/><category term='FULL OUTER JOIN'/><category term='Database maintenance'/><category term='CONSTRAINTS'/><category term='sql server orphan users'/><category term='table partitioning'/><category term='sql server till 2008'/><category term='New datatypes in Sql server'/><category term='Log file shrink'/><category term='master'/><category term='Decrease sql server table defragmentation'/><category term='sql server object list'/><category term='database wise user permissions'/><category term='PRIMARY KEY'/><category term='shrink log file'/><category term='db restore time'/><category term='permission on view'/><category term='master db rebuild'/><category term='asynchronization mode'/><category term='Default Constraint'/><category term='sql 2005 indexes'/><category term='SQLSERVER 2005 JOBS AND DETAILS'/><category term='functions'/><category term='Improve performance using PERFMON'/><category term='Sql Server functions'/><category term='Hierarchyid'/><category term='variable declaration in Sql server'/><category term='RIGHT OUTER JOIN'/><category term='SQL SERVER JOBS'/><category term='find permissions'/><category term='cursor'/><category term='log file maintenance'/><category term='sql sever'/><category term='sp_executesql'/><category term='index include columns'/><category term='DCL'/><category term='Sql server 2008'/><category term='UNIQUE'/><category term='Sql server Indexes'/><category term='Sql server database design'/><category term='change the job owner'/><category term='email operator'/><category term='JOB DETAILS'/><category term='view examples'/><category term='live lock'/><category term='Sql Server learning'/><category term='data_compression'/><category term='job step wise information'/><category term='sql server 2008 job owner change'/><category term='Mirror'/><category term='Jobs history'/><category term='job report'/><category term='index features in 2005'/><category term='table partition'/><category term='List out all object count'/><category term='dbcc sqlperf(logspace)'/><category term='Hierarchyid in sql server 2008'/><category term='DML'/><category term='Output Keyword'/><category term='wild cards characters'/><category term='Constraints in SQL Server'/><category term='MCITP'/><category term='Reindex'/><category term='CAse function'/><category term='jobs for long time'/><category term='isnull'/><category term='defragment indexes'/><category term='Sql PERFMON'/><category term='Sql server query language'/><category term='partitioning a table'/><category term='sqlserver log file'/><category term='Sql server 2008 indexing'/><category term='TCL'/><category term='sql versions'/><category term='PIVOT'/><category term='Windows tools'/><category term='sql server jobs owner change'/><category term='count of procedures'/><category term='Master database'/><category term='system functions'/><category term='shrinking file'/><category term='LIST OF JOBS AND ITS DETAILS'/><category term='Alter Index'/><category term='Comparision Operators'/><category term='Resource database'/><category term='New Data types in Sql Server 2000'/><category term='SQLSERVER maintenance'/><category term='sql users'/><category term='RAID 4'/><category term='Redundant array'/><category term='FIND THE SQL SERVER JOB DETAILS'/><category term='sql server 2005 new concepts'/><category term='Ranking functions'/><category term='SQL SErver statistics'/><category term='SQL SERVER 2008 R2'/><category term='sql failed jobs find'/><category term='RAID 5'/><category term='master and resource databsae'/><category term='sql 2008 indexes'/><category term='Revoke'/><category term='index checkup'/><category term='Normalization'/><category term='count of tables'/><category term='NULL'/><category term='Logical Operators'/><category term='db restore details'/><category term='venkat profile'/><category term='partition scheme'/><category term='sql normalization'/><category term='RAID 6'/><category term='RAID 1+0'/><category term='sql server 2005 job owner'/><category term='RAID Levels'/><category term='sql server 2008 indexes'/><category term='TSQL'/><category term='fix orphan users'/><category term='Mirroring'/><category term='partition function'/><category term='DDL'/><category term='use of Group by'/><category term='Sql server 2000 learning'/><category term='sql queries'/><category term='Transact SQL'/><category term='sql server database restoration'/><category term='Dbcc shrink files'/><category term='job notifications'/><category term='MCTS'/><category term='roles assigned to users'/><category term='Snapshot'/><category term='Check Constraint'/><title type='text'>Sql Server 2000/2005/2008</title><subtitle type='html'>SQL Server BLOG for information about Sql server 2000/2005/2008 for viewers working on SQL Server Database.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>40</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-4813450744404437261</id><published>2012-01-12T03:11:00.001-08:00</published><updated>2012-01-12T03:57:51.784-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='email operator'/><category scheme='http://www.blogger.com/atom/ns#' term='notification'/><category scheme='http://www.blogger.com/atom/ns#' term='job notifications'/><category scheme='http://www.blogger.com/atom/ns#' term='job notification details'/><title type='text'>Findout SQL server Job notification details</title><content type='html'>How to findout all the notification details which are configured in the server, like there are some jobs which are not sending notifications for successive / failure actions, so we need to fix that. By identifying each and everyone manually it takes a long time when there are no. of jobs, so following query will help to identify the notification details.&lt;br /&gt;&lt;br /&gt;select a.name, case when a.enabled =1 then 'Enabled' else 'Disabled' end Status, case when notify_level_email = 1 then 'Job success' when notify_level_email = 2 then 'Job failure' end NotifyEmail, b.name&lt;br /&gt;from sysjobs a left outer join (Select * from Sysoperators ) b on a.notify_email_operator_id = b.id&lt;br /&gt;union all&lt;br /&gt;select a.name,case when a.enabled =1 then 'Enabled' else 'Disabled' end Status, case when notify_level_page = 1 then 'Job success' when notify_level_page = 2 then 'Job failure' end NotifyPage, c.name&lt;br /&gt;from sysjobs a left outer join (Select * from Sysoperators ) c on a.notify_page_operator_id = c.id order by a.name&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-4813450744404437261?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/4813450744404437261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=4813450744404437261' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/4813450744404437261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/4813450744404437261'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2012/01/findout-sql-server-job-notification.html' title='Findout SQL server Job notification details'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-681875177724263020</id><published>2011-09-27T02:39:00.000-07:00</published><updated>2011-09-27T02:41:10.635-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='orphan users'/><category scheme='http://www.blogger.com/atom/ns#' term='fix orphan users'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server orphan users'/><category scheme='http://www.blogger.com/atom/ns#' term='sql users'/><title type='text'>How to fix Orphan users in Sqlserver</title><content type='html'>The orphan users can be fixed by executing sp_change_users_login procedure. The syntax would be&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Syntax : &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;sp_change_users_login 'update_one', 'Username','UserName'&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-681875177724263020?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/681875177724263020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=681875177724263020' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/681875177724263020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/681875177724263020'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2011/09/how-to-fix-orphan-users-in-sqlserver.html' title='How to fix Orphan users in Sqlserver'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-3935151333697274067</id><published>2011-01-27T06:46:00.000-08:00</published><updated>2011-01-27T06:50:38.959-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL SERVER 2008 R2 FEATURES'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL SERVER 2008 R2'/><category scheme='http://www.blogger.com/atom/ns#' term='2008 R2'/><category scheme='http://www.blogger.com/atom/ns#' term='discontinued feature from Sql server 2008'/><title type='text'>SQL SERVER 2008 R2 FEATURES (CONSOLIDATED)</title><content type='html'>&lt;strong&gt;A Document &lt;br /&gt;on &lt;br /&gt;Sql Server 2008 R2 Features&lt;/strong&gt;&lt;br /&gt;Microsoft SQL Server 2008 R2 is the latest release of SQL Server. This documentation explains about SQL Server 2008 R2 and its features. The “R2” tag indicates that this is an immediate release of SQL Server.   The Sql server 2008 R2 having features which helps to Developer and DBAs both.   In addition to new features, there are two new editions as well, SQL Server 2008 R2 Datacenter and SQL Server 2008 R2 Parallel Data Warehouse. &lt;br /&gt;&lt;br /&gt;Following are the new features, connected features and enhancements in existing features introduced in Sql Server 2008 R2.  &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Sql server 2008 R2 StreamInsight&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;New in SQL Server 2008 R2 is component called StreamInsight. This interesting component allows streaming data to be analyzed on the fly. Meaning the data is processed directly from the source stream prior to being saved in a SQL Server table. This could be extremely handy if you’re running a real time system and need to analyze data but can’t afford the latency of a committed write to a table first. Examples usually cited for this application include stock trading streams, click stream web analytics, and industrial process controls. Multiple input streams can be simultaneously monitored. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Sql server 2008 R2 Master Data Services&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Master Data Services (MDS) is both a concept and a product. The concept of a Master Data Service is that there is a central data gate keeper of core business data. Data items such as customer billing addresses, employee/customer names, and product names should be centrally managed so that all consuming applications have the same information. The Microsoft example given is a company that has a customer address record in the customer table but a different address in the mailing table. A Master Data Service application would ensure that all tables would have only one correct address. While an MDS can be a homegrown application, SQL Server 2008 R2 includes an application and an interface to manage the central data.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server Report Builder 3.0 for   SQL Server 2008 R2&lt;/strong&gt; &lt;br /&gt;Report Builder 3.0 introduces additional visualizations including maps, sparklines and databars which can help produce new insights well beyond what can be achieved with standard tables and charts. The Report Part Gallery is also included in this release - taking self-service reporting to new heights by enabling users to re-use existing report parts as building blocks for creating new reports in a matter of minutes with a “grab and go” experience. Additionally, users will experience significant performance improvements with enhancements to the ability to use Report Builder in server mode. This allows for much faster report processing with caching of datasets on the report server when toggling between design and preview modes.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  2008 R2 Reporting Services Add-in for   SharePoint  Technologies 2010 &lt;/strong&gt;The Microsoft SQL Server 2008 R2 Reporting Services Add-in for Microsoft SharePoint Technologies 2010 allows you to integrate your reporting environment with SharePoint to experience the benefits of using the collaborative environment provided by SharePoint. Once you install the Reporting Services Add-in and configure your servers for integration, you can publish Reporting Services content to a SharePoint library and then view and manage those documents directly from a SharePoint site. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  2008 R2 Policies &lt;/strong&gt;Microsoft SQL Server 2008 R2 Policies are examples of how you can take advantage of Policy Based Management. These policies will help you follow some of the SQL Server best practices and avoid common pitfalls. For more information, please see Administering Servers by Using Policy Based Management in SQL Server 2008 R2 Books Online.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Sql server 2008 R2 Data-Tier Application &lt;/strong&gt;&lt;br /&gt;A Data-Tier Application (abbreviated as DAC –no idea what the C stands for, and not to be confused with the Windows Data Access Components also abbreviated as DAC ) is an object that stores all the needed database information for a project, such as login, tables, and procedures into one package that can be consumed by Visual Studio. By creating a Data-Tier Application, a SQL Server package version could be saved with each Visual Studio build of your application. This would allow application code builds to be married to a database build in an easily managed way.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Unicode Compression in Sql server 2008 R2&lt;/strong&gt;&lt;br /&gt;SQL Server 2008 R2 uses a new algorithm known as Simple Compression Scheme for Unicode storage. This reduces the amount of disk spaced used by Unicode characters. This new format happens automatically and is managed by the SQL Server engine so no programming changes are required of the DBA.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server Utility in Sql server 2008 R2&lt;/strong&gt;&lt;br /&gt;The new SQL Server Utility is a repository object for centrally controlling multiple SQL Server instances. Performance data and configuration policies can be stored in a single Utility. The Utility also includes an Explorer tool where multi-server dashboards can be created. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Sql server 2008 R2 Multi Server Dashboards&lt;/strong&gt;&lt;br /&gt;While the SQL Server Management Studio could always connection to multiple servers, each was managed independently with no central view of all of them. Now with SQL Server 2008 R2, Dashboards showing combined server data can be created. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  Compact 3.5 SP2 &lt;/strong&gt;SQL Server Compact 3.5 SP2 is an embedded database that allows developers to build robust applications for Windows desktops and mobile devices. The download contains the files for installing SQL Server Compact 3.5 SP 2 on Windows desktop.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  Compact 3.5 SP2 For Windows Mobile &lt;/strong&gt;SQL Server Compact 3.5 SP2 is an embedded database that allows developers to build robust applications for Windows desktops and mobile devices. The download contains the files for installing SQL Server Compact 3.5 SP 2 on Windows desktop.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  Compact 3.5 SP2 Server Tools &lt;/strong&gt;SQL Server Compact 3.5 SP2 is an embedded database that allows developers to build robust applications for Windows desktops and mobile devices. The download contains the files for installing SQL Server Compact 3.5 SP 2 on Windows desktop.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  Compact 3.5 SP2 Books On-line &lt;/strong&gt;SQL Server Compact 3.5 SP2 is an embedded database that allows developers to build robust applications for Windows desktops and mobile devices. The download contains the files for installing SQL Server Compact 3.5 SP 2 on Windows desktop.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  JDBC Driver 3.0 &lt;/strong&gt;In our continued commitment to interoperability, Microsoft has released a new Java Database Connectivity (JDBC) driver. The SQL Server JDBC Driver 3.0 download is available to all SQL Server users at no additional charge, and provides access to SQL Server 2008 R2 , SQL Server 2008, SQL Server 2005 and SQL Server 2000 from any Java application, application server, or Java-enabled applet. This is a Type 4 JDBC driver that provides database connectivity through the standard JDBC application program interfaces (APIs) available in Java Platform, Enterprise Edition 5. This release of the JDBC Driver is JDBC 4.0 compliant and runs on the Java Development Kit (JDK) version 5.0 or later. It has been tested against major application servers including IBM WebSphere, and SAP NetWeaver.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Connector 1.1 for SAP BW for SQL Server  2008 R2 &lt;/strong&gt;The Microsoft Connector for SAP BW is a set of managed components for transferring data to or from an SAP NetWeaver BW version 7.0 system. The component is designed to be used with the Enterprise and Developer editions of SQL Server 2008 R2 Integration Services. To install the component, run the platform-specific installer for x86, x64, or Itanium computers respectively. For more information see the Readme and the installation topic in the Help file.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;System CLR Types for SQL Server  2008 R2 &lt;/strong&gt;The SQL Server System CLR Types package contains the components implementing the geometry, geography, and hierarchy id types in SQL Server 2008 R2. This component can be installed separately from the server to allow client applications to use these types outside of the server.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  2008 R2 Remote Blob Store &lt;/strong&gt;The SQL Server Remote Blob Store is a method for storing blobs of unstructured data in an external Content Addressable data store. The component consists of a client-side DLL that is linked into a user application, as well as a set of stored procedures to be installed on SQL Server. Run the self-extracting download package to create an installation folder. The setup program contained there will install RBS on X86, X64, and Itanium-based computers.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  2008 R2 Books On-line &lt;/strong&gt;Microsoft SQL Server 2008 R2 Books Online is the primary documentation for SQL Server. Visit the SQL Server 2008 Books Online page on the Microsoft Download Center. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  2008 R2 Upgrade Advisor &lt;/strong&gt;Microsoft SQL Server 2008 R2 Upgrade Advisor analyzes instances of SQL Server 2000, SQL Server 2005 and SQL Server 2008 in preparation for upgrading to SQL Server 2008 R2. Upgrade Advisor identifies feature and configuration changes that might affect your upgrade, and it provides links to documentation that describes each identified issue and how to resolve it.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  2008 R2 Native Client &lt;/strong&gt;Microsoft SQL Server 2008 R2 Native Client (SQL Server Native Client) is a single dynamic-link library (DLL) containing both the SQL OLE DB provider and SQL ODBC driver. It contains run-time support for applications using native-code APIs (ODBC, OLE DB and ADO) to connect to Microsoft SQL Server 2000, 2005, or 2008. SQL Server Native Client should be used to create new applications or enhance existing applications that need to take advantage of new SQL Server 2008 R2 features. This redistributable installer for SQL Server Native Client installs the client components needed during run time to take advantage of new SQL Server 2008 R2 features, and optionally installs the header files needed to develop an application that uses the SQL Server Native Client API.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;OLEDB Provider for DB2 &lt;/strong&gt;The Microsoft OLE DB Provider for DB2 Version 3.0 offers a set of technologies and tools for integrating vital data stored in IBM DB2 databases with new solutions based on Microsoft SQL Server 2008 R2 Enterprise Edition and Developer Edition. SQL Server developers and administrators can use the data provider with Integration Services, Analysis Services, Replication, Reporting Services, and DistributedQuery Processor. Run the self-extracting download package to create an installation folder. The single setup program will install the Version 3.0 provider and tools on x86, x64, and IA64 computers. Read the installation guide and release notes for more information.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  2008 R2 Command Line Utilities &lt;/strong&gt;The SQLCMD utility allows users to connect to, send Transact-SQL batches from, and output rowset information from SQL Server 7.0, SQL Server 2000, SQL Server 2005, and SQL Server 2008 and 2008 R2 instances. The bcp utility bulk copies data between an instance of Microsoft SQL Server 2008 R2 and a data file in a user-specified format. The bcp utility can be used to import large numbers of new rows into SQL Server tables or to export data out of tables into data files.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  Service Broker External Activator for SQL Server  2008 R2 &lt;/strong&gt;The Microsoft SQL Server 2008 R2 Service Broker External Activator is an extension of the internal activation feature in SQL Server 2008 R2 that lets you move the logic for receiving and processing Service Broker messages from the Database Engine service to an application executable that runs outside SQL Server. By doing this, cpu-intensive or long-duration tasks can be offloaded out of SQL Server to an application executable, possibly in another computer. The application executable can also run under a different Windows account from the Database Engine process. This gives administrators additional control over the resources that the application can access. Run the self-extracting download package to create an installation folder. Read Books Online for more information. The single setup program will install the service on x86, x64, and IA64 computers. Read the documentation for more information&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Windows PowerShell Extensions for SQL Server  2008 R2 &lt;/strong&gt;The Microsoft Windows PowerShell Extensions for SQL Server2008 R2 includes a provider and a set of cmdlets that enable administrators and developers to build PowerShell scripts for managing instances of SQL Server. The SQL Server PowerShell Provider delivers a simple mechanism for navigating SQL Server instances that is similar to file system paths. PowerShell scripts can then use the SQL Server Management Objects to administer the instances. The SQL Server cmdlets support operations such as executing Transact-SQL scripts or evaluating SQL Server policies.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  2008 R2 Shared Management Objects &lt;/strong&gt;The SQL Server Management Objects (SMO) is a .NET Framework object model that enables software developers to create client-side applications to manage and administer SQL Server objects and services. This object model will work with SQL Server 2000, SQL Server 2005, SQL Server 2008 and SQL Server 2008 R2.&lt;br /&gt;Note: Microsoft SQL Server 2008 R2 Management Objects Collection requires Microsoft Core XML Services (MSXML) 6.0, Microsoft SQL Server Native Client, and Microsoft SQL Server System CLR Types. These are available on this page.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  2008 R2 ADOMD.NET &lt;/strong&gt;ADOMD.NET is a Microsoft .NET Framework object model that enables software developers to create client-side applications that browse metadata and query data stored in Microsoft SQL Server 2008 R2 Analysis Services. ADOMD.NET is a Microsoft ADO.NET provider with enhancements for online analytical processing (OLAP) and data mining.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Analysis Services OLE DB Provider for   SQL Server  2008 R2 &lt;/strong&gt;The Analysis Services OLE DB Provider is a COM component that software developers can use to create client-side applications that browse metadata and query data stored in Microsoft SQL Server 2008 R2 Analysis Services. This provider implements both the OLE DB specification and the specification’s extensions for online analytical processing (OLAP) and data mining.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  2008 R2 Analysis Management Objects &lt;/strong&gt;Analysis Management Objects (AMO) is a .NET Framework object model that enables software developers to create client-side applications to manage and administer Analysis Services objects.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  Driver for PHP 1.1 &lt;/strong&gt;The SQL Server Driver for PHP 1.1 is a PHP extension that allows for accessing data in all Editions of SQL Server 2005, SQL Server 2008,and SQL Server 2008 R2 (including Express Editions) from within PHP scripts. The driver provides a procedural interface for accessing data and makes use of PHP features, including PHP streams to read and write large objects. The SQL Server Driver for PHP relies on the Microsoft SQL Server Native Client to communicate with SQL Server.SQL Server Native Client can be downloaded on this Feature Pack page.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  Migration Assistant &lt;/strong&gt;Microsoft SQL Server Migration Assistant (SSMA) is a family of tools that dramatically cut the effort, cost, and risk of migrating from Oracle, Sybase, MySQL or Access to any edition of SQL Server 2008 R2 or SQL Server 2008 or SQL Server 2005. SSMA for MySQL and SSMA for Access products also support simple and direct migration to SQL Azure. SSMA provides an assessment of migration efforts as well as automates schema and data migration.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server  2008 R2 Best Practices Analyzer &lt;/strong&gt;SQL Server 2008 R2 Best Practices Analyzer is an analysis tool that validates your system configuration and execution against a recommended set of best practices developed by SQL Server Engineering and Customer Support.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Optimize Hardware Resources&lt;/strong&gt;This is a great new feature for database administrators as it will provide a real time insight into Server Utilization, Policy Violations etc. This feature will help organizations to strictly apply organization wide policies across servers thereby helping them maintain a healthy system.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Manage Efficiently at Scale&lt;/strong&gt;&lt;br /&gt;This feature will help database administrator to gain insight into growing applications and databases thereby helping them to ensure better management of database servers. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Enhance Collaboration Across Development and IT&lt;/strong&gt;&lt;br /&gt;Database Application development will be more closely integrated with Visual Studio 2010 which will help to ensure higher quality during the application development along with easier deployments and better handling of changes over time. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Build Robust Analytical Applications&lt;/strong&gt;&lt;br /&gt;Using Microsoft Office Excel 2010 you can build robust analytical applications which will allow in-memory, column oriented processing engine to allow users to interactively explore and perform complex calculations on millions of data at lightening speeds. Using Microsoft Excel 2010 you can easily integrate data from multiple sources such as corporate databases, spreadsheets and external data sources. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Support for Geospatial Visualization&lt;/strong&gt;&lt;br /&gt;Microsoft SQL Server 2008 R2 will provide support for geospatial visualization including mapping, routing, and custom shapes. It will also support SQL Spatial and will also provide integration with Microsoft Virtual Earth tiles.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Sql server 2008 R2 Edition wise Information  :&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Standard Edition:&lt;/strong&gt; Now with Backup Compression&lt;br /&gt;SQL Server 2008 introduced backup compression, but it was only available in Enterprise Edition. At the time, Enterprise Edition cost around $20,000 more per processor than Standard Edition, so companies couldn’t justify upgrading to Enterprise Edition just to get backup compression. Companies had to need Enterprise for multiple features in order to stomach the price. If all a DBA needed was compression, they could buy backup compression software much cheaper than the price of Enterprise Edition.&lt;br /&gt;In SQL 2008 R2, even Standard Edition gets backup compression. That’s a game-changer, and I’d expect to see smaller companies that do backup compression – and nothing else – to start falling by the wayside.&lt;br /&gt;In addition, Standard can now be a managed instance – it can be managed by some of the slick multi-server-management tools coming down the pike like the Utility Control Point (read my SQL 2008 R2 Utility review). It can’t be the management server itself – it can’t be a Utility Control Point – but at least we can manage Standard. It’s good to see that Microsoft recognizes all servers need to be managed, not just the expensive ones. Big thumbs up there.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Enterprise Edition: CPU Limits&lt;/strong&gt;In Enterprise, Microsoft giveth and Microsoft taketh away. SQL 2008 R2′s BI tools include a new Master Data Services tool. It’s targeted at enterprises with data warehouses that need to manage incoming data from lots of different sources, and that data isn’t always clean or correct. MDS helps make sure data follows business rules. This isn’t a common need for OLTP systems, so it’s only included in Enterprise, not Standard. Makes sense.&lt;br /&gt;A little less easy to stomach, however, is a new set of caps on Enterprise Edition. The current SQL 2008 comparison page shows that Enterprise has no licensing limit on memory or the number of CPU sockets. SQL 2008 R2 Enterprise Edition is capped at 8 CPU sockets, and there’s a memory cap as well, but I haven’t been able to track down a public page showing the cap. The only hint is the SQL 2008 R2 edition comparison page, which notes that Datacenter Edition (more on that in a second) is licensed for “memory limits up to OS maximum.” If that wasn’t a unique selling point, it shouldn’t be included in the feature list.&lt;br /&gt;The more expensive Enterprise can act as the management server (Utility Control Point) for up to 25 instances. However, that doesn’t mean you need to buy one Enterprise per 24-25 Standard servers, and then manage them in pools – there’s an app edition for that.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Datacenter Edition:&lt;/strong&gt; For, Well, Datacenters&lt;br /&gt;The new Datacenter Edition picks up where Enterprise now runs out of gas. It supports more than 8 sockets, up to 256 cores, and all the memory you can afford. Or can’t afford, for that matter.&lt;br /&gt;If you’re going to manage over 25 instances with the Utility Control Point stuff, Datacenter Edition can manage “more than 25 instances” according to Microsoft’s edition comparison page. I like how they worded that – they didn’t say “unlimited instances,” because there will be performance impacts associated with using Utility Control Points. The performance data collections gather a lot of data, and storing it for hundreds of instances will take some pretty high performance hardware.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Parallel Data Warehouse Edition:&lt;/strong&gt; Sold with Hardware Only&lt;br /&gt;The big new fella in town getting all the press is the artist formerly known as Project Madison, formerly known as DATAllegro. It’s a scale-out data warehouse appliance, but you won’t find this appliance at Home Depot. This version of SQL Server is sold in reference architecture hardware packages from Bull, Dell, HP, EMC, and IBM. Write one check, and you get a complete soup-to-nuts data warehouse storage engine that includes everything from the servers, SAN, configuration, and training.&lt;br /&gt;I had the chance to talk with Microsoft’s Val Fontama, and I’ll post more details of that interview next week, but I have to share one quick snippet. I asked what happens when a Parallel Data Warehouse system starts to have performance issues, and he explained that the DBA will need to call in specialized Parallel engineers. You won’t be popping open this rack and installing another drawer of hard drives yourself or adding additional commodity hardware boxes to scale out your datacenter. It’s more of a sealed solution than something you have to build yourself.&lt;br /&gt;I have mixed feelings about this – as a guy who loves hardware, I want to dive under the hood. However, as a guy who’s managed data warehouses, I know it’s one heck of an ugly skillset to learn on the job, and when data gets into the 5-10 terabyte range, you can’t afford to make configuration mistakes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-3935151333697274067?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/3935151333697274067/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=3935151333697274067' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/3935151333697274067'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/3935151333697274067'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2011/01/sql-server-2008-r2-features.html' title='SQL SERVER 2008 R2 FEATURES (CONSOLIDATED)'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-5399235698339015619</id><published>2010-12-27T05:56:00.000-08:00</published><updated>2010-12-27T05:58:20.827-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='new index features in sql serer 2005'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server 2008 indexes'/><category scheme='http://www.blogger.com/atom/ns#' term='sql 2005 indexes'/><category scheme='http://www.blogger.com/atom/ns#' term='data_compression'/><category scheme='http://www.blogger.com/atom/ns#' term='sql 2008 indexes'/><category scheme='http://www.blogger.com/atom/ns#' term='index include columns'/><category scheme='http://www.blogger.com/atom/ns#' term='2008'/><title type='text'>New Index features in Sql server 2005 &amp; 2008</title><content type='html'>&lt;strong&gt;1. Indexes in SQL Server 2005:&lt;/strong&gt; Index features:&lt;br /&gt;&lt;br /&gt;INCLUDE (column [,... n ] )&lt;br /&gt;&lt;br /&gt; Specifies the nonkey columns to be added to the leaf level of the nonclustered index.&lt;br /&gt; The maximum number of included nonkey columns is 1,023 columns; the minimum number is 1 column.&lt;br /&gt; Column names cannot be repeated in the INCLUDE list and cannot be used simultaneously as both key and nonkey columns.&lt;br /&gt; All data types are allowed except text, ntext, and image.&lt;br /&gt;&lt;br /&gt; Index arguments&lt;br /&gt;&lt;br /&gt; ONLINE = {ON|OFF}&lt;br /&gt; Specifies whether underlying tables and associated indexes are available for queries and data modification during the index operation. &lt;br /&gt; The default is OFF.&lt;br /&gt; Online index operations are available only in SQL Server 2005 Enterprise Edition.&lt;br /&gt;&lt;br /&gt;ON&lt;br /&gt;Long-term table locks are not held for the duration of the index operation. During the main phase of the index operation, only an Intent Share (IS) lock is held on the source table. This enables queries or updates to the underlying table and indexes to proceed. At the start of the operation, a Shared (S) lock is held on the source object for a very short period of time. At the end of the operation, for a short period of time, an S (Shared) lock is acquired on the source if a nonclustered index is being created; or an SCH-M (Schema Modification) lock is acquired when a clustered index is created or dropped online and when a clustered or nonclustered index is being rebuilt. ONLINE cannot be set to ON when an index is being created on a local temporary table.&lt;br /&gt;&lt;br /&gt;OFF&lt;br /&gt;Table locks are applied for the duration of the index operation. An offline index operation that creates, rebuilds, or drops a clustered index, or rebuilds or drops a nonclustered index, acquires a Schema modification (Sch-M) lock on the table. This prevents all user access to the underlying table for the duration of the operation. An offline index operation that creates a nonclustered index acquires a Shared (S) lock on the table. This prevents updates to the underlying table but allows read operations, such as SELECT statements. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; ALLOW_ROW_LOCKS = {ON | OFF}&lt;br /&gt;&lt;br /&gt; Specifies whether row locks are allowed. &lt;br /&gt; The default is ON.&lt;br /&gt;&lt;br /&gt;ON&lt;br /&gt;&lt;br /&gt; Row locks are allowed when accessing the index. &lt;br /&gt; The Database Engine determines when row locks are used. &lt;br /&gt;&lt;br /&gt;OFF&lt;br /&gt; Row locks are not used.&lt;br /&gt;&lt;br /&gt; ALLOW_PAGE_LOCKS = {ON | OFF}&lt;br /&gt;&lt;br /&gt; Specifies whether page locks are allowed. &lt;br /&gt; The default is ON.&lt;br /&gt;&lt;br /&gt;ON&lt;br /&gt; Page locks are allowed when accessing the index. &lt;br /&gt; The Database Engine determines when page locks are used.&lt;br /&gt;&lt;br /&gt;OFF&lt;br /&gt; Page locks are not used.&lt;br /&gt;&lt;br /&gt; MAXDOP = max_degree_of_parallelism&lt;br /&gt;&lt;br /&gt; Overrides the max degree of parallelism configuration option for the duration of the index operation. &lt;br /&gt; Use MAXDOP to limit the number of processors used in a parallel plan execution. &lt;br /&gt; The maximum is 64 processors. &lt;br /&gt; The below table shows the possible max_degree_of_parallelism and its description.&lt;br /&gt;&lt;br /&gt;Max_degree_of_parallelism Description&lt;br /&gt;1 Suppresses parallel plan generation.&lt;br /&gt;&gt;1 Restricts the max.no of processors used in a parallel index operation to the specified number&lt;br /&gt;0(Default) Uses the actual number of processors&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. Indexes in SQL Server 2008:&lt;/strong&gt; Index features:&lt;br /&gt;&lt;br /&gt;WHERE &lt;filter_predicate&gt;&lt;br /&gt;&lt;br /&gt; Creates a filtered index by specifying which rows to include in the index. &lt;br /&gt; The filtered index must be a nonclustered index on a table.&lt;br /&gt; Filtered indexes do not apply to XML indexes and full-text indexes.&lt;br /&gt; Filtered indexes do not allow the IGNORE_DUP_KEY option.&lt;br /&gt; The filter predicate uses simple comparison logic and cannot reference a computed column, a UDT column, a spatial data type column, or a hierarchyID data type column. Comparisons using NULL literals are not allowed with the comparison operators.&lt;br /&gt;&lt;br /&gt;FILESTREAM_ON { filestream_filegroup_name | partition_scheme_name | NULL}&lt;br /&gt;&lt;br /&gt; Specifies the placement of FILESTREAM data for the table when a clustered index is created. &lt;br /&gt; The FILESTREAM_ON clause allows FILESTREAM data to be moved to a different FILESTREAM filegroup or partition scheme.&lt;br /&gt; filestream_filegroup_name is the name of a FILESTREAM filegroup.&lt;br /&gt; The filegroup must have one file defined for the filegroup otherwise an error is raised.&lt;br /&gt; If the table is partitioned, the FILESTREAM_ON clause must be included and must specify a partition scheme of FILESTREAM filegroups that uses the same partition function and partition columns as the partition scheme for the table. Otherwise, an error is raised.&lt;br /&gt; If the table is not partitioned, the FILESTREAM column cannot be partitioned. FILESTREAM data for the table must be stored in a single filegroup that is specified in the FILESTREAM_ON clause.&lt;br /&gt; FILESTREAM_ON NULL can be specified in a CREATE INDEX statement if a clustered index is being created and the table does not contain a FILESTREAM column.&lt;br /&gt;&lt;br /&gt; Index arguments&lt;br /&gt;&lt;br /&gt; DATA_COMPRESSION&lt;br /&gt; Specifies the data compression option for the specified index, partition number, or range of partitions. The options are as follows:&lt;br /&gt;NONE&lt;br /&gt; Index or specified partitions are not compressed.&lt;br /&gt;ROW&lt;br /&gt; Index or specified partitions are compressed by using row compression.&lt;br /&gt;PAGE&lt;br /&gt; Index or specified partitions are compressed by using page compression.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-5399235698339015619?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/5399235698339015619/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=5399235698339015619' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5399235698339015619'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5399235698339015619'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2010/12/new-index-features-in-sql-server-2005.html' title='New Index features in Sql server 2005 &amp; 2008'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-5682708232692287927</id><published>2010-12-11T03:11:00.000-08:00</published><updated>2010-12-11T03:13:16.435-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL SERVER JOBS'/><category scheme='http://www.blogger.com/atom/ns#' term='job step wise information'/><category scheme='http://www.blogger.com/atom/ns#' term='JOB DETAILS'/><category scheme='http://www.blogger.com/atom/ns#' term='job information'/><title type='text'>FIND LIST OF JOBS AND THEIR SCHEDULE WITH STEP WISE</title><content type='html'>SELECT SJ.NAME, SJS.STEP_ID,SJS.STEP_NAME,SJS.COMMAND, &lt;br /&gt;SJ.DESCRIPTION,&lt;br /&gt;(SELECT NAME FROM MASTER.DBO.SYSLOGINS WHERE SID IN (SJ.OWNER_SID)) JOB_OWNER,&lt;br /&gt;SJ.DATE_CREATED,SJ.DATE_MODIFIED, SJS.DATABASE_NAME, case when d.freq_type = 8 then 'Weekly' when d.freq_type = 4 then 'Daily' else 'None' end Schedule,&lt;br /&gt;d.Freq_Subday_Interval Interval_in_Minutes, &lt;br /&gt;case when len(d.active_start_time) = 5 then convert(varchar,left(d.active_start_time,1)) + ':' + convert(varchar,left(right(d.active_start_time,4),2)) + ':' + convert(varchar,right (d.active_start_time,2))  &lt;br /&gt;when len(d.active_start_time) = 4 then '00' + ':'+convert(varchar,left(d.active_start_time,2)) + ':'+convert(varchar,right(d.active_start_time,2))  &lt;br /&gt;when len(d.active_start_time) = 3 then '00:0' + convert(varchar,left(d.active_start_time,1)) + ':'+convert(varchar,right(d.active_start_time,2))  &lt;br /&gt;when len(d.active_start_time) = 2 then '00:00:' + convert(varchar,left(d.active_start_time,2))  &lt;br /&gt;when len(d.active_start_time) = 1 then '00:00:0' + convert(varchar,left(d.active_start_time,1))  &lt;br /&gt;else  &lt;br /&gt;convert(varchar,left(d.active_start_time,2)) + ':' + convert(varchar,left(right(d.active_start_time,4),2)) + ':' + convert(varchar,right (d.active_start_time,2)) End [Scheduled_Time]&lt;br /&gt;FROM SYSJOBS SJ INNER JOIN SYSJOBSTEPS SJS &lt;br /&gt;ON SJ.JOB_ID = SJS.JOB_ID&lt;br /&gt;LEFT OUTER JOIN SYSJOBSCHEDULES SJSC ON SJ.JOB_ID = SJSC.JOB_ID&lt;br /&gt;LEFT OUTER JOIN SYSSCHEDULES d ON SJSC.SCHEDULE_ID = d.SCHEDULE_ID&lt;br /&gt;ORDER BY NAME&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-5682708232692287927?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/5682708232692287927/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=5682708232692287927' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5682708232692287927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5682708232692287927'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2010/12/find-list-of-jobs-and-their-schedule.html' title='FIND LIST OF JOBS AND THEIR SCHEDULE WITH STEP WISE'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-5774762601606816475</id><published>2010-10-14T08:37:00.000-07:00</published><updated>2010-10-14T08:43:34.178-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL SERVER JOBS'/><category scheme='http://www.blogger.com/atom/ns#' term='Job Monitor'/><category scheme='http://www.blogger.com/atom/ns#' term='Job failure'/><category scheme='http://www.blogger.com/atom/ns#' term='msdb'/><category scheme='http://www.blogger.com/atom/ns#' term='failed jobs'/><category scheme='http://www.blogger.com/atom/ns#' term='sql failed jobs find'/><title type='text'>Sql Monitoring - Job Failure information</title><content type='html'>A common requiremnet in DBA Environment to findout what are the jobs got failure in the servers.  The jobs use to perform for various activities like Mainteance, Performance Related, Projects related,  Backups/restore, making Disaster recovery techniques etc.  If the job got failure and no solution has been provided for that, there could be some problem in regular activities.   &lt;br /&gt;&lt;br /&gt;Following query helps to findout what are the jobs got failure and by getting the information solution can be provided.   If required this can be created as procedure in MSDB to simplify the task. &lt;br /&gt;&lt;br /&gt;----------------------------------------------------------------------------------&lt;br /&gt;&lt;strong&gt;Create Proc Pr_MonitorFailure as&lt;br /&gt;Begin&lt;br /&gt;select b.name Job,&lt;br /&gt;case when len(a.run_time) = 5 then convert(varchar,left(a.run_time,1)) + ':' + convert(varchar,left(right(a.run_time,4),2)) + ':' + convert(varchar,right (a.run_time,2))  &lt;br /&gt;when len(a.run_time) = 4 then '00' + ':'+convert(varchar,left(a.run_time,2)) + ':'+convert(varchar,right(a.run_time,2))  &lt;br /&gt;when len(a.run_time) = 3 then '00:0' + convert(varchar,left(a.run_time,1)) + ':'+convert(varchar,right(a.run_time,2))  &lt;br /&gt;when len(a.run_time) = 2 then '00:00:' + convert(varchar,left(a.run_time,2))  &lt;br /&gt;when len(a.run_time) = 1 then '00:00:0' + convert(varchar,left(a.run_time,1))  &lt;br /&gt;else  &lt;br /&gt;convert(varchar,left(a.run_time,2)) + ':' + convert(varchar,left(right(a.run_time,4),2)) + ':' + convert(varchar,right (a.run_time,2)) End [Last Run Datetime],  &lt;br /&gt;--run_duration,  &lt;br /&gt;ISNULL(SUBSTRING(CONVERT(varchar(7),run_duration+1000000),2,2) + ':'  &lt;br /&gt;+ SUBSTRING(CONVERT(varchar(7),run_duration+1000000),4,2) + ':'  &lt;br /&gt;+ SUBSTRING(CONVERT(varchar(7),run_duration+1000000),6,2),'') AS [Last Run Duration], Message, &lt;br /&gt;case when run_status = 0 then 'Fail' else 'Other Reason' end run_status from&lt;br /&gt;Sysjobhistory a inner join Sysjobs b on a.job_id = b.job_id&lt;br /&gt;where run_status &lt;&gt; 1 and message not like '%The Job was invoked%'&lt;br /&gt;End&lt;/strong&gt;&lt;br /&gt;----------------------------------------------------------------------------------&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-5774762601606816475?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/5774762601606816475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=5774762601606816475' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5774762601606816475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5774762601606816475'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2010/10/sql-monitoring-job-failure-information.html' title='Sql Monitoring - Job Failure information'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-7926963893185529468</id><published>2010-09-14T05:17:00.000-07:00</published><updated>2010-09-14T05:21:17.749-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='RIGHT OUTER JOIN'/><category scheme='http://www.blogger.com/atom/ns#' term='SELF JOIN'/><category scheme='http://www.blogger.com/atom/ns#' term='CROSS JOIN'/><category scheme='http://www.blogger.com/atom/ns#' term='LEFT OUTER JOIN'/><category scheme='http://www.blogger.com/atom/ns#' term='FULL OUTER JOIN'/><category scheme='http://www.blogger.com/atom/ns#' term='JOINS IN SQL SERVER'/><category scheme='http://www.blogger.com/atom/ns#' term='INNER JOIN'/><category scheme='http://www.blogger.com/atom/ns#' term='join'/><category scheme='http://www.blogger.com/atom/ns#' term='joins'/><title type='text'>Basic information about Joins in Sql server</title><content type='html'>Joins are really important for writing queries in any database language.  If you take SQL Server there are few joins available  which can help to construct sql statemetns.   The Joins are combination of keywords Intersect, Union, Union all which we have learnt during our X standards.  Join can be matched to 2 or more tables (usually), you can match single table also using join i.e., called Self join.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;In Sql server we have mainly&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;Inner Join&lt;br /&gt;Left Outer Join&lt;br /&gt;Right Outer Join&lt;br /&gt;Full Outer Join&lt;br /&gt;Cross Join&lt;br /&gt;Self Join&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;For best understanding create following tables and insert the data in sample database.   So that you can understand very easily how the join condition results.&lt;br /&gt;&lt;br /&gt;----------------------------&lt;br /&gt;Create table Table1 (id int, name varchar(10))&lt;br /&gt;Create table Table2 (id int, Name varchar(10))&lt;br /&gt;&lt;br /&gt;insert into table1 (id, name) &lt;br /&gt;values (1,'A')&lt;br /&gt;insert into table1 (id, name) &lt;br /&gt;values (2,'AB')&lt;br /&gt;insert into table1 (id, name) &lt;br /&gt;values (3,'ABC')&lt;br /&gt;&lt;br /&gt;insert into table2 (id, name) &lt;br /&gt;values (1,'A')&lt;br /&gt;insert into table2 (id, name) &lt;br /&gt;values (2,'AB')&lt;br /&gt;&lt;br /&gt;----------------------------&lt;br /&gt;&lt;strong&gt;JOINS : &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Inner join :&lt;/strong&gt;  A Intersect B; it means the data results which are available in both the tables. &lt;br /&gt;Eg : &lt;br /&gt;SELECT a.id, a.Name,b.id, b.Name from&lt;br /&gt;Table1 A inner join Table2 B on a.id = b.id&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Left outer Join :&lt;/strong&gt; A union B : Whatever the data available in A table and the matching data from B Table&lt;br /&gt;Eg : &lt;br /&gt;SELECT a.id, a.Name,b.id, b.Name from&lt;br /&gt;Table1 A Left outer join Table2 B on a.id = b.id&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Right outer Join :&lt;/strong&gt; A union B : Whatever the data available in B table and the matching data from A Table&lt;br /&gt;Eg : &lt;br /&gt;SELECT a.id, a.Name,b.id, b.Name from&lt;br /&gt;Table1 A Right outer join Table2 B on a.id = b.id&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Full outer Join : &lt;/strong&gt; All the data from A and B tables&lt;br /&gt;Eg : &lt;br /&gt;SELECT a.id, a.Name,b.id, b.Name from&lt;br /&gt;Table1 A Full outer join Table2 B on a.id = b.id&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Cross Join :&lt;/strong&gt; A X B ; for each row in a multiply into all rows in B. Like wise for all the rows.&lt;br /&gt;SELECT a.id, a.Name,b.id, b.Name from&lt;br /&gt;Table1 A cross join Table2 B &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Self Join : &lt;/strong&gt;By using self join we can match the same table for different columns.&lt;br /&gt;SELECT a.id, a.Name,b.id, b.Name from&lt;br /&gt;Table1 A join Table1 B on a.id = b.id&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-7926963893185529468?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/7926963893185529468/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=7926963893185529468' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/7926963893185529468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/7926963893185529468'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2010/09/basic-information-about-joins-in-sql.html' title='Basic information about Joins in Sql server'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-3521707750120127982</id><published>2010-07-12T07:41:00.000-07:00</published><updated>2010-10-24T01:42:22.776-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sql server Indexes'/><category scheme='http://www.blogger.com/atom/ns#' term='defragment tables'/><category scheme='http://www.blogger.com/atom/ns#' term='Alter Index'/><category scheme='http://www.blogger.com/atom/ns#' term='Reindex'/><category scheme='http://www.blogger.com/atom/ns#' term='Rebuild Index'/><category scheme='http://www.blogger.com/atom/ns#' term='Sql server 2008 indexing'/><category scheme='http://www.blogger.com/atom/ns#' term='Decrease sql server table defragmentation'/><category scheme='http://www.blogger.com/atom/ns#' term='defragment indexes'/><category scheme='http://www.blogger.com/atom/ns#' term='Defragmentation'/><title type='text'>Reindex all tables which are highly fragmented in the database</title><content type='html'>A common database maintenance activity, we need to Reindex database tables to maintain less fragmentation. For performing this we can identify each and every object which has fragmentation reached our expectation level; instead I have designed 2 procedures to findout the fragmented tables and perform the reindex on all indexes available in identified tables.&lt;br /&gt;&lt;br /&gt;Hope this will reduce your maintenance time of writing queries for reindexing.&lt;br /&gt;You can choose MSDB to create this proc and change the content to refer actual databases&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#3333ff;"&gt;-- Identifying Fragmentation of Tables (1)&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style="color:#009900;"&gt;&lt;br /&gt;Create Proc Pr_View_Defragmentation (@database sysname, @Frag int)&lt;br /&gt;as&lt;br /&gt;Declare @dbid int&lt;br /&gt;select @dbid = dbid from sys.sysdatabases where name = @database&lt;br /&gt;select distinct xtype, name,object_name(object_id),* from sys.dm_db_index_physical_stats (@dbid,NULL,NULL,NULL,'SAMPLED')&lt;br /&gt;a inner join sys.sysobjects b on a.object_id = id where xtype = 'u' and name not like '%sys%'&lt;br /&gt;and avg_fragmentation_in_percent &gt;= @frag &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#3333ff;"&gt;-- Perform Reindexing to decrease the Fragmentation (2)&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style="color:#009900;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;Create Proc Pr_Alter_index (@database sysname, @frag int) as&lt;br /&gt;--DECLARE @DATABASE SYSNAME&lt;br /&gt;--DECLARE @FRAG INT&lt;br /&gt;Declare @a int&lt;br /&gt;Declare @b int&lt;br /&gt;Declare @sql varchar(1000)&lt;br /&gt;Declare @Table table(id int identity(1,1),Object varchar(100))&lt;br /&gt;Declare @sql1 varchar(100)&lt;br /&gt;--set @database = 'DATABASE'&lt;br /&gt;--set @frag = 10&lt;br /&gt;SEt @a = 1&lt;br /&gt;select @B = count(DISTINCT object_id) from sys.dm_db_index_physical_stats (db_id(@database),NULL,NULL,NULL,'SAMPLED')&lt;br /&gt;a inner join sys.sysobjects b on a.object_id = id where xtype = 'u' and name not like '%sys%'&lt;br /&gt;and avg_fragmentation_in_percent &gt;= @frag&lt;br /&gt;insert into @table(object)&lt;br /&gt;Select distinct object_name(object_id) from sys.dm_db_index_physical_stats (db_id(@database),NULL,NULL,NULL,'SAMPLED')&lt;br /&gt;a inner join sys.sysobjects b on a.object_id = id where xtype = 'u' and name not like '%sys%'&lt;br /&gt;and avg_fragmentation_in_percent &gt;= @frag&lt;br /&gt;while @a &lt; @b&lt;br /&gt;Begin&lt;br /&gt;select @SQL1 = OBJECT FROM @TABLE where id = @a SET @SQL = 'ALTER INDEX ALL ON ' + @database + '..' + @sql1 + ' REBUILD WITH (ONLINE = ON)'&lt;br /&gt;exec (@sql)&lt;br /&gt;set @a = @a+1&lt;br /&gt;End &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;exec pr_View_Defragmentation database, fragmentation percentage&lt;br /&gt;exec Pr_Alter_index database,fragmentation percentage&lt;br /&gt;&lt;br /&gt;Eg : exec pr_View_Defragmentation 'abcd', 70&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-3521707750120127982?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/3521707750120127982/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=3521707750120127982' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/3521707750120127982'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/3521707750120127982'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2010/07/reindex-all-tables-which-are-highly.html' title='Reindex all tables which are highly fragmented in the database'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-5385520226265711224</id><published>2010-06-10T03:21:00.000-07:00</published><updated>2010-06-10T03:26:14.860-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql server jobs owner change'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL SERVER JOBS'/><category scheme='http://www.blogger.com/atom/ns#' term='sql job owner'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server 2008 job owner change'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server 2005 job owner'/><category scheme='http://www.blogger.com/atom/ns#' term='change the job owner'/><category scheme='http://www.blogger.com/atom/ns#' term='JOBS'/><title type='text'>Maintain all jobs with a default owner account in Sql server</title><content type='html'>This is common requirement in DBA environment, like all created jobs in the server should run with specified username. Normally in production environment user will not perform the job manually and if it is on schedule also it should run with some service account. When creating a job it would be created with the default user who creates the job and there may be chances also to forget changing the job owner.&lt;br /&gt;&lt;br /&gt;This query will helps to perform all jobs should be under default owner account.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;strong&gt;declare @username varchar(100)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;strong&gt;set @username = 'sa'&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;strong&gt;update sysjobs set owner_sid = &lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;strong&gt;(select sid from master.dbo.syslogins where name = @username)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;strong&gt;where name in (job_a, job_b,...... job_n)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;* you can change the parameters as per your requirement&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-5385520226265711224?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/5385520226265711224/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=5385520226265711224' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5385520226265711224'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5385520226265711224'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2010/06/maintain-all-jobs-with-default-owner.html' title='Maintain all jobs with a default owner account in Sql server'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-8532670206433725126</id><published>2010-06-07T03:24:00.000-07:00</published><updated>2010-06-07T03:31:21.871-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='identify the time of restoration of sql server db'/><category scheme='http://www.blogger.com/atom/ns#' term='database restoration time in sql server'/><category scheme='http://www.blogger.com/atom/ns#' term='db restore'/><category scheme='http://www.blogger.com/atom/ns#' term='db restore details'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server database restoration'/><category scheme='http://www.blogger.com/atom/ns#' term='db restore time'/><title type='text'>Findout Database Restoration Details</title><content type='html'>I got confusion that have I restored my database using latest back or yet to be restored ? B'cos I have no. of databases in different environments and requires to be restored with the latest backup arrived from client dbs.&lt;br /&gt;&lt;br /&gt;To findout these details in the database like when it was restored either full database (or) only filegroup or part of some files restored, It can be achieved in following way :&lt;br /&gt;USE MSDB&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;select BS.user_name,&lt;br /&gt;destination_database_name Database_name,&lt;br /&gt;restore_date Date,&lt;br /&gt;BS.database_name Actual_Database,&lt;br /&gt;BS.server_name,&lt;br /&gt;BS.name,&lt;br /&gt;physical_name,&lt;br /&gt;backup_start_date,&lt;br /&gt;BF.backup_size&lt;br /&gt;from RestoreHistory RH inner join BackupSet BS on RH.backup_set_id = BS.backup_set_id&lt;br /&gt;inner join BackupFile BF on BF.backup_set_id = BS.backup_set_id&lt;br /&gt;order by RH.Restore_Date&lt;br /&gt;&lt;br /&gt;* Database_name and Actual_Database both are same but Actual_Database refers the database which you have restored. If the database is renamed after restoration also it shows the actual name when it was restored.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-8532670206433725126?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/8532670206433725126/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=8532670206433725126' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/8532670206433725126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/8532670206433725126'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2010/06/findout-database-restoration-details.html' title='Findout Database Restoration Details'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-5834471017394770645</id><published>2010-05-25T03:58:00.000-07:00</published><updated>2010-05-25T04:26:33.054-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql server performance increase'/><category scheme='http://www.blogger.com/atom/ns#' term='Improve performance using PERFMON'/><category scheme='http://www.blogger.com/atom/ns#' term='Sql PERFMON'/><category scheme='http://www.blogger.com/atom/ns#' term='PERFMON'/><category scheme='http://www.blogger.com/atom/ns#' term='How to configure PERFMON'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows Monitor'/><category scheme='http://www.blogger.com/atom/ns#' term='what is PERFMON'/><title type='text'>How PERFMON (Windows tool) helps DBA to identify the Performance Issues and take necessary solutions</title><content type='html'>In SQL Server DBA Environment, there are several ways to improve the performance of SQL Server Database Applications such as Query Execution Plans, Sql Profiler, DTA (Database Tuning Advisor), Server Level properties, Object level improvements (Indexes, statistics, other maintenance stuff) and Windows Level Applications. I mean the database performance can be identified in 3 levels i.e., Server Level (Operating Systems, Networking Protocols); Database Level (Sql Server Databsae Engine, SQL Server) ; Object Level (Objects within the database).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So if we are facing the performance degrade then we need to check up at all levels for taking necessary actions. Currently I will discuss about the Server Level Tool PERFMON which is very useful to identify the sever levels activities, based on the identified results we can take appropriate action to improve the performance. It can be Hardware, Memory (or) System changes.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;PERFMON :&lt;/strong&gt; PERFMON is a windows inbuilt tool which can provide the workload of the resources running in the system. It can be used to find out Windows resources data as well as SQL Server resources.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Main Benefits Of The Tool : &lt;/strong&gt;&lt;br /&gt;• Understand your workload and its effect on your system's resources.&lt;br /&gt;• Observe changes and trends in workloads and resource usage so you can plan for future upgrades.&lt;br /&gt;• Test configuration changes or other tuning efforts by monitoring the results.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;System Monitor and Performance Logs and Alerts provide detailed data about the resources used by specific components of the operating system and by programs that have been designed to collect performance data.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Choosing the data to monitor :&lt;/strong&gt;&lt;br /&gt;Start by monitoring the activity of the following components in order:&lt;br /&gt;• Memory&lt;br /&gt;• Processors&lt;br /&gt;• Disks&lt;br /&gt;• Network&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Following counters can be helpful to trace the data&lt;br /&gt;&lt;br /&gt;1:&lt;br /&gt;Component : Disk&lt;br /&gt;Performance aspect being monitored : Usage&lt;br /&gt;Counters to monitor :&lt;br /&gt;Physical Disk\Disk Reads/sec, Physical Disk\Disk Writes/sec, LogicalDisk\% Free Space, Interpret the % Disk Time counter carefully. Because the _Total instance of this counter may not accurately reflect utilization on multiple-disk systems, it is important to use the % Idle Time counter as well. Note that these counters cannot display a value exceeding 100%. &lt;a href="http://2.bp.blogspot.com/_20DZwQsD82M/S_uvvXnnn0I/AAAAAAAAAD0/XsDxnk80gMA/s1600/table.JPG"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2 :&lt;br /&gt;Component : Disk&lt;br /&gt;Performance aspect being monitored : Hindrances&lt;br /&gt;Counters to Monitor : Physical Disk\Avg. Disk Queue Length (all instances)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3:&lt;br /&gt;Component : Memory&lt;br /&gt;Performance aspect being monitored : Usage&lt;br /&gt;Counters to Monitor : Memory\Available Bytes, Memory\Cache Bytes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4:&lt;br /&gt;Component : Memory&lt;br /&gt;Performance aspect being monitored : Hindrances&lt;br /&gt;Counters to Monitor : Memory\Pages/sec, Memory\Page Reads/sec, Memory\Transition Faults/sec, Memory\Pool Paged Bytes, Memory\Pool Nonpaged Bytes.&lt;br /&gt;Although not specifically Memory object counters, the following are also useful for memory analysis: Paging File\% Usage object (all instances), Cache\Data Map Hits %, Server\Pool Paged Bytes and Server\Pool Nonpaged Bytes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;5:&lt;br /&gt;Component : Network&lt;br /&gt;Performance aspect being monitored : Throughput&lt;br /&gt;Counters to Monitor : Protocol transmission counters (varies with networking protocol); for TCP/IP: Network Interface\Bytes total/sec, Network Interface\ Packets/sec, Server\Bytes Total/sec, or Server\Bytes Transmitted/sec and Server\Bytes Received/sec&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6:&lt;br /&gt;Component : Processor&lt;br /&gt;Performance aspect being monitored : Usage&lt;br /&gt;Counters to Monitor : Processor\% Processor Time (all instances)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;7:&lt;br /&gt;Component : Processor&lt;br /&gt;Performance aspect being monitored : Hindrances&lt;br /&gt;Counters to Monitor : System\Processor Queue Length (all instances),&lt;br /&gt;Processor\ Interrupts/sec, System\Context switches/sec&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;How to Create and perform :&lt;br /&gt;&lt;/strong&gt;1. Go to RUN and type PERFMON then Enter&lt;br /&gt;2. Double-click Performance Logs and Alerts, and then double-click Counter Logs. Any existing logs will be listed in the details pane. A green icon indicates that a log is running; a red icon indicates that a log has been stopped.&lt;br /&gt;3. Right-click a blank area of the details pane, and click New Log Settings.&lt;br /&gt;4. In Name, type the name of the log, and then click OK.&lt;br /&gt;5. On the General tab, click Add Objects and select the performance objects you want to add, or click Add Counters to select the individual counters you want to log.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Configure the other setings as you required. It can be run for certain time period i.e, 10 hours, 1 day, 1 week to identify how the processes are running in the system. The data can be saved as .CSV or text files. When you get the data you can make a charts using Excel and it can be understandable what necessary action to be taken for improving performance.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-5834471017394770645?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/5834471017394770645/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=5834471017394770645' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5834471017394770645'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5834471017394770645'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2010/05/how-perfmon-windows-tool-helps-dba-to.html' title='How PERFMON (Windows tool) helps DBA to identify the Performance Issues and take necessary solutions'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-5805443276389575664</id><published>2010-05-20T04:08:00.000-07:00</published><updated>2010-05-20T04:19:01.451-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQLSERVER maintenance'/><category scheme='http://www.blogger.com/atom/ns#' term='Dbcc shrink files'/><category scheme='http://www.blogger.com/atom/ns#' term='sqlserver log file'/><category scheme='http://www.blogger.com/atom/ns#' term='shrink log file'/><category scheme='http://www.blogger.com/atom/ns#' term='Log shrink'/><category scheme='http://www.blogger.com/atom/ns#' term='shrink file'/><category scheme='http://www.blogger.com/atom/ns#' term='shrinking file'/><category scheme='http://www.blogger.com/atom/ns#' term='log file maintenance'/><category scheme='http://www.blogger.com/atom/ns#' term='dbcc sqlperf(logspace)'/><title type='text'>Understand how shrinking a LOG file works :</title><content type='html'>&lt;strong&gt;Understand how shrinking a LOG file works : &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Many of them faced while shrinking a log file in the database, after applying the DBCC&lt;br /&gt;Shrinkfile option also the files size not reduced. What was the structure behind, how it works.&lt;br /&gt;&lt;br /&gt;For an example you have a database consists of data and log files, which log file size is growing abnormally exceeding hard drive size. So you need to reduce the file to accommodate within the available space. So maximum people would perform following options to decrease the file size.&lt;br /&gt;&lt;br /&gt;1) Either truncating log file directly then shrink&lt;br /&gt;Backup log 'DATABASE' with truncate_only&lt;br /&gt;DBCC shrinkdatabase ('database',10) (or)&lt;br /&gt;DBCC shrinkfile ('logfile')&lt;br /&gt;&lt;br /&gt;2) or Applying the shrinkdatabase option directly on the database.&lt;br /&gt;&lt;br /&gt;3) or Keeping Full / Log backup jobs in the server with some time intervals and shrinking the database.&lt;br /&gt;&lt;br /&gt;Whether these above options are sufficient to perform the maintenance of Log file in the server. No, these can be manageable upto some extent only, if you can follow the above activities with slight changes you can expect 100% results from it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What are the drawbacks in above processes :&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;1) If you truncate directly your log file then shrink the database, you can have reduced log file, but if you need to restore your database using the log backup.......... no backup available&lt;br /&gt;&lt;br /&gt;2) Applying shrink option directly doesn't give you much impact&lt;br /&gt;&lt;br /&gt;3) Keeping Log backup and perform shrink option will give you the good result but it should happend sequentially.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The Process behind log backup and shrink :&lt;br /&gt;&lt;/strong&gt;1) I have database consists of log file size 100Mb and Used space in the log file is 94 MB.&lt;br /&gt;This can be find out using &lt;strong&gt;DBCC sqlperf(logspace)&lt;/strong&gt;.&lt;br /&gt;2) I have performed &lt;strong&gt;DBCC shrinkfile ('log file')&lt;/strong&gt; for size decrease ; but it increased instead of decrease. Why bcos the log file having the logs and for shrinking it written on the top of it, it increased. Use &lt;strong&gt;DBCC sqlperf(logspace)&lt;/strong&gt; to check the details.&lt;br /&gt;3) Now I have performed backup log file then performed the shrink option. It reduced to the initial size and my drive is free now.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Additional options to findout : &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;A) Run following query&lt;br /&gt;&lt;strong&gt;DBCC loginfo&lt;br /&gt;&lt;/strong&gt;If the status in the below table is 2 then it is waiting for the backup&lt;br /&gt;else it is 0 then it can be shrinked&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;result : &lt;/strong&gt;&lt;br /&gt;Field FileSize Startoffset FseqNo STatus Parity CreateLSN&lt;br /&gt;2 2555904 8192 98682 2 64 0&lt;br /&gt;2 2555904 2564096 98683 2 128 0&lt;br /&gt;2 2555904 5120000 98685 2 64 0&lt;br /&gt;2 2809856 7675904 98684 2 128 0&lt;br /&gt;2 253952 10485760 98686 2 64 98685000000407400016&lt;br /&gt;2 253952 10739712 98687 2 64 98685000000407400016&lt;br /&gt;2 253952 10993664 98688 2 64 98685000000407400016&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;b) Run following query whether the backup is pending or not&lt;br /&gt;&lt;strong&gt;select log_reuse_wait_desc from sys.databases where name = 'database'&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;if the result is 'LOG_BACKUP' then waiting for backup&lt;br /&gt;if the result if 'NOTHING' then it can be shrinked&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Note : In Sql Server 2008 there is no truncating log backup option, instead you can alter the recovery mode into simple then shrink. Again change the mode into normal. &lt;/em&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-5805443276389575664?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/5805443276389575664/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=5805443276389575664' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5805443276389575664'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5805443276389575664'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2010/05/understand-how-shrinking-log-file-works.html' title='Understand how shrinking a LOG file works :'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-1259579442501537015</id><published>2010-04-29T05:16:00.000-07:00</published><updated>2010-04-29T05:26:06.138-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sql Server certifications'/><category scheme='http://www.blogger.com/atom/ns#' term='MCTS'/><category scheme='http://www.blogger.com/atom/ns#' term='Sql Server 2008 Certification Details'/><category scheme='http://www.blogger.com/atom/ns#' term='Book reference for MCITP'/><category scheme='http://www.blogger.com/atom/ns#' term='Sql Server 2008 Certification'/><category scheme='http://www.blogger.com/atom/ns#' term='MCITP'/><category scheme='http://www.blogger.com/atom/ns#' term='Book reference for MCTS'/><title type='text'>SQL Server 2008 Certification Details</title><content type='html'>Useful information about Sql Server 2008 Certification Exams :  (Click on the image to read)&lt;br /&gt;&lt;div&gt;&lt;a href="http://1.bp.blogspot.com/_20DZwQsD82M/S9l5Ag3_dPI/AAAAAAAAADU/A1IcqeOBQ44/s1600/Sql+Serer+2008+Cert1.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5465532672522548466" style="WIDTH: 506px; CURSOR: hand; HEIGHT: 295px" alt="" src="http://1.bp.blogspot.com/_20DZwQsD82M/S9l5Ag3_dPI/AAAAAAAAADU/A1IcqeOBQ44/s320/Sql+Serer+2008+Cert1.JPG" border="0" /&gt;&lt;/a&gt; &lt;/div&gt;&lt;a href="http://2.bp.blogspot.com/_20DZwQsD82M/S9l5UdXR61I/AAAAAAAAADk/88Vhh-eXZjc/s1600/Sql+Serer+2008+Cert2.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5465533015177423698" style="WIDTH: 480px; CURSOR: hand; HEIGHT: 262px" alt="" src="http://2.bp.blogspot.com/_20DZwQsD82M/S9l5UdXR61I/AAAAAAAAADk/88Vhh-eXZjc/s320/Sql+Serer+2008+Cert2.JPG" border="0" /&gt;&lt;/a&gt; &lt;a href="http://2.bp.blogspot.com/_20DZwQsD82M/S9l5ryh7GJI/AAAAAAAAADs/A1ijxlbVKu0/s1600/Sql+Serer+2008+Cert+(UPG+PATH).JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5465533415996201106" style="WIDTH: 483px; CURSOR: hand; HEIGHT: 239px" alt="" src="http://2.bp.blogspot.com/_20DZwQsD82M/S9l5ryh7GJI/AAAAAAAAADs/A1ijxlbVKu0/s320/Sql+Serer+2008+Cert+(UPG+PATH).JPG" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-1259579442501537015?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/1259579442501537015/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=1259579442501537015' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/1259579442501537015'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/1259579442501537015'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2010/04/sql-server-2008-certification-details.html' title='SQL Server 2008 Certification Details'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_20DZwQsD82M/S9l5Ag3_dPI/AAAAAAAAADU/A1IcqeOBQ44/s72-c/Sql+Serer+2008+Cert1.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-3314486589409020588</id><published>2010-04-13T02:25:00.000-07:00</published><updated>2010-04-13T02:30:19.187-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database maintenance'/><category scheme='http://www.blogger.com/atom/ns#' term='truncate_only'/><category scheme='http://www.blogger.com/atom/ns#' term='Log size reduce'/><category scheme='http://www.blogger.com/atom/ns#' term='Dbcc Shrink Log'/><category scheme='http://www.blogger.com/atom/ns#' term='Shrink log'/><category scheme='http://www.blogger.com/atom/ns#' term='Log file shrink'/><category scheme='http://www.blogger.com/atom/ns#' term='discontinued feature from Sql server 2008'/><title type='text'>Log file Maintenance in SQL SERVER 2000/2005 &amp; 2008 :</title><content type='html'>In earlier version of SQL Server if the database log is full then by truncating the Log file, we can free up the database log file space.    For an example you have allocated 5 GB for log file and it crosses the limit after certain period.  As a result it doesn't allows any database transactions and receives continuous errors.    In SQL server 2005 and 2000 we can free up the space by using following commands. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;USE DatabaseName &lt;br /&gt; * Database will be your user database. &lt;br /&gt;&lt;br /&gt; BACKUP LOG DatabaseName WITH TRUNCATE_ONLY&lt;br /&gt; * it will truncate all the contents from log file&lt;br /&gt;&lt;br /&gt; DBCC SHRINKFILE (Log File)&lt;br /&gt; * It will shrink the file into its intial size. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But the above process doesn't work in SQL server 2008.  These features are discontinued from the latest version and for achieving this requirement you need to work on following method. &lt;br /&gt;&lt;br /&gt;First Alter the database from Full recovery mode to Simple recovery mode, then Shrink the database and again change the mode into full. &lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt; ALTER DATABASE DatabaseName SET RECOVERY SIMPLE&lt;br /&gt; * This will change the database mode into simple&lt;br /&gt;&lt;br /&gt; DBCC SHRINKFILE (Log File)&lt;br /&gt; * It will shrink the file into its intial size. &lt;br /&gt;&lt;br /&gt; ALTER DATABASE DatabaseName SET RECOVERY FULL&lt;br /&gt; * This will change the database mode into full&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;The above process can be done using SQL Server Management studio also. &lt;br /&gt;&lt;br /&gt;To check up the database and its file details you can use system procs sp_helpdb, sp_helpdb databasename.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-3314486589409020588?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/3314486589409020588/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=3314486589409020588' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/3314486589409020588'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/3314486589409020588'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2010/04/log-file-maintenance-in-sql-server.html' title='Log file Maintenance in SQL SERVER 2000/2005 &amp; 2008 :'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-2687190276823141242</id><published>2010-03-18T03:47:00.000-07:00</published><updated>2010-04-13T02:32:24.712-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql server performance increase'/><category scheme='http://www.blogger.com/atom/ns#' term='table partition'/><category scheme='http://www.blogger.com/atom/ns#' term='table partitioning'/><category scheme='http://www.blogger.com/atom/ns#' term='partition scheme'/><category scheme='http://www.blogger.com/atom/ns#' term='partition function'/><category scheme='http://www.blogger.com/atom/ns#' term='partitioning a table'/><title type='text'>Partition a Table for better performance in Sql Server 2005 / 2008</title><content type='html'>In earlier versions we didn't have partitioning a table option to distribute the data across multiple file groups.  This was introduced with Sql server 2005 including other valuable features.  Partitioning can be performed with help of Partition Function, Partition Scheme.   &lt;br /&gt; &lt;br /&gt;Partition is nothing like distributing the data across multiple file groups, as we all know if we share the data into multiple drives automatically performance of the database will be increased.   Let assume we have a big table comprises million of records, when fetching the data it took too long time.   So, for increasing the performance of the table we can implement Partitioning concept and achieve the better performance. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;HOW TO PARTITION A TABLE : &lt;/strong&gt;&lt;br /&gt;Requirement : A table is to be defined with multiple columns, out of which we need to fetch the data based on column "Name".   If you select data based on Name there would be many records with different names comprising letters from A-Z.  So by using following method, the data can be distributed into different file groups.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Step 1 : As a first step you need to create a Partition function :&lt;/strong&gt;&lt;br /&gt;CREATE PARTITION FUNCTION NameFunc (nvarchar(30))&lt;br /&gt;AS RANGE RIGHT FOR VALUES ('H', 'N')&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Step 2 : Need to create partition scheme based on the partition function : &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;CREATE PARTITION SCHEME NameScheme&lt;br /&gt;AS PARTITION NameFunc TO (fg1, fg2, fg3)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Step 3 : Create a table based on Function and Scheme &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;CREATE TABLE dbo.Employees &lt;br /&gt;(EmpID int, Name nvarchar(30))&lt;br /&gt;ON NameScheme (Name)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Explanation :  &lt;/strong&gt;&lt;br /&gt; In the first step 1, 'H', 'N' values defines &lt;br /&gt; A-H first group, &lt;br /&gt; H-N second group,&lt;br /&gt; N-Z Third group&lt;br /&gt;&lt;br /&gt; the above 3 groups will be stored on fg1, fg2 and fg3 file groups respectively.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-2687190276823141242?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/2687190276823141242/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=2687190276823141242' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/2687190276823141242'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/2687190276823141242'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2010/03/partition-table-for-better-performance.html' title='Partition a Table for better performance in Sql Server 2005 / 2008'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-7024832184695776074</id><published>2010-01-06T02:13:00.000-08:00</published><updated>2010-01-12T01:36:20.866-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Online index'/><category scheme='http://www.blogger.com/atom/ns#' term='online index in sql server 2005'/><category scheme='http://www.blogger.com/atom/ns#' term='index features in 2005'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server cursor'/><category scheme='http://www.blogger.com/atom/ns#' term='index checkup'/><category scheme='http://www.blogger.com/atom/ns#' term='cursor'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server 2005 new concepts'/><title type='text'>Online Indexing in Sql Server 2005</title><content type='html'>In SQL Server 2005, the index can be created while Insert/update/delete happening on a table. Without affecting performance degradance to table the index will be created. This concept is called Online indexing in Sql server. &lt;br /&gt;&lt;br /&gt;I have taken following sample queries to test online indexing : &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Step 1: Create sampe tables to hold the data&lt;/strong&gt;create table Index_Check (id int identity(1,1), name varchar(20),join_date datetime, Amount float)&lt;br /&gt;Create table names (name varchar(50))&lt;br /&gt;insert into names values ('Software company,Bangalore,India')&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Step 2 :  Executing cursor to insert the data continuously&lt;/strong&gt;&lt;br /&gt;declare venkat cursor local &lt;br /&gt;for&lt;br /&gt;Select NAME FROM NAMES &lt;br /&gt;open venkat&lt;br /&gt;Declare @aaa VARCHAR(20)&lt;br /&gt;fetch next from venkat into @aaa&lt;br /&gt;while @@fetch_status =0&lt;br /&gt;exec ('insert into Index_Check (name,join_date) select '''+@aaa+''', GETDATE()')&lt;br /&gt;fetch next from venkat into @aaa&lt;br /&gt;deallocate venkat&lt;br /&gt;close venkat&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Step 3 : Connect the same server and same table from other connection, try to create cluster / nonclustered online index&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Create clustered index IDX_Check on Index_Check(id) with (online=on)&lt;br /&gt;Create nonclustered index IDX_Check1 on Index_Check(id) with (online=on)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Successfully index creates without disturbing the table process.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can schedule rebuilding index depends on the data usage in the database.  While performing rebuild it can be configured to perform online/offline.  Online means it doens't impact anything to the table operation and does.   But it has some restrictions also like or text data type columns we can't perform online reindexing and etc.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-7024832184695776074?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/7024832184695776074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=7024832184695776074' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/7024832184695776074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/7024832184695776074'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2010/01/online-indexing-in-sql-server-2005.html' title='Online Indexing in Sql Server 2005'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-6408687939712646528</id><published>2010-01-04T02:57:00.000-08:00</published><updated>2010-01-04T03:03:19.101-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='RAID 0+1'/><category scheme='http://www.blogger.com/atom/ns#' term='RAID 0'/><category scheme='http://www.blogger.com/atom/ns#' term='RAID 1+0'/><category scheme='http://www.blogger.com/atom/ns#' term='RAID Levels'/><category scheme='http://www.blogger.com/atom/ns#' term='RAID 5'/><category scheme='http://www.blogger.com/atom/ns#' term='RAID 3'/><category scheme='http://www.blogger.com/atom/ns#' term='Redundant array'/><category scheme='http://www.blogger.com/atom/ns#' term='Sql server installation on RAID'/><category scheme='http://www.blogger.com/atom/ns#' term='RAID 1'/><category scheme='http://www.blogger.com/atom/ns#' term='RAID 4'/><category scheme='http://www.blogger.com/atom/ns#' term='RAID 6'/><title type='text'>RAID : Understanding of RAID and its functionality</title><content type='html'>&lt;strong&gt;Understanding of RAID......Redundant Array of Indepenent Disks (RAID)&lt;/strong&gt;&lt;br /&gt;RAID is a combination of multilple disks to improve the performance and safety of the data.  This can be configured using SCSI contollers. SCSI is nothing but a card which can have facility of connect multiple disks.  Once configured the RAID, the data is available on ARRAY comprising the available disks.  There are mainly 3 terms need to remember while working with RAID levels.  Mirroring, Stripped disks and fault tolerance. &lt;br /&gt;&lt;br /&gt;There are different RAID levels for various requirements.  We can implement the actual RAID level to achieve 100% success. &lt;br /&gt;&lt;br /&gt;RAID 0 : It distributes the data across multiple disks.  The data retrieving can be faster as the data is dividing into  multilpe disks.  But this levels doesn't have any data safety, means if one disk fails you will loose the data automatically. &lt;br /&gt;&lt;br /&gt;RAID 1 : Mirror the data from one disk to another.  Here we have more safety, if one disk fails automatically another disks works which already has mirrored data. &lt;br /&gt;&lt;br /&gt;RAID 3 (OR) 4 : This level requires minimum 3 disks including 2 for data distribution and 1 for fault tolerance.  Here we have data safety mechanism with full performance  including redundant data identification. For this level 1 dedicated disk is required to store redundant data.&lt;br /&gt;&lt;br /&gt;RAID 5 : This level also requires 3 or more disks to protect the data in case any one disk fails.  Here we dont required dedicated disk for storing redundant data, this will be stored in the combination of all disks.  This level has higher data safety allows only one disks to fail.  If more than one disks fails then the data will not be available on array. &lt;br /&gt;&lt;br /&gt;RAID 6 : Similar to RAID 5, but it requires minimum 4 disks and allows to fail 2 disks.  Means 2 disks can fail in this raid level, if more than 2 disks fails than the data wouldn't be available. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;There are 2 more new levels introduced i.e...., &lt;br /&gt;&lt;br /&gt;RAID 1+0 : Combination of RAID 1 + RAID 0, whatever the features having both levels can incorporate here.  But in the sequence like first it mirror the data (safety) then distribute the data across drives (performance). &lt;br /&gt;&lt;br /&gt;RAID 0+1 : Combination of RAID 0 + RAID 1, whatever the features having both levels can incorporate here.  But in the sequence like first it distribute the data across drives (performance) then mirror the data (safety). &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;When consider to SQL Server installation mostly we can use RAID 5 for backups of the databases where it requires only 3 disks (less hardware) and high safety with high performance.  If the data is too much important and your company can able to spend money like data worth's than any thing, you can suggest  RAID 6 level where it comprises 4 disks with dual disk safety.  &lt;br /&gt;&lt;br /&gt;RAID 1+0 is good for installing Tempdb database where TEMPDB database requires safety of data with good performance.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-6408687939712646528?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/6408687939712646528/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=6408687939712646528' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/6408687939712646528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/6408687939712646528'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2010/01/raid-understanding-of-raid-and-its.html' title='RAID : Understanding of RAID and its functionality'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-4808485162292437518</id><published>2009-11-27T02:13:00.000-08:00</published><updated>2009-11-27T02:18:23.067-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='master db rebuild'/><category scheme='http://www.blogger.com/atom/ns#' term='master and resource databsae'/><category scheme='http://www.blogger.com/atom/ns#' term='live lock'/><category scheme='http://www.blogger.com/atom/ns#' term='having clause'/><category scheme='http://www.blogger.com/atom/ns#' term='where clause'/><category scheme='http://www.blogger.com/atom/ns#' term='materialized view'/><category scheme='http://www.blogger.com/atom/ns#' term='deadlock and livelock'/><category scheme='http://www.blogger.com/atom/ns#' term='difference between inner join and union'/><category scheme='http://www.blogger.com/atom/ns#' term='covering index'/><title type='text'>Some useful Interview questions</title><content type='html'>&lt;strong&gt;What is materialized view?&lt;/strong&gt;We can name it materialized view in different ways like Schema Binding view, Structure binding view and materilizaed view.  The main use of the view is it acts as a table like hold the schema.    For a example normal view is a select query written by combining multiple tables.  If we want to improve the performance there is only a way that we can alter the statements in better way.    But if consider materialized view, one can create indexes apart from altering a query for better performance.   As you understood indexes will give more performance compares with any other option available in sql server. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What is the diff between inner join and union?&lt;/strong&gt;Inner join retrieves the matched data from 2 or more tables where as union will retrieve distinct data from 2 or more tables.   Join is like horizontal result, Union is like vertical result. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What is the diff between master database and resource database?&lt;/strong&gt; If resource database was corrupted sql server will work or not? How you can repair that?&lt;br /&gt;Master and Resource both are system dbs in sql server.  But master is the primary database which will contain all security structures, objects structures and other user database dependent information where as resource will have copy of the users database system tables which helps at the time of upgradation or degradation.    The resource purpose is intended in Sql server 2005 is only for Upgradation or degradation of the versions or service packs.   If resource is not available, then also Sql server will not work as some dependent services are working based on resource db structured in Sql Server 2005.  Eg : Alert Service, Performance related services. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;If i need to give permission per column in table how you can give and tell me process?&lt;/strong&gt;--&lt;br /&gt;Step 1: &lt;br /&gt;Create table NB_Perm (sl int, name varchar(10))&lt;br /&gt;&lt;br /&gt;--STep 2 :&lt;br /&gt;Create role NB_role &lt;br /&gt;&lt;br /&gt;--Step 3 : &lt;br /&gt;grant select (sl) on nb_perm to NB_role&lt;br /&gt;deny select(sl) on nb_perm to NB_Role&lt;br /&gt;&lt;br /&gt;Make your users member of this role. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What is use of built/administrator in sql server?&lt;/strong&gt;It is a Windows Group defaultly created with installation of SQL Server.  The role defaultly assigned is Sysadmin.   If we want this group to be there in Sql server we can keep it and create the users under this group.  For creating users refer Administrator Tools – Computer Management  - Users and Groups.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What is the diff between having clause and where clause?&lt;/strong&gt;‘Having’ clause can be used when the query consists aggregate functions like count, avg …..  &lt;br /&gt;Eg : Select id,count(id) from table having count(id)&gt;5&lt;br /&gt;‘Where’ clause can be used to filter the data in any statement irrespective of conditions.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;How you can know who was last using the query?&lt;/strong&gt;In earlier versions we can find by implementing the trigger.   But in Sql server 2008 new concept auditing is available.   With help of this we can find out. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What is the diff between physical file and logical file and which one you refer at the time shrink the file?&lt;/strong&gt;Logical and Physical both are database files where logical file available inside the database structure and physical file available at the destination drive.    Logical and physical both are important at the time of backup, restore or any kind of database operation.   As you requested I refer the logical file only at the time of shrinking or restoring the db.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What is covering Index and can you give me one example?&lt;/strong&gt;Covering index is an index which helps to reduce the index size in a database.  Like a index will improve the performance and as a disadvantage it occupies some space in your db.   Suppose if you want to create index by using more columns then you can refer convering index as best solution.  Addition to decreasing the table space it gives good performance also as running the indexes only it requires on the columns.   The suggestions from my side is create all int kind of data columns in index list and varchar kind of column in include list. &lt;br /&gt;Eg : Create (cluster/nonclustered) index  IndexName on table (main columns) include (other columns)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What is live lock?&lt;/strong&gt;A live lock 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 live lock also occurs when read transactions monopolize a table or page, forcing a write transaction to wait indefinitely&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Diff between live lock and dead lock&lt;/strong&gt;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.&lt;br /&gt;&lt;br /&gt;A live lock 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 Live lock also occurs when read transactions monopolize a table or page, forcing a write&lt;br /&gt;transaction to wait indefinitely&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Lock escalation&lt;/strong&gt;Lock escalation is the process of escalating a significant number of row level locks to a single table lock.  This is trick performed by SQL Server as a way of conserving memory and improving performance.  The problem is it works well for smaller systems but can easily throttle performance on larger systems when the activity reaches a certain threshold.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;How can rebuild master db&lt;/strong&gt;Process : &lt;br /&gt;1) Shutdown the SQL server and its services.&lt;br /&gt;2) Goto Program Files\Microsoft SQL Server\80\Tools\Binn directory.&lt;br /&gt;3) Open Rebuildm.exe&lt;br /&gt;4) In the Browse for Folder dialog box, select the \Data folder on the SQL Server 2000 compact disc or in the shared network directory from which SQL Server 2000 was installed, and then click OK.&lt;br /&gt;5) Change collation settings if required or leave it default.&lt;br /&gt;6) In the Rebuild Master dialog box, click Rebuild to start the process. &lt;br /&gt;DTS to SSIS migration&lt;br /&gt;We cannot migrate DTS packages from 2000 to 2005 (or) 2008.  If it is simple package then we can use it as it is.   If it consists vbcode and all it will not convert instead we need to rewritten the package using SSIS.  Because SSIS uses .net code.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Types of replication agents&lt;/strong&gt;Replication Snapshot Agent: &lt;br /&gt;Replication Log Reader Agent: &lt;br /&gt;Replication Distribution Agent:&lt;br /&gt;Replication Merge Agent: &lt;br /&gt;Replication Queue Reader Agent: &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Public/private network&lt;/strong&gt;Public vs. private networks&lt;br /&gt;Computers that are connected to each other create a network.  These networks are often configured with "public" Internet Protocol (IP) addresses -- that is, the devices on the network are "visible" to devices outside the network (from the Internet or another network).  Networks can also be configured as "private" -- meaning that devices outside the network cannot "see" or communicate directly to them.&lt;br /&gt;Computers on a public network have the advantage (and disadvantage) that they are completely visible to the Internet.  As such, they have no boundaries between themselves and the rest of the Internet community.  This advantage oftentimes becomes a distinct disadvantage since this visibility can lead to a computer vulnerability exploit -- a.k.a., a "hack" -- if the devices on the public network are not properly secured.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-4808485162292437518?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/4808485162292437518/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=4808485162292437518' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/4808485162292437518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/4808485162292437518'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/11/some-useful-interview-questions.html' title='Some useful Interview questions'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-8441146820129594540</id><published>2009-11-16T05:02:00.001-08:00</published><updated>2009-11-16T05:02:55.260-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='difference between master and resource'/><category scheme='http://www.blogger.com/atom/ns#' term='Resource database'/><category scheme='http://www.blogger.com/atom/ns#' term='Master and Resource'/><category scheme='http://www.blogger.com/atom/ns#' term='master'/><category scheme='http://www.blogger.com/atom/ns#' term='Master database'/><category scheme='http://www.blogger.com/atom/ns#' term='system databases in sql server'/><category scheme='http://www.blogger.com/atom/ns#' term='resource'/><title type='text'>The difference between Master and Resource databases</title><content type='html'>The difference between Master and Resource database&lt;br /&gt;&lt;br /&gt;Mster db is the mother database for all other databases like it consits of other database information, configurations, file locations, security context and etc. whereas Resource db is a database addition to master consists of database schema and stored procedures which requires to run databases in current instance.  Resource db mainly introduced for Upgradation or rollback your installations in Sql server 2005.  &lt;br /&gt;&lt;br /&gt;Some differences: &lt;br /&gt;&lt;br /&gt;Master : &lt;br /&gt;1. Master will have data specific to your instance.&lt;br /&gt;&lt;br /&gt;2. The database can be found in your sqlserver installation data folder with the name of master.mdf.&lt;br /&gt;&lt;br /&gt;3. For any maintenance activity you need to make the db in single user mode. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Resource : &lt;br /&gt;1. Resource will have schema and stored procedures to run your instance. &lt;br /&gt;&lt;br /&gt;2. It is introduced in Sql server 2005 for upgradation purpose.  In sql server 2000 if you want to upgrade to a new service pack, you would need to run many log scripts that drop and create system scripts.  It is too long process and much time consume.  In Sql server 2005 if you install service pack or quick fix a copy of resource database will overrite the old database.   With help of this resource db you can easily upgrade or rollback your service packs.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. The database can be found in your sqlserver installation data folder with the name of mssqlsystemresource.mdf.&lt;br /&gt;&lt;br /&gt;4. It is a hidden database, you can't findout it in sysdatabases table. By using serverproperty we can view the information about the resource db.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-8441146820129594540?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/8441146820129594540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=8441146820129594540' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/8441146820129594540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/8441146820129594540'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/11/difference-between-master-and-resource.html' title='The difference between Master and Resource databases'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-1922072116649006603</id><published>2009-09-16T07:34:00.000-07:00</published><updated>2009-09-24T00:55:58.215-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Jobs history'/><category scheme='http://www.blogger.com/atom/ns#' term='Jobs informations'/><category scheme='http://www.blogger.com/atom/ns#' term='findout job history in SQl server'/><category scheme='http://www.blogger.com/atom/ns#' term='jobs duration'/><category scheme='http://www.blogger.com/atom/ns#' term='jobs for long time'/><category scheme='http://www.blogger.com/atom/ns#' term='FIND THE SQL SERVER JOB DETAILS'/><category scheme='http://www.blogger.com/atom/ns#' term='job report'/><title type='text'>Query to findout JOBs information for a period of time</title><content type='html'>I hope this requirement is very common in DBA work life, as DBA needs to findout how the JOBs are performing currently and for a long time. I too faced the requirement. I have searched most of the pages from google and I couldn't found the solution.   Finally I written the following query spending almost 3 hours. &lt;br /&gt;&lt;br /&gt;Hopefully it will useful for all SQL Server DBAs.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Syntax : &lt;/strong&gt;&lt;br /&gt;Select b.Name JobName, a.step_name,a.run_date,run_time,&lt;br /&gt;case when len(a.run_time) = 5 then convert(varchar,left(a.run_time,1)) + ':' + convert(varchar,left(right(a.run_time,4),2)) + ':' + convert(varchar,right (a.run_time,2))&lt;br /&gt;when len(a.run_time) = 4 then '00' + ':'+convert(varchar,left(a.run_time,2)) + ':'+convert(varchar,right(a.run_time,2))&lt;br /&gt;when len(a.run_time) = 3 then '00:0' + convert(varchar,left(a.run_time,1)) + ':'+convert(varchar,right(a.run_time,2))&lt;br /&gt;when len(a.run_time) = 2 then '00:00:' + convert(varchar,left(a.run_time,2))&lt;br /&gt;when len(a.run_time) = 1 then '00:00:0' + convert(varchar,left(a.run_time,1))&lt;br /&gt; else&lt;br /&gt;convert(varchar,left(a.run_time,2)) + ':' + convert(varchar,left(right(a.run_time,4),2)) + ':' + convert(varchar,right (a.run_time,2)) End run_time,&lt;br /&gt;run_duration,&lt;br /&gt; ISNULL(SUBSTRING(CONVERT(varchar(7),run_duration+1000000),2,2) + ':'&lt;br /&gt;        +        SUBSTRING(CONVERT(varchar(7),run_duration+1000000),4,2) + ':'&lt;br /&gt;        +        SUBSTRING(CONVERT(varchar(7),run_duration+1000000),6,2),'') AS [Duration], a.message&lt;br /&gt;from sysjobs b inner join sysjobhistory a on a.job_id = b.job_id &lt;br /&gt;where b.name like '%Reindex%' AND step_name not like 'Notification' &lt;br /&gt;and step_name not like '%Job Outcome%' order by b.Name&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For the above query you can add filter conditions as per your requirements.  By getting the result of above query you can have an idea of how the jobs are involved and making the analysis you can increase the performance of the server.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-1922072116649006603?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/1922072116649006603/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=1922072116649006603' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/1922072116649006603'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/1922072116649006603'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/09/query-to-findout-jobs-information-for.html' title='Query to findout JOBs information for a period of time'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-4559390902152456906</id><published>2009-09-10T04:59:00.000-07:00</published><updated>2009-09-10T05:03:24.912-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='List out all object count'/><category scheme='http://www.blogger.com/atom/ns#' term='Sql server objects count'/><category scheme='http://www.blogger.com/atom/ns#' term='find database objects count'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server objects'/><category scheme='http://www.blogger.com/atom/ns#' term='count of tables'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server object list'/><category scheme='http://www.blogger.com/atom/ns#' term='count of view'/><category scheme='http://www.blogger.com/atom/ns#' term='count of functions'/><category scheme='http://www.blogger.com/atom/ns#' term='count of procedures'/><title type='text'>Query to findout list of Objects count from all databases in SQL Server :</title><content type='html'>This is very useful query on DBA daily work environment.  I have struggled to findout the information before.  Finally I developed following query to get the information. &lt;br /&gt;&lt;br /&gt;Select 'select ('''+name+''') Database_name, &lt;br /&gt;(Select count(*) from '+name+'.dbo.sysobjects where xtype = ''u'') Table_Count,&lt;br /&gt;(Select count(*) from '+name+'.dbo.sysobjects where xtype = ''v'') View_Count,&lt;br /&gt;(Select count(*) from '+name+'.dbo.sysobjects where xtype in (''fn'', ''tn'')) func_Count,&lt;br /&gt;(Select count(*) from '+name+'.dbo.sysobjects where xtype = ''p'') proc_Count, &lt;br /&gt;(Select count(*) from '+name+'.dbo.sysobjects where xtype = ''tr'') Trig_Count union all'&lt;br /&gt;from sysdatabases where dbid &gt; 4&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Instructions : &lt;br /&gt;&lt;br /&gt;* you need to take the result script of above query and execute in other window.  And you need to remove 'UNION ALL" from end statement.&lt;br /&gt;* dbid &gt; 4 = it will not show for sysdatabases&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Result Query : &lt;br /&gt;&lt;br /&gt;select ('TEST') Database_name, (Select count(*) from TEST.dbo.sysobjects where xtype = 'u') Table_Count,  (Select count(*) from TEST.dbo.sysobjects where xtype = 'v') View_Count,  (Select count(*) from TEST.dbo.sysobjects where xtype in ('fn', 'tn')) func_Count,  (Select count(*) from TEST.dbo.sysobjects where xtype = 'p') proc_Count,   (Select count(*) from TEST.dbo.sysobjects where xtype = 'tr') Trig_Count&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-4559390902152456906?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/4559390902152456906/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=4559390902152456906' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/4559390902152456906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/4559390902152456906'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/09/query-to-findout-list-of-objects-count.html' title='Query to findout list of Objects count from all databases in SQL Server :'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-3142987238024587740</id><published>2009-09-10T04:37:00.000-07:00</published><updated>2009-09-10T04:41:51.796-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='synchronization'/><category scheme='http://www.blogger.com/atom/ns#' term='asynchronization mode'/><category scheme='http://www.blogger.com/atom/ns#' term='Statistics'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL SErver statistics'/><category scheme='http://www.blogger.com/atom/ns#' term='performance improve in sql server'/><title type='text'>Statistics in Synchronization and Asynchronization mode to gain the performance.</title><content type='html'>In SQL Server we have Statistics to improve the performance on tables. Following are some of the concepts about Statistics in Synchronization/Asynchronization mode to gain the performance from tables. &lt;br /&gt;&lt;br /&gt;1.  Statistics Asynchronization mode was introduced in SQL Server 2005.  In earlier versions only synchronizations mode was available.    But the default level is synchronization only. &lt;br /&gt;&lt;br /&gt;2.  Synchronization /Asynchronization options are at database level, not individual object level.  There is single option we can enable or disable this for entire database.  We can do this by using alter database statement. &lt;br /&gt; Syntax :  ALTER DATABASE dbName SET AUTO_UPDATE_STATISTICS_ASYNC ON  &lt;br /&gt;   ALTER DATABASE dbName SET AUTO_UPDATE_STATISTICS_ASYNC OFF&lt;br /&gt;&lt;br /&gt;3.  To checkup this option on existing databases. &lt;br /&gt; Syntax : Select name,is_auto_update_stats_async_on from sys.databases&lt;br /&gt;  &lt;br /&gt; 1 = enabled&lt;br /&gt; 0 = disabled&lt;br /&gt;&lt;br /&gt;When the setting is off and a statistics update is initiated due to out-of-date statistics in the execution plan, the query must wait until the statistics update is complete before compiling and then returning the result set.  When the setting is on, the query does not need to wait as the statistics update are handled by a background process. Mainly it is using to improve the performance on the tables. &lt;br /&gt;&lt;br /&gt;So, prior to utilize the statistics aynchronous option at database level, the following process should do at object level. &lt;br /&gt;1.  Create statistics on indexed columns.  It is suggestable that statistics must create on composite indexed columns. &lt;br /&gt;&lt;br /&gt;2.  All the created statistics must be updated regularly.  When we update the statistics on regular basis, we can gain the performance from tables.         &lt;br /&gt;&lt;br /&gt;3.  This options will work on tables which are having statistics and updating regularly will improve the performance compare to synchronization mode.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-3142987238024587740?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/3142987238024587740/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=3142987238024587740' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/3142987238024587740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/3142987238024587740'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/09/statistics-in-synchronization-and.html' title='Statistics in Synchronization and Asynchronization mode to gain the performance.'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-8604383613151438481</id><published>2009-08-06T06:01:00.000-07:00</published><updated>2009-08-07T06:43:50.330-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coalesce'/><category scheme='http://www.blogger.com/atom/ns#' term='non deterministic'/><category scheme='http://www.blogger.com/atom/ns#' term='multi statement function'/><category scheme='http://www.blogger.com/atom/ns#' term='deterministic'/><category scheme='http://www.blogger.com/atom/ns#' term='Sql Server functions'/><category scheme='http://www.blogger.com/atom/ns#' term='isnull'/><category scheme='http://www.blogger.com/atom/ns#' term='Table valued function'/><category scheme='http://www.blogger.com/atom/ns#' term='system functions'/><category scheme='http://www.blogger.com/atom/ns#' term='Scalar Function'/><category scheme='http://www.blogger.com/atom/ns#' term='functions'/><title type='text'>Class 8 - Functions in SQL Server</title><content type='html'>&lt;strong&gt;FUNCTIONS&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;What is function ? &lt;/strong&gt;&lt;br /&gt;A function in SQL Server can be defined primary as 2 types.   User Defined Functions which is creating by user based on the requirement and System Defined Functions which was already created by Microsoft and provided for ready use. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;These can be classified in other ways also : &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The Transact-SQL programming language provides three types of functions: &lt;br /&gt;• Rowset functions &lt;br /&gt;Can be used like table references in an SQL statement. &lt;br /&gt;• Aggregate functions &lt;br /&gt;Operate on a collection of values but return a single, summarizing value. &lt;br /&gt;• Scalar functions &lt;br /&gt;Operate on a single value and then return a single value. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Deterministic and Nondeterministic Functions&lt;/strong&gt;&lt;br /&gt;All functions are deterministic or nondeterministic: &lt;br /&gt;• Deterministic functions always return the same result any time they are called with a specific set of input values.&lt;br /&gt;• Nondeterministic functions may return different results each time they are called with a specific set of input values. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;USER DEFINED FUNCTIONS : &lt;/strong&gt;When we come to User Defined Function again there are 3 types.   &lt;br /&gt;1) Scalar Function&lt;br /&gt;2) Table Valued Function&lt;br /&gt;3) Multi Statement Function&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Scalar Functions &lt;/strong&gt;&lt;br /&gt;Scalare functions always returns single resultant value. &lt;br /&gt;Syntax : &lt;br /&gt;CREATE FUNCTION [ owner. ] fn_name ( [ { @parameter [ AS ] data_type }[ ,...n ] ] ) &lt;br /&gt;RETURNS data_type &lt;br /&gt;[ AS ] &lt;br /&gt;BEGIN &lt;br /&gt;function_body &lt;br /&gt;RETURN scalar_expression &lt;br /&gt;END &lt;br /&gt;Eg : &lt;br /&gt;create function fn_studage (@id int) returns int&lt;br /&gt;as&lt;br /&gt;begin&lt;br /&gt;declare @studage int&lt;br /&gt;select @studage = datediff(year,dob,getdate()) from students where id = @id&lt;br /&gt;return @studage&lt;br /&gt;end &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Inline Table-Valued Functions &lt;/strong&gt;&lt;br /&gt;Inline Table-Valued Functions return a resultset, as opposed to a single scalar value. A table valued function specifies the TABLE keyword in its RETURN clause. Its basic form is : &lt;br /&gt;Syntax : &lt;br /&gt;CREATE FUNCTION [ owner_name. ] fn_name ( [ { @parameter [ AS ] type } [ ,...n ] ]) &lt;br /&gt;RETURNS TABLE &lt;br /&gt;[ AS ] &lt;br /&gt;RETURN [ ( ] select-statement [ ) ] &lt;br /&gt;&lt;br /&gt;An Inline Table-Valued Function created by this command: &lt;br /&gt;CREATE FUNCTION datesales (@deadline as datetime) &lt;br /&gt;RETURNS TABLE &lt;br /&gt;AS &lt;br /&gt;RETURN ( SELECT * &lt;br /&gt;FROM sales &lt;br /&gt;WHERE ord_date &gt; @deadline) &lt;br /&gt;  &lt;br /&gt;and called by this sequence: &lt;br /&gt;USE PUBS &lt;br /&gt;GO &lt;br /&gt;select * from datesales('09/13/1994') &lt;br /&gt;will yield the following table: &lt;br /&gt;stor_id  ord_num  ord_date  qty  payterms  title_id &lt;br /&gt;6380  6871  09/14/94  5  Net 60  BU1032 &lt;br /&gt;7067  D4482  09/14/94  10  Net 60  PS2091 &lt;br /&gt;7131  N914008  09/14/94  20  Net 30  PS2091 &lt;br /&gt;7131  N914014  09/14/94  25  Net 30  MC3021 &lt;br /&gt;8042  423LL922  09/14/94  15  ON invoice  MC3021 &lt;br /&gt;8042  423LL930  09/14/94  10  ON invoice  BU1032 &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Multi-statement Table-Valued Function &lt;/strong&gt;&lt;br /&gt;The final type of UDF is the Multi-statement Table-Valued Function. This UDS also returns a resultset, like the Inline variety UDF, but with a much more powerful result. The Multi-statement UFD can actually create a temporary table, specifying the fields, their type and characteristics. Now the scope of that temporary table is limited to the UDF in which it was defined, so when the UDF ends, the temporary table evaporates too. However, this can be a tremendously powerful technique to obtain or manipulate data. &lt;br /&gt;&lt;br /&gt;The general form for the Multi-statement Table-Valued Function is: &lt;br /&gt;CREATE FUNCTION [ owner_name. ] fn_name ( [ { @parameter [AS] type } [ ,...n ] ] ) &lt;br /&gt;RETURNS @return_variable TABLE &lt; table_type_definition &gt; &lt;br /&gt;[ AS ] &lt;br /&gt;BEGIN &lt;br /&gt;function_body &lt;br /&gt;RETURN &lt;br /&gt;END &lt;br /&gt;The following creates the datesales2 UDF: &lt;br /&gt;CREATE FUNCTION datesales2 (@deadline datetime) RETURNS @table TABLE (stor_id varchar(6) null, ord_num varchar(8) null, ord_date datetime null, qty int, payterms varchar(20), title_id varchar(6)) &lt;br /&gt;AS &lt;br /&gt;BEGIN &lt;br /&gt;INSERT @table &lt;br /&gt;SELECT * &lt;br /&gt;FROM sales &lt;br /&gt;WHERE ord_date &gt; @deadline &lt;br /&gt;RETURN &lt;br /&gt;END &lt;br /&gt;When the function is called by this sequence, &lt;br /&gt;USE PUBS &lt;br /&gt;GO &lt;br /&gt;select * from datesales2('09/13/1994') &lt;br /&gt;The following resultset is displayed and available. (It is the same set displayed in the Inline UDF, but created with the temporary table.) &lt;br /&gt;stor_id  ord_num  ord_date  qty  payterms  title_id &lt;br /&gt;6380  6871  09/14/94  5  Net 60  BU1032 &lt;br /&gt;7067  D4482  09/14/94  10  Net 60  PS2091 &lt;br /&gt;7131  N914008  09/14/94  20  Net 30  PS2091 &lt;br /&gt;7131  N914014  09/14/94  25  Net 30  MC3021 &lt;br /&gt;8042  423LL922  09/14/94  15  ON invoice  MC3021 &lt;br /&gt;8042  423LL930  09/14/94  10  ON invoice  BU1032 &lt;br /&gt;Now these temporary tables by me combined, joined, with virtually any number created within the Multi-Tabled UDF, giving the user a very powerful tool for calculating and presenting data from the server in a way that truly leverages the effectiveness of writing code in the native language of SQL Server. &lt;br /&gt; &lt;br /&gt;&lt;strong&gt;SYSTEM DEFINED FUNCTIONS : &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;FUNCTION EXPLANATION :&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Function category Explanation&lt;br /&gt;Configuration Functions :  Returns information about the current configuration.&lt;br /&gt;Cursor Functions :   Returns information about cursors.&lt;br /&gt;Date and Time Functions :  Performs an operation on a date and time input value and returns either a string, numeric, or date and time value.&lt;br /&gt;Mathematical Functions :  Performs a calculation based on input values provided as parameters to the function, and returns a numeric value.&lt;br /&gt;Metadata Functions :  Returns information about the database and database objects.&lt;br /&gt;Security Functions :  Returns information about users and roles.&lt;br /&gt;String Functions :  Performs an operation on a string (char or varchar) input value and returns a string or numeric value.&lt;br /&gt;System Functions :  Performs operations and returns information about values, objects, and settings in Microsoft® SQL Server™. &lt;br /&gt;System Statistical Functions :  Returns statistical information about the system.&lt;br /&gt;Text and Image Functions :  Performs an operation on a text or image input values or column, and returns information about the value.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Configuration Functions :&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;@@REMSERVER&lt;/strong&gt;Returns the name of the remote Microsoft® SQL Server™ database server as it appears in the login record.&lt;br /&gt;Syntax&lt;br /&gt;@@REMSERVER&lt;br /&gt;Example : &lt;br /&gt;CREATE PROCEDURE check_server&lt;br /&gt;AS&lt;br /&gt;SELECT @@REMSERVER&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;@@LANGUAGE&lt;/strong&gt;&lt;br /&gt;@@SERVERNAME&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;@@SERVICENAME&lt;/strong&gt;&lt;br /&gt;Example&lt;br /&gt;SELECT @@SERVICENAME&lt;br /&gt;Here is the result set:&lt;br /&gt;------------------------------ &lt;br /&gt;MSSQLServer&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;@@SPID&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;@@MAX_CONNECTIONS&lt;/strong&gt;&lt;br /&gt;The actual number of user connections allowed also depends on the version of SQL Server installed and the limitations of your application(s) and hardware.&lt;br /&gt;To reconfigure SQL Server for fewer connections, use sp_configure.&lt;br /&gt;Examples&lt;br /&gt;SELECT @@MAX_CONNECTIONS&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;@@VERSION&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;@@NESTLEVEL&lt;/strong&gt;&lt;br /&gt;Returns the nesting level of the current stored procedure execution (initially 0).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;@@DATEFIRST&lt;/strong&gt;&lt;br /&gt;Returns the current value of the SET DATEFIRST parameter, which indicates the specified first day of each week: 1 for Monday, 2 for Wednesday, and so on through 7 for Sunday.&lt;br /&gt;Syntax&lt;br /&gt;@@DATEFIRST&lt;br /&gt;Examples&lt;br /&gt;SET DATEFIRST 5&lt;br /&gt;SELECT @@DATEFIRST AS '1st Day', DATEPART(dw, GETDATE()) AS 'Today'&lt;br /&gt;Here is the result set. Counting from Friday, today (Saturday) is day 2.&lt;br /&gt;1st Day           Today&lt;br /&gt;----------------  --------------&lt;br /&gt;5                 2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. Cursor Functions&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;@@CURSOR_ROWS&lt;br /&gt;@@CURSOR_STATUS&lt;br /&gt;@@FETCH_STATUS&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3.  Date and Time Functions&lt;/strong&gt;&lt;br /&gt;Datepart Abbreviations&lt;br /&gt;Year yy, yyyy&lt;br /&gt;Quarter qq, q&lt;br /&gt;Month mm, m&lt;br /&gt;dayofyear dy, y&lt;br /&gt;Day dd, d&lt;br /&gt;Week wk, ww&lt;br /&gt;Hour hh&lt;br /&gt;minute mi, n&lt;br /&gt;second ss, s&lt;br /&gt;millisecond ms&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DATEADD&lt;/strong&gt;&lt;br /&gt;Eg : SELECT DATEADD(day, 21, pubdate) AS timeframe fROM titles&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DATEDIFF&lt;/strong&gt;&lt;br /&gt;SELECT DATEDIFF(day, pubdate, getdate()) AS no_of_days&lt;br /&gt;FROM titles&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DATENAME&lt;/strong&gt;SELECT DATENAME(month, getdate()) AS 'Month Name'   = February&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DATEPART&lt;/strong&gt;SELECT DATEPART(month, GETDATE()) AS 'Month Number' = 2&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DAY &lt;/strong&gt;SELECT DAY('03/12/1998') AS 'Day Number'&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;MONTH&lt;/strong&gt;SELECT MONTH('03/12/1998') AS 'MONTH Number'&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;YEAR&lt;/strong&gt;SELECT YEAR('03/12/1998') AS 'YEAR Number'&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;GETDATE()&lt;/strong&gt;SELECT GETDATE()&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4. Mathematical Functions&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;CEILING &lt;/strong&gt;Returns the smallest integer greater than, or equal to, the given numeric expression.&lt;br /&gt;Examples&lt;br /&gt;This example shows positive numeric, negative, and zero values with the CEILING function. &lt;br /&gt;SELECT CEILING($123.45), CEILING($-123.45), CEILING($0.0)&lt;br /&gt;GO&lt;br /&gt;Here is the result set:&lt;br /&gt;--------- --------- ------------------------- &lt;br /&gt;124.00    -123.00    0.00                     &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;FLOOR&lt;/strong&gt;Returns the largest integer less than or equal to the given numeric expression.&lt;br /&gt;Examples&lt;br /&gt;This example shows positive numeric, negative numeric, and currency values with the FLOOR function.&lt;br /&gt;SELECT FLOOR(123.45), FLOOR(-123.45), FLOOR($123.45)&lt;br /&gt;The result is the integer portion of the calculated value in the same data type as numeric_expression. &lt;br /&gt;---------      ---------     -----------&lt;br /&gt;123            -124          123.0000   &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;TRIGNOMETRY : &lt;br /&gt;SIN&lt;br /&gt;COS&lt;br /&gt;TAN&lt;br /&gt;COT&lt;/strong&gt;&lt;br /&gt; &lt;br /&gt;&lt;strong&gt;5. Metadata Functions&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;@@PROCID&lt;/strong&gt;Returns the stored procedure identifier (ID) of the current procedure&lt;br /&gt;SELECT @@PROCID AS 'ProcID'&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;OBJECTPROPERTY&lt;/strong&gt;IF OBJECTPROPERTY ( object_id('authors'),'ISTABLE') = 2&lt;br /&gt;print 'Authors is a table'&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DB_ID&lt;/strong&gt;Returns the database identification (ID) number.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DB_NAME&lt;/strong&gt;Returns the database name.&lt;br /&gt;Ex : &lt;br /&gt;SELECT dbid, DB_NAME(dbid) AS DB_NAME&lt;br /&gt;FROM sysdatabases&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;OBJECT_ID&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;6. Security Functions&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;USER&lt;br /&gt;USER_ID&lt;br /&gt;SUSER_NAME   : EG :select SUSER_NAME(0X01)&lt;br /&gt;SUSER_SID : EG : SELECT SUSER_SID('sa')&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;7. String Functions&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;LTRIM&lt;/strong&gt;Returns a character expression after removing leading blanks.&lt;br /&gt;select ltrim('   venkat')&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;RTRIM&lt;/strong&gt;&lt;br /&gt;Returns a character string after truncating all trailing blanks.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;UPPER&lt;/strong&gt;Returns a character expression with lowercase character data converted to uppercase.&lt;br /&gt;select upper('venkat')&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;LOWER&lt;/strong&gt;Returns a character expression with UPPER character data converted to lowercase.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;LEN&lt;/strong&gt;Returns the number of characters, rather than the number of bytes, of the given string expression, excluding trailing blanks.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;LEFT&lt;/strong&gt;Returns the part of a character string starting at a specified number of characters from the left.&lt;br /&gt;Ex : left(‘venkat’,3)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;RIGHT&lt;/strong&gt;Returns the part of a character string starting at a specified number of characters from the right.&lt;br /&gt;Ex : Right(‘venkat’,3)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;REPLACE&lt;/strong&gt;Replaces all occurrences of the second given string expression in the first string expression with a third expression.&lt;br /&gt;Examples&lt;br /&gt;This example replaces the string cde in abcdefghi with xxx.&lt;br /&gt;SELECT REPLACE('abcdefghicde','cde','xxx')&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;strong&gt;8. System Functions&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;CASE&lt;br /&gt;CAST and CONVERT&lt;/strong&gt;Explicitly converts an expression of one data type to another. CAST and CONVERT provide similar functionality.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;CAST : &lt;/strong&gt;SELECT SUBSTRING(title, 1, 30) AS Title, ytd_sales&lt;br /&gt;FROM titles&lt;br /&gt;WHERE CAST(ytd_sales AS char(20)) LIKE '3%'&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;CONVERT : &lt;/strong&gt;SELECT SUBSTRING(title, 1, 30) AS Title, ytd_sales&lt;br /&gt;FROM titles&lt;br /&gt;WHERE CONVERT(char(20), ytd_sales) LIKE '3%'&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ISNULL&lt;/strong&gt;COALESCE&lt;br /&gt;&lt;strong&gt;CURRENT_USER&lt;br /&gt;HOST_ID&lt;br /&gt;HOST_NAME&lt;/strong&gt;&lt;br /&gt;Eg : CREATE TABLE Orders&lt;br /&gt;   (OrderID     INT        PRIMARY KEY,&lt;br /&gt;   Workstation NCHAR(30)  NOT NULL DEFAULT HOST_NAME())&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;@@IDENTITY&lt;br /&gt;ISNUMERIC &lt;br /&gt;@@row_count&lt;br /&gt;SCOPE_IDENTITY&lt;br /&gt;SERVERPROPERTY &lt;/strong&gt;&lt;br /&gt;eg : SELECT   SERVERPROPERTY('servername'), &lt;br /&gt;SELECT   SERVERPROPERTY('productlevel')&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SYSTEM_USER&lt;br /&gt;&lt;br /&gt;@@TRANCOUNT&lt;br /&gt;&lt;br /&gt;USER_NAME&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;System Statistical Functions&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;@@CONNECTIONS&lt;/strong&gt;Returns the number of connections, or attempted connections, since Microsoft® SQL Server™ was last started.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;@@PACK_RECEIVED&lt;/strong&gt;Returns the number of input packets read from the network by Microsoft® SQL Server™ since last started.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;@@CPU_BUSY&lt;/strong&gt;Returns the time in milliseconds (based on the resolution of the system timer) that the CPU has spent working since Microsoft® SQL Server™ was last started.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;@@PACK_SENT&lt;/strong&gt;Returns the number of output packets written to the network by Microsoft® SQL Server™ since last started.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;@@TOTAL_ERRORS&lt;/strong&gt;Returns the number of disk read/write errors encountered by Microsoft® SQL Server™ since last started.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;9. Text and Image Functions&lt;/strong&gt;PATINDEX&lt;br /&gt;&lt;strong&gt;TEXTPTR&lt;br /&gt;TEXTVALID&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-8604383613151438481?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/8604383613151438481/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=8604383613151438481' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/8604383613151438481'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/8604383613151438481'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/08/class-8-functions-in-sql-server.html' title='Class 8 - Functions in SQL Server'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-85761085652288359</id><published>2009-08-06T05:17:00.000-07:00</published><updated>2009-08-06T05:30:08.527-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql server views'/><category scheme='http://www.blogger.com/atom/ns#' term='sql queries'/><category scheme='http://www.blogger.com/atom/ns#' term='view examples'/><category scheme='http://www.blogger.com/atom/ns#' term='views in sql server'/><category scheme='http://www.blogger.com/atom/ns#' term='Schema Binding View'/><category scheme='http://www.blogger.com/atom/ns#' term='joins'/><category scheme='http://www.blogger.com/atom/ns#' term='permission on view'/><title type='text'>Class 7 - Views in SQL Server</title><content type='html'>&lt;strong&gt;VIEW IN SQL SERVER 2000&lt;/strong&gt;&lt;br /&gt;Views are nothing but saved SQL queries.   Suppose you have written a query by using multiple SQL statements to view the data.  But it may require that watching the data from these tables whenever required.  For this you don’t need to write all these queries every time, instead you can save it as a view.     View doesn’t contain any data, it is just a query. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;CREATE A VIEW&lt;/strong&gt;&lt;br /&gt;This example creates a view with a simple SELECT statement. A simple view is helpful when a combination of columns is queried frequently.&lt;br /&gt;CREATE VIEW titles_view&lt;br /&gt;AS &lt;br /&gt;SELECT title, type, price, pubdate&lt;br /&gt;FROM titles&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;JOINS :  &lt;/strong&gt;&lt;br /&gt;Views can be written by using multiple tables with help of joins.  There are different joins available in SQL Server.  As per the requirement we can choose join to use in the queries for view.&lt;br /&gt;&lt;br /&gt;INNER&lt;br /&gt;LEFT OUTER&lt;br /&gt;RIGHT OUTER&lt;br /&gt;FULL &lt;br /&gt;CROSS   &lt;br /&gt;SELF&lt;br /&gt;CARTISAN &lt;br /&gt;&lt;br /&gt; Eg : Create view ABCD_View&lt;br /&gt;AS&lt;br /&gt;Select a.Col1, a.col2,  b.col1, b.col2 &lt;br /&gt;from Table_A inner join Table_B &lt;br /&gt;on a.Col1 = b.Col2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Some Arguments about Views in Sql Server 2000 : &lt;/strong&gt;• &lt;br /&gt;You can create views only in the current database. However, the tables and views referenced by the new view can exist in other databases or even other servers if the view is defined using distributed queries. &lt;br /&gt;• A view can reference a maximum of 1,024 columns.&lt;br /&gt;• A View can be used as a security mechanism like we can given permissions for the users also.&lt;br /&gt;• View names must follow the rules for identifiers and must be unique for each user. Additionally, the name must not be the same as any tables owned by that user.&lt;br /&gt;• You can build views on other views and on procedures that reference views. Microsoft® SQL Server™ 2000 allows views to be nested up to 32 levels.&lt;br /&gt;• You cannot associate rules or DEFAULT definitions with views.&lt;br /&gt;• You cannot associate AFTER triggers with views, only INSTEAD OF triggers.&lt;br /&gt;• The query defining the view cannot include the ORDER BY, COMPUTE, or COMPUTE BY clauses or the INTO keyword.&lt;br /&gt;• You cannot define full-text index definitions on views.&lt;br /&gt;• You cannot create temporary views, and you cannot create views on temporary tables.&lt;br /&gt;• Views or tables participating in a view created with the SCHEMABINDING clause cannot be dropped, unless the view is dropped or changed so that it no longer has schema binding. In addition, ALTER TABLE statements on tables that participate in views having schema binding will fail if these statements affect the view definition.&lt;br /&gt;• When a view is created, the name of the view is stored in the sysobjects table. &lt;br /&gt;• If the new table (or view) structure changes, then the view must be dropped and recreated.&lt;br /&gt;&lt;br /&gt;View can be createD by using following options for security and performance purposes.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;WITH CHECK OPTION&lt;/strong&gt;Forces all data modification statements executed against the view to adhere to the criteria set within select_statement. When a row is modified through a view, the WITH CHECK OPTION ensures the data remains visible through the view after the modification is committed.&lt;br /&gt;Eg : &lt;br /&gt;CREATE VIEW CAonly&lt;br /&gt;AS &lt;br /&gt;SELECT au_lname, au_fname, city, state&lt;br /&gt;FROM authors&lt;br /&gt;WHERE state = 'CA'&lt;br /&gt;WITH CHECK OPTIONGO&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;WITH ENCRYPTION&lt;/strong&gt;Indicates that SQL Server encrypts the system table columns containing the text of the CREATE VIEW statement. Using WITH ENCRYPTION prevents the view from being published as part of SQL Server replication.&lt;br /&gt;Eg : &lt;br /&gt;CREATE VIEW CAonly&lt;br /&gt;AS &lt;br /&gt;SELECT au_lname, au_fname, city, state&lt;br /&gt;FROM authors&lt;br /&gt;WHERE state = 'CA'&lt;br /&gt;WITH ENCRYPTION&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SCHEMABINDING&lt;/strong&gt;Binds the view to the schema. When SCHEMABINDING is specified, the select_statement must include the two-part names (owner.object) of tables, views, or user-defined functions referenced.&lt;br /&gt;Views or tables participating in a view created with the schema binding clause cannot be dropped unless that view is dropped or changed so that it no longer has schema binding. Otherwise, SQL Server raises an error. In addition, ALTER TABLE statements on tables that participate in views having schema binding will fail if these statements affect the view definition.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Use built-in functions within a view :&lt;/strong&gt; This example shows a view definition that includes a built-in function. When you use functions, the derived column must include a column name in the CREATE VIEW statement.&lt;br /&gt;CREATE VIEW categories (category, average_price)&lt;br /&gt;AS &lt;br /&gt;SELECT type, AVG(price)&lt;br /&gt;FROM titles&lt;br /&gt;GROUP BY type&lt;br /&gt;GO&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-85761085652288359?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/85761085652288359/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=85761085652288359' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/85761085652288359'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/85761085652288359'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/08/class-7-views-in-sql-server.html' title='Class 7 - Views in SQL Server'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-346986265491641128</id><published>2009-07-05T06:10:00.000-07:00</published><updated>2009-07-05T06:15:20.991-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Arithemetic Opreators'/><category scheme='http://www.blogger.com/atom/ns#' term='CAse function'/><category scheme='http://www.blogger.com/atom/ns#' term='variable declaration in Sql server'/><category scheme='http://www.blogger.com/atom/ns#' term='Sql server queries'/><category scheme='http://www.blogger.com/atom/ns#' term='use of Group by'/><category scheme='http://www.blogger.com/atom/ns#' term='Logical Operators'/><category scheme='http://www.blogger.com/atom/ns#' term='Comparision Operators'/><category scheme='http://www.blogger.com/atom/ns#' term='wild cards characters'/><title type='text'>Class 6 - Knowlege before writing Queries</title><content type='html'>&lt;strong&gt;KNOWLEDGE BEFORE WRITING QUERIES&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;WILDCARD EXAMPLES : &lt;/strong&gt;&lt;br /&gt;% - V% - VENKAT, VIJAY, VAMSI&lt;br /&gt;- - V-NKAT - VENKAT&lt;br /&gt;[] - [CS]HERYL - CHERYL, SHERYL&lt;br /&gt;[^] - [^C] - SHERYL&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;FUNCTIONS :&lt;br /&gt;&lt;/strong&gt;Arithmetic operators&lt;br /&gt;Comparison operators&lt;br /&gt;Logical operators&lt;br /&gt;Assignment operators&lt;br /&gt;String concatenation operators&lt;br /&gt;Unary operators&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Arithmetic Operators&lt;br /&gt;&lt;/strong&gt;Operator Description&lt;br /&gt;+ Addition&lt;br /&gt;- Subtraction&lt;br /&gt;* Multiplication&lt;br /&gt;/ Division&lt;br /&gt;% Modulo (returns the integer remainder of a division)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Comparison Operators&lt;/strong&gt;&lt;br /&gt;= Equal to&lt;br /&gt;&gt; Greater than&lt;br /&gt;&lt;&gt;= Greater than or equal to&lt;br /&gt;&lt;= Less than or equal to &lt;&gt; Not equal to&lt;br /&gt;! = Not equal to (SQL-89 standard)&lt;br /&gt;! &lt;&gt; Not greater than (SQL-89 standard)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Logical Operators&lt;br /&gt;&lt;/strong&gt;AND True if both expressions evaluate to true&lt;br /&gt;BETWEEN True if the value is within a specified range&lt;br /&gt;IN True if the result is equal to one in a list&lt;br /&gt;LIKE True if the result matches a pattern&lt;br /&gt;NOT Reverses the value of any other logical operator (such as NOT IN)&lt;br /&gt;OR True if either logical expression evaluates to true&lt;br /&gt;EXISTS True if a subquery (introduced later in this session) returns any Records&lt;br /&gt;&lt;br /&gt;---ALL True if all of a set of compared values evaluates to true&lt;br /&gt;---ANY True if any one of a set of compared values evaluates to true&lt;br /&gt;---SOME True if some of a set of compared values evaluates to true&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The assignment operator&lt;br /&gt;&lt;/strong&gt;Transact-SQL only has one assignment operator, and you’ve probably guessed it&lt;br /&gt;already—it’s the equals sign (=). You use it when assigning values to variables or&lt;br /&gt;specifying column headings.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The string concatenation operator&lt;br /&gt;&lt;/strong&gt;String concatenation is an operation you’ll find yourself performing over and over&lt;br /&gt;again. Luckily, it is very intuitive—T-SQL uses the plus sign (+) to concatenate&lt;br /&gt;strings. You can use it in SELECT statements like the following:&lt;br /&gt;SELECT au_fname + ‘,’ + au_lname FROM authors&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Unary Operators&lt;/strong&gt;&lt;br /&gt;Operator Description&lt;br /&gt;+ The number is positive&lt;br /&gt;- The number is negative&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Working with Aggregate Functions&lt;br /&gt;&lt;/strong&gt;DISTINCT tells the query to ignore duplicate values, and ALL is a default&lt;br /&gt;SUM returns the total of all the values in a numeric field&lt;br /&gt;AVG returns the average of all the values in the numeric column:&lt;br /&gt;COUNT returns the number of records in the group:&lt;br /&gt;COUNT_BIG for big size purpose&lt;br /&gt;MAX returns the highest value in the column:&lt;br /&gt;MIN returns the lowest value in the column:&lt;br /&gt;STDEV finding standar deviation&lt;br /&gt;STDEVP finding standar deviation&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;CLAUSES : &lt;/strong&gt;&lt;br /&gt;AS&lt;br /&gt;SET&lt;br /&gt;ORDER BY&lt;br /&gt;GROUP BY&lt;br /&gt;UNION&lt;br /&gt;UNIONALL&lt;br /&gt;HAVING&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;CASE FUNCTION :&lt;br /&gt;&lt;/strong&gt;SELECT case when id = 4 then 'VENKAT' ELSE 'VIJAY' END NAME FROM SYSOBJECTS&lt;br /&gt;WHILE : WHILE (SELECT AVG(price) FROM titles) &lt; $30BEGIN UPDATE titles SET price = price * 2 SELECT MAX(price) FROM titles IF (SELECT MAX(price) FROM titles) &gt; $50 BREAK ELSE CONTINUEENDPRINT 'Too much for the market to bear'&lt;br /&gt;IFDECLARE @msg varchar(255)IF (SELECT COUNT(price) FROM titles WHERE title_id LIKE 'TC%' AND price BETWEEN 10 AND 20) &gt; 0 BEGIN SET NOCOUNT ON SET @msg = 'There are several books that are a good value between $10 and $20. These books are: ' PRINT @msg SELECT title FROM titles WHERE title_id LIKE 'TC%' AND price BETWEEN 10 AND 20 ENDELSE BEGIN SET NOCOUNT ON SET @msg = 'There are no books between $10 and $20. You might consider the following books that are under $10.' PRINT @msg SELECT title FROM titles WHERE title_id LIKE 'TC%' AND price &lt;&gt;Inbuilt functions :&lt;br /&gt;GOTO&lt;br /&gt;WAITFOR&lt;br /&gt;RTRIM (select Right of given characters)&lt;br /&gt;LTRIM (select Right of given characters)&lt;br /&gt;Getdate()&lt;br /&gt;Cast&lt;br /&gt;Convert&lt;br /&gt;Isnull&lt;br /&gt;Coleasce&lt;br /&gt;Datediff&lt;br /&gt;Identity&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Queries :&lt;br /&gt;&lt;/strong&gt;SELECT employeeID, firstname, lastname FROM names WHERE dept = 'prod' or city = 'Orlando' or division = 'food'&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;UNION ALL&lt;/strong&gt;&lt;br /&gt;SELECT employeeID, firstname, lastname FROM names WHERE dept = 'prod' UNION ALL SELECT employeeID, firstname, lastname FROM names WHERE city = 'Orlando' UNION ALL SELECT employeeID, firstname, lastname FROM names WHERE division = 'food'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;GROUP BY&lt;br /&gt;&lt;/strong&gt;USE Northwind SELECT OrderID FROM [Order Details] WHERE UnitPrice &gt; 10 GROUP BY OrderID&lt;br /&gt;Using a NOT EXISTS&lt;br /&gt;SELECT a.hdr_key FROM hdr_tbl a WHERE NOT EXISTS (SELECT * FROM dtl_tbl b WHERE a.hdr_key = b.hdr_key)&lt;br /&gt;Using a NOT IN&lt;br /&gt;SELECT hdr_key FROM hdr_tbl WHERE hdr_key NOT IN (SELECT hdr_key FROM dtl_tbl)&lt;br /&gt;&lt;br /&gt;QUERY :&lt;br /&gt;SELECT companyid, plantid, formulaid FROM batchrecords WHERE companyid = '0001' and plantid = '0202' and formulaid = '39988773' OR companyid = '0001' and plantid = '0202'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;QUERY WITH VARIABLE :&lt;br /&gt;&lt;/strong&gt;DECLARE @age int SET @age = "30" DECLARE @service_years int SET @service_years = "10" SELECT employee_id FROM employees WHERE age = @age and service_years = @service_years&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;................. I will post more................ wait and see.................&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-346986265491641128?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/346986265491641128/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=346986265491641128' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/346986265491641128'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/346986265491641128'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/07/class-6-knowlege-before-writing-queries.html' title='Class 6 - Knowlege before writing Queries'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-1352377211042938245</id><published>2009-07-05T06:08:00.000-07:00</published><updated>2009-07-05T06:09:44.816-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sql server database design'/><category scheme='http://www.blogger.com/atom/ns#' term='Normalization'/><category scheme='http://www.blogger.com/atom/ns#' term='sql normalization'/><category scheme='http://www.blogger.com/atom/ns#' term='Data Normalization'/><title type='text'>Class 5 - Normalization</title><content type='html'>&lt;strong&gt;Data Models :  We can use following models to design our database.&lt;br /&gt;Entity, Hierarchical, Network&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;DATA MODELING :&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;1 – 1 Relationship      &lt;br /&gt;1 – many&lt;br /&gt;Many – many&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1-1   defining with primary – unique key&lt;br /&gt;Students table (studenntID)   -           Hostel (StudID)&lt;br /&gt;&lt;br /&gt;1- many   definign Primary – Foreign Key&lt;br /&gt;Students table (StudentID) -  Library (StudID)&lt;br /&gt;&lt;br /&gt;Many – Many    defining with 3 table&lt;br /&gt;Students table (studID) -   Subjects (SubjectID)   - Third table (    )&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;NORMALIZATION : &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1NF&lt;br /&gt;&lt;/strong&gt;&lt;a href="http://www.datamodel.org/NormalizationRules.html#one#one"&gt;Eliminate Repeating Groups&lt;/a&gt; - Make a separate table for each set of related attributes, and give each table a primary key.&lt;br /&gt;&lt;strong&gt;2NF&lt;/strong&gt;&lt;br /&gt;&lt;a href="http://www.datamodel.org/NormalizationRules.html#two#two"&gt;Eliminate Redundant Data&lt;/a&gt; - If an attribute depends on only part of a multi-valued key, remove it to a separate table.&lt;br /&gt;&lt;strong&gt;3NF&lt;br /&gt;&lt;/strong&gt;&lt;a href="http://www.datamodel.org/NormalizationRules.html#three#three"&gt;Eliminate Columns Not Dependent On Key&lt;/a&gt; - If attributes do not contribute to a description of the key, remove them to a separate table.&lt;br /&gt;&lt;strong&gt;BCNF&lt;/strong&gt;&lt;br /&gt;&lt;a href="http://www.datamodel.org/NormalizationRules.html#bcnf#bcnf"&gt;Boyce-Codd Normal Form&lt;/a&gt; - If there are non-trivial dependencies between candidate key attributes, separate them out into distinct tables.&lt;br /&gt;&lt;strong&gt;4NF&lt;br /&gt;&lt;/strong&gt;&lt;a href="http://www.datamodel.org/NormalizationRules.html#four#four"&gt;Isolate Independent Multiple Relationships&lt;/a&gt; - No table may contain two or more 1:n or n:m relationships that are not directly related.&lt;br /&gt;&lt;strong&gt;5NF&lt;/strong&gt;&lt;br /&gt;&lt;a href="http://www.datamodel.org/NormalizationRules.html#five#five"&gt;Isolate Semantically Related Multiple Relationships&lt;/a&gt; - There may be practical constrains on information that justify separating logically related many-to-many relationships.&lt;br /&gt;&lt;strong&gt;ONF&lt;br /&gt;&lt;/strong&gt;&lt;a href="http://www.datamodel.org/NormalizationRules.html#onf#onf"&gt;Optimal Normal Form&lt;/a&gt; - a model limited to only simple (elemental) facts, as expressed in Object Role Model notation.&lt;br /&gt;&lt;strong&gt;DKNF&lt;/strong&gt;&lt;br /&gt;&lt;a href="http://www.datamodel.org/NormalizationRules.html#dknf#dknf"&gt;Domain-Key Normal Form&lt;/a&gt; - a model free from all modification anomalies.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-1352377211042938245?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/1352377211042938245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=1352377211042938245' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/1352377211042938245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/1352377211042938245'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/07/class-5-normalization.html' title='Class 5 - Normalization'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-1352214956820703456</id><published>2009-07-05T06:05:00.000-07:00</published><updated>2009-07-05T06:06:43.045-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CONSTRAINTS'/><category scheme='http://www.blogger.com/atom/ns#' term='FOREIGN KEY'/><category scheme='http://www.blogger.com/atom/ns#' term='Default Constraint'/><category scheme='http://www.blogger.com/atom/ns#' term='Default Key'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Contsraints'/><category scheme='http://www.blogger.com/atom/ns#' term='PRIMARY KEY'/><category scheme='http://www.blogger.com/atom/ns#' term='Constraints in SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Check Constraint'/><title type='text'>Class 4 - Constraints</title><content type='html'>&lt;strong&gt;CONSTRAINTS :&lt;br /&gt;&lt;/strong&gt;Primary Key, Foreign Key,Unique ,Default Key,Check,Null&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Primary key&lt;br /&gt;&lt;/strong&gt;NEW TABLE : create table abc (sl int identity(1,1), name varchar(100), constraint PK_sl Primary key(Sl))&lt;br /&gt;&lt;br /&gt;ON EXISTING :  ALTER TABLE ABC ADD CONSTRAINT pk_sL PRIMARY KEY (SL)&lt;br /&gt;&lt;br /&gt;DROPPING : ALTER TABLE ABC DROP CONSTRAINT pk_sL&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Foreign Key&lt;/strong&gt;&lt;br /&gt;NEW TABLE : CREATE TABLE ABCD (SL INT, PLACE VARCHAR(100),DISTRICT VARCHAR(50), CITY VARCHAR(50),  CONSTRAINT FK_sl$abc$sl Foreign Key (Sl) references abc(Sl))&lt;br /&gt;&lt;br /&gt;ON EXISTING :  alter table abcd ADD constraint FK_Sl$abc$sl FOREIGN KEY (SL) REFERENCES ABC(SL)&lt;br /&gt;&lt;br /&gt;DROPPNG :  alter table abcd drop constraint FK_Sl$abc$sl&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;unique&lt;br /&gt;&lt;/strong&gt;NEW TABLE : create table abcde (sl int, rollnum int, classname varchar(10),&lt;br /&gt;Constraint UQ_rollnum Unique(rollnum))&lt;br /&gt;&lt;br /&gt;ON EXISTING :  ALTER TABLE ABCDE ADD CONSTRAINT uq_ROLLNUM UNIQUE CLUSTERED (ROLLNUM)&lt;br /&gt;&lt;br /&gt;DROPPING : ALTER TABLE ABCDE  DROP CONSTRAINT UQ_ROLLNUM&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;check&lt;/strong&gt;&lt;br /&gt;NEW TABLE :  CREATE TABLE ABCDEF (SL INT, AMOUNT INT, CONSTRAINT ch_AMOUNT CHECK(AMOUNT&gt;5))&lt;br /&gt;&lt;br /&gt;ON EXISTING :  ALTER TABLE ABCDEF  ADD CONSTRAINT CH_AMOUNT CHECK(AMOUNT&gt;5)&lt;br /&gt;&lt;br /&gt;DROPPING : ALTER TABLE ABCDEF DROP CONSTRAINT CH_AMOUNT&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;default&lt;br /&gt;&lt;/strong&gt;CREATE TABLE ABCDEFF (SL INT, MARKS INT DEFAULT 35)&lt;br /&gt;&lt;br /&gt;Null / not null&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-1352214956820703456?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/1352214956820703456/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=1352214956820703456' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/1352214956820703456'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/1352214956820703456'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/07/class-4-constraints.html' title='Class 4 - Constraints'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-6330970337981981333</id><published>2009-07-05T05:57:00.000-07:00</published><updated>2009-07-05T06:01:51.284-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DCL'/><category scheme='http://www.blogger.com/atom/ns#' term='Sql server query language'/><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='TCL'/><category scheme='http://www.blogger.com/atom/ns#' term='T-SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='DDL'/><category scheme='http://www.blogger.com/atom/ns#' term='Transact Query Language'/><category scheme='http://www.blogger.com/atom/ns#' term='DML'/><title type='text'>Class 3 - Brief about T-SQL</title><content type='html'>&lt;p&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Brief about TSQL&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;DDL – DATA DEFINITION LANGUAGE&lt;br /&gt;DML – DATA MANIPULATION LANGUAGE&lt;br /&gt;DCL – DATA CONTROL LANGUAGE&lt;br /&gt;TCL – TRANSACT CONTROL LANGUAGE&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;DDL – CREATE, ALTER, DROP, TRUNCATE&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Eg :   CREATE DATABASE SampleDatabase&lt;br /&gt;ON&lt;br /&gt;( NAME = MyDatabase,&lt;br /&gt;FILENAME = ‘C:\program files\MyData\mydatabasefile.mdf’,&lt;br /&gt;SIZE = 10MB,&lt;br /&gt;MAXSIZE = UNLIMITED,&lt;br /&gt;FILEGROWTH = 1MB)&lt;br /&gt;LOG ON&lt;br /&gt;( NAME = MyDatabase_LOG,&lt;br /&gt;FILENAME = ‘C:\program files\MyData\mydatabaselog.ldf’,&lt;br /&gt;SIZE = 5MB,&lt;br /&gt;MAXSIZE = 25MB,&lt;br /&gt;FILEGROWTH = 5MB )&lt;br /&gt;&lt;br /&gt;Eg :&lt;br /&gt;CREATE TABLE MyTable (&lt;br /&gt;Field1 int PRIMARY KEY,&lt;br /&gt;Field2 char(10) NOT NULL),&lt;br /&gt;Field3 datetime&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;Eg :  ALTER DATABASE SampleDatabase&lt;br /&gt;ADD FILE&lt;br /&gt;(&lt;br /&gt;NAME = MyDatabase1,&lt;br /&gt;FILENAME =’c:\program files\MyData\mydatabasefile2.ndf’,&lt;br /&gt;SIZE = 10MB,&lt;br /&gt;MAXSIZE = 50MB,&lt;br /&gt;FILEGROWTH = 1MB&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;Eg :  ALTER TABLE MyTable ADD Field4 VARCHAR(10) NULL&lt;br /&gt;ALTER TABLE MyTable DROP COLUMN Field4&lt;br /&gt;&lt;br /&gt;Eg :  DROP DATABASE SampleDatabase&lt;br /&gt;&lt;br /&gt;Eg :  DROP TABLE MyTable&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DML – SELECT, INSERT, UPDATE, DELETE&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Eg :  _ SELECT @@lNGUAGE displays the name of your SQL Server language.&lt;br /&gt;_ SELECT @@SERVERNAME displays the name of the SQL Server for the current connection.&lt;br /&gt;_ SELECT @@VERSION displays information about Microsoft SQL Server version, build, edition, and so on.&lt;br /&gt;_ SELECT @@TRANCOUNT displays the number of open transactions for the current connection.&lt;br /&gt;_ SELECT @@ERROR displays an error number giving&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SELECT :&lt;/strong&gt;&lt;br /&gt;Select * from [ABCD]&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;INSERT :&lt;br /&gt;&lt;/strong&gt;Insert into ABCD [ColumnA, ColumnB] values 5, 6&lt;br /&gt;&lt;br /&gt;Insert into ABCD values 5,6&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DELETE&lt;/strong&gt;&lt;br /&gt;Delete from ABCD where ColumnA = 5&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;UPDATE&lt;br /&gt;&lt;/strong&gt;Update ABCD set ColumnA = 8 where ColumnA = 5&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;DCL – GRANT, REVOKE&lt;br /&gt;&lt;/strong&gt;CREATE LOGIN [venky] WITH PASSWORD=N'111'&lt;br /&gt;CREATE USER [venky] FOR LOGIN [venky]&lt;br /&gt;EXEC sp_addrolemember N'db_owner', N'venky'&lt;br /&gt;DROP LOGIN [venky]&lt;br /&gt;&lt;br /&gt;Grant select to venkat&lt;br /&gt;Revoke select to venkat&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;TCL – COMMIT, ROLLBACK&lt;br /&gt;&lt;/strong&gt; Commit&lt;br /&gt;Rollback&lt;br /&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-6330970337981981333?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/6330970337981981333/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=6330970337981981333' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/6330970337981981333'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/6330970337981981333'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/07/class-3-brief-about-t-sql.html' title='Class 3 - Brief about T-SQL'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-30112026977137670</id><published>2009-07-05T05:50:00.001-07:00</published><updated>2009-07-05T05:56:42.162-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='int'/><category scheme='http://www.blogger.com/atom/ns#' term='New Data types in Sql Server 2000'/><category scheme='http://www.blogger.com/atom/ns#' term='New Data types in Sql Server 2008'/><title type='text'>Class 2 - Data Types</title><content type='html'>&lt;strong&gt;DATA TYPES :&lt;br /&gt;Exact Numerics &lt;/strong&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms187745.aspx"&gt;bigint&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms187746.aspx"&gt;decimal&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms187745.aspx"&gt;int&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms187746.aspx"&gt;numeric&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms187745.aspx"&gt;smallint&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms179882.aspx"&gt;money&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms187745.aspx"&gt;tinyint&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms179882.aspx"&gt;smallmoney&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms177603.aspx"&gt;bit&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Approximate Numerics&lt;br /&gt;&lt;/strong&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms173773.aspx"&gt;float&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms173773.aspx"&gt;real&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Date and Time&lt;br /&gt;&lt;/strong&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms187819.aspx"&gt;datetime&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms187819.aspx"&gt;smalldatetime&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Character Strings&lt;br /&gt;&lt;/strong&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms176089.aspx"&gt;char&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms187727.aspx"&gt;text&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms176089.aspx"&gt;varchar&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Unicode Character Strings&lt;br /&gt;&lt;/strong&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms186939.aspx"&gt;nchar&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms187993.aspx"&gt;ntext&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms186939.aspx"&gt;nvarchar&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Binary Strings &lt;/strong&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms188362.aspx"&gt;binary&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms174409.aspx"&gt;image&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms188362.aspx"&gt;varbinary&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Other Data Types&lt;br /&gt;&lt;/strong&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms190498.aspx"&gt;cursor&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms182776.aspx"&gt;timestamp&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms173829.aspx"&gt;sql_variant&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms187942.aspx"&gt;uniqueidentifier&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms175010.aspx"&gt;table&lt;/a&gt;&lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/ms187339.aspx"&gt;xml&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;See Also&lt;br /&gt;New Datatypes :&lt;br /&gt;&lt;/strong&gt;Varchar(max)&lt;br /&gt;Nvarchar(max)&lt;br /&gt;Varbinary(max)&lt;br /&gt;xml&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Exact-number data types that use integer data.&lt;br /&gt;Data type Range Storage &lt;/strong&gt;&lt;br /&gt;bigint -2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807) 8 Bytes&lt;br /&gt;int -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647) 4 Bytes&lt;br /&gt;smallint -2^15 (-32,768) to 2^15-1 (32,767) 2 Bytes&lt;br /&gt;tinyint 0 to 255 1 Byte&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;decimal and numeric (Transact-SQL) &lt;/strong&gt;&lt;br /&gt;Numeric data types that have fixed precision and scale.&lt;br /&gt;decimal[ (p[ , s] )] and numeric[ (p[ , s] )]&lt;br /&gt;Fixed precision and scale numbers. When maximum precision is used, valid values are from - 10^38 +1 through 10^38 - 1. The SQL-92 synonyms for decimal are dec and dec(p, s). numeric is functionally equivalent to decimal.&lt;br /&gt;p (precision)&lt;br /&gt;The maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point. The precision must be a value from 1 through the maximum precision of 38. The default precision is 18.&lt;br /&gt;s (scale)&lt;br /&gt;The maximum number of decimal digits that can be stored to the right of the decimal point. Scale must be a value from 0 through p. Scale can be specified only if precision is specified. The default scale is 0; therefore, 0 &lt;= s &lt;= p. Maximum storage sizes vary, based on the precision. Precision Storage bytes 1 – 9 5 10-19 9 20-28 13 29-38 17 money and smallmoney (Transact-SQL) Data types that represent monetary or currency values. Data type Range Storage money -922,337,203,685,477.5808 to 922,337,203,685,477.5807 8 bytes smallmoney - 214,748.3648 to 214,748.3647 4 bytes bit (Transact-SQL) An integer data type that can take a value of 1, 0, or NULL. float and real (Transact-SQL) Approximate-number data types for use with floating point numeric data. Floating point data is approximate; therefore, not all values in the data type range can be represented exactly. Note: The SQL-92 synonym for real is float(24). Data type Range Storage float - 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308 Depends on the value of n real - 3.40E + 38 to -1.18E - 38, 0 and 1.18E - 38 to 3.40E + 38 4 Bytes Date and Time (Transact-SQL) Are data types that are used for representing the date and the time of day. datetime and smalldatetime Represent the date and the time of day. Data type Range Accuracy datetime January 1, 1753, through December 31, 9999 3.33 milliseconds smalldatetime January 1, 1900, through June 6, 2079 1 minute char and varchar (Transact-SQL) Are character data types of either fixed length or variable length. char [ ( n ) ] Fixed-length, non-Unicode character data with a length of n bytes. n must be a value from 1 through 8,000. The storage size is n bytes. The SQL-2003 synonym for char is character. varchar [ ( n max ) ] Variable-length, non-Unicode character data. n can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size is the actual length of data entered + 2 bytes. The data entered can be 0 characters in length. The SQL-2003 synonyms for varchar are char varying or character varying. nchar and nvarchar (Transact-SQL) Character data types that are either fixed-length, nchar, or variable-length, nvarchar, Unicode data and use the UNICODE UCS-2 character set. nchar [ ( n ) ] Fixed-length Unicode character data of n characters. n must be a value from 1 through 4,000. The storage size is two times n bytes. The SQL-2003 synonyms for nchar are national char and national character. nvarchar [ ( n max ) ] Variable-length Unicode character data. n can be a value from 1 through 4,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size, in bytes, is two times the number of characters entered + 2 bytes. The data entered can be 0 characters in length. The SQL-2003 synonyms for nvarchar are national char varying and national character varying. ntext, text, and image (Transact-SQL) Important: ntext, text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use &lt;a href="http://technet.microsoft.com/en-us/library/ms186939.aspx"&gt;nvarchar(max)&lt;/a&gt;, &lt;a href="http://technet.microsoft.com/en-us/library/ms176089.aspx"&gt;varchar(max)&lt;/a&gt;, and &lt;a href="http://technet.microsoft.com/en-us/library/ms188362.aspx"&gt;varbinary(max)&lt;/a&gt; instead. For more information, see &lt;a href="http://technet.microsoft.com/en-us/library/ms178158.aspx"&gt;Using Large-Value Data Types&lt;/a&gt;.&lt;br /&gt;Fixed and variable-length data types for storing large non-Unicode and Unicode character and binary data. Unicode data uses the UNICODE UCS-2 character set.&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;ntext &lt;/strong&gt;&lt;br /&gt;Variable-length Unicode data with a maximum length of 2^30 - 1 (1,073,741,823) characters. Storage size, in bytes, is two times the number of characters entered. The SQL-2003 synonym for ntext is national text.&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;text&lt;br /&gt;&lt;/strong&gt;Variable-length non-Unicode data in the code page of the server and with a maximum length of 2^31-1 (2,147,483,647) characters. When the server code page uses double-byte characters, the storage is still 2,147,483,647 bytes. Depending on the character string, the storage size may be less than 2,147,483,647 bytes.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;image&lt;br /&gt;&lt;/strong&gt;Variable-length binary data from 0 through 2^31-1 (2,147,483,647) bytes.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;binary and varbinary (Transact-SQL)&lt;br /&gt;&lt;/strong&gt;Binary data types of either fixed length or variable length.&lt;br /&gt;binary [ ( n ) ]&lt;br /&gt;Fixed-length binary data with a length of n bytes, where n is a value from 1 through 8,000. The storage size is n bytes.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;varbinary [ ( n max) ]&lt;br /&gt;&lt;/strong&gt;Variable-length binary data. n can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size is the actual length of the data entered + 2 bytes. The data that is entered can be 0 bytes in length. The SQL-2003 synonym for varbinary is binary varying.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;cursor (Transact-SQL)&lt;br /&gt;&lt;/strong&gt;A data type for variables or stored procedure OUTPUT parameters that contain a reference to a cursor. Any variables created with the cursor data type are nullable.&lt;br /&gt;The operations that can reference variables and parameters having a cursor data type are:&lt;br /&gt;The DECLARE @local_variable and SET @local_variable statements.&lt;br /&gt;The OPEN, FETCH, CLOSE, and DEALLOCATE cursor statements.&lt;br /&gt;Stored procedure output parameters.&lt;br /&gt;The CURSOR_STATUS function.&lt;br /&gt;The sp_cursor_list, sp_describe_cursor, sp_describe_cursor_tables, and sp_describe_cursor_columns system stored procedures.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Sql_variant (Transact-SQL)&lt;br /&gt;&lt;/strong&gt;A data type that stores values of various SQL Server 2005-supported data types, except text, ntext, image, timestamp, and sql_variant.&lt;br /&gt;uniqueidentifier (Transact-SQL)&lt;br /&gt;Is a 16-byte GUID.&lt;br /&gt;Remarks&lt;br /&gt;&lt;a name="remarksToggle"&gt;&lt;/a&gt;A column or local variable of uniqueidentifier data type can be initialized to a value in the following ways:&lt;br /&gt;By using the NEWID function.&lt;br /&gt;By converting from a string constant in the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, in which each x is a hexadecimal digit in the range 0-9 or a-f. For example, 6F9619FF-8B86-D011-B42D-00C04FC964FF is a valid uniqueidentifier value.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;xml (Transact-SQL) &lt;/strong&gt;&lt;br /&gt;Updated: 5 December 2005&lt;br /&gt;Is the data type that stores XML data. You can store xml instances in a column, or a variable of xml type. For more information, see &lt;a href="http://technet.microsoft.com/en-us/library/ms189887.aspx"&gt;xml Data Type&lt;/a&gt;.&lt;br /&gt;Select * from systypes&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-30112026977137670?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/30112026977137670/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=30112026977137670' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/30112026977137670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/30112026977137670'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/07/class-2-data-types.html' title='Class 2 - Data Types'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-6310046575165166628</id><published>2009-07-05T05:34:00.000-07:00</published><updated>2009-07-05T05:48:43.718-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql server till 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server history'/><category scheme='http://www.blogger.com/atom/ns#' term='codd rules'/><category scheme='http://www.blogger.com/atom/ns#' term='sql versions'/><category scheme='http://www.blogger.com/atom/ns#' term='sql sever'/><category scheme='http://www.blogger.com/atom/ns#' term='sql version inforamtion'/><title type='text'>Class 1 - Introduction of SQL Server</title><content type='html'>&lt;p&gt;&lt;strong&gt;Overview of Database Concepts&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;A database is a &lt;a title="Structure" href="http://en.wikipedia.org/wiki/Structure"&gt;structured&lt;/a&gt; collection of records of &lt;a title="Data" href="http://en.wikipedia.org/wiki/Data"&gt;data&lt;/a&gt;.  Its group os objects.&lt;br /&gt;The first database management systems were developed in the 1960s. A pioneer in the field was &lt;a title="Charles Bachman" href="http://en.wikipedia.org/wiki/Charles_Bachman"&gt;Charles Bachman&lt;/a&gt;&lt;br /&gt;First it was in the form of Files.  &lt;br /&gt;Later created like Foxpro, Dbase.&lt;br /&gt;The &lt;a title="Relational model" href="http://en.wikipedia.org/wiki/Relational_model"&gt;relational model&lt;/a&gt; was proposed by &lt;a title="Edgar F. Codd" href="http://en.wikipedia.org/wiki/Edgar_F._Codd"&gt;E. F. Codd&lt;/a&gt; in 1970.&lt;br /&gt;The rules&lt;br /&gt;Rule 0: The system must qualify as &lt;a title="Relational model" href="http://en.wikipedia.org/wiki/Relational_model"&gt;relational&lt;/a&gt;, as a &lt;a title="Database" href="http://en.wikipedia.org/wiki/Database"&gt;database&lt;/a&gt;, and as a &lt;a title="Management system" href="http://en.wikipedia.org/wiki/Management_system"&gt;management system&lt;/a&gt;.&lt;br /&gt;For a system to qualify as a relational database management system (&lt;a title="RDBMS" href="http://en.wikipedia.org/wiki/RDBMS"&gt;RDBMS&lt;/a&gt;), that system must use its relational facilities (exclusively) to manage the &lt;a title="Database" href="http://en.wikipedia.org/wiki/Database"&gt;database&lt;/a&gt;.&lt;br /&gt;&lt;strong&gt;Rule 1: The information rule:&lt;br /&gt;&lt;/strong&gt;All information in the database is to be represented in one and only one way, namely by values in column positions within rows of tables.&lt;br /&gt;&lt;strong&gt;Rule 2: The guaranteed access rule:&lt;/strong&gt;&lt;br /&gt;All data must be accessible with no ambiguity. This rule is essentially a restatement of the fundamental requirement for primary keys. It says that every individual scalar value in the database must be logically addressable by specifying the name of the containing &lt;a title="Table" href="http://en.wikipedia.org/wiki/Table"&gt;table&lt;/a&gt;, the name of the containing column and the &lt;a title="Primary key" href="http://en.wikipedia.org/wiki/Primary_key"&gt;primary key&lt;/a&gt; value of the containing &lt;a title="Row" href="http://en.wikipedia.org/wiki/Row"&gt;row&lt;/a&gt;.&lt;br /&gt;&lt;strong&gt;Rule 3: Systematic treatment of null values:&lt;br /&gt;&lt;/strong&gt;The DBMS must allow each field to remain null (or empty). Specifically, it must support a representation of "missing information and inapplicable information" that is &lt;a title="Systematic" href="http://en.wikipedia.org/wiki/Systematic"&gt;systematic&lt;/a&gt;, distinct from all regular values (for example, "distinct from zero or any other number," in the case of numeric values), and independent of &lt;a title="Data type" href="http://en.wikipedia.org/wiki/Data_type"&gt;data type&lt;/a&gt;. It is also implied that such representations must be manipulated by the DBMS in a systematic way.&lt;br /&gt;&lt;strong&gt;Rule 4: Active &lt;/strong&gt;&lt;a title="Online" href="http://en.wikipedia.org/wiki/Online"&gt;&lt;strong&gt;online&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; &lt;/strong&gt;&lt;a title="Database catalog" href="http://en.wikipedia.org/wiki/Database_catalog"&gt;&lt;strong&gt;catalog&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; based on the relational model:&lt;br /&gt;&lt;/strong&gt;The system must support an online, inline, &lt;a title="Relational catalog (page does not exist)" href="http://en.wikipedia.org/w/index.php?title=Relational_catalog&amp;amp;action=edit&amp;amp;redlink=1"&gt;relational catalog&lt;/a&gt; that is accessible to authorized users by means of their regular &lt;a title="Query language" href="http://en.wikipedia.org/wiki/Query_language"&gt;query language&lt;/a&gt;. That is, users must be able to access the database's structure (catalog) using the same query language that they use to access the database's data.&lt;br /&gt;&lt;strong&gt;Rule 5: The comprehensive data sublanguage rule:&lt;/strong&gt;&lt;br /&gt;The system must support at least one relational language that&lt;br /&gt;(a) Has a &lt;a title="Linear syntax (page does not exist)" href="http://en.wikipedia.org/w/index.php?title=Linear_syntax&amp;amp;action=edit&amp;amp;redlink=1"&gt;linear syntax&lt;/a&gt;&lt;br /&gt;(b) Can be used both interactively and within application programs,&lt;br /&gt;(c) Supports data definition operations (including view definitions), data manipulation operations (update as well as retrieval), security and integrity constraints, and &lt;a title="Transaction" href="http://en.wikipedia.org/wiki/Transaction"&gt;transaction&lt;/a&gt; management operations (begin, commit, and rollback).&lt;br /&gt;&lt;strong&gt;Rule 6: The view updating rule:&lt;br /&gt;&lt;/strong&gt;All views that are theoretically updatable must be updatable by the system.&lt;br /&gt;&lt;strong&gt;Rule 7: High-level insert, update, and delete:&lt;/strong&gt;&lt;br /&gt;The system must support set-at-a-time insert, update, and delete operators. This means that data can be retrieved from a relational database in sets constructed of data from multiple rows and/or multiple tables. This rule states that insert, update, and delete operations should be supported for any retrievable set rather than just for a single row in a single table.&lt;br /&gt;&lt;strong&gt;Rule 8: Physical data independence:&lt;br /&gt;&lt;/strong&gt;Changes to the physical level (how the data is stored, whether in arrays or linked lists etc.) must not require a change to an application based on the structure.&lt;br /&gt;&lt;strong&gt;Rule 9: Logical data independence:&lt;/strong&gt;&lt;br /&gt;Changes to the logical level (tables, columns, rows, and so on) must not require a change to an application based on the structure. Logical data independence is more difficult to achieve than physical data independence.&lt;br /&gt;&lt;strong&gt;Rule 10: Integrity independence:&lt;br /&gt;&lt;/strong&gt;&lt;a title="Integrity constraints" href="http://en.wikipedia.org/wiki/Integrity_constraints"&gt;Integrity constraints&lt;/a&gt; must be specified separately from application programs and stored in the &lt;a title="Database catalog" href="http://en.wikipedia.org/wiki/Database_catalog"&gt;catalog&lt;/a&gt;. It must be possible to change such constraints as and when appropriate without unnecessarily affecting existing applications.&lt;br /&gt;&lt;strong&gt;Rule 11: Distribution independence:&lt;/strong&gt;&lt;br /&gt;The distribution of portions of the database to various locations should be invisible to users of the database. Existing applications should continue to operate successfully :&lt;br /&gt;(a) when a distributed version of the DBMS is first introduced; and&lt;br /&gt;(b) when existing distributed data are redistributed around the system.&lt;br /&gt;&lt;strong&gt;Rule 12: The nonsubversion rule:&lt;br /&gt;&lt;/strong&gt;If the system provides a low-level (record-at-a-time) interface, then that interface cannot be used to subvert the system, for example, bypassing a relational security or integrity constraint.&lt;br /&gt;&lt;br /&gt;During the 1980s, research activity focused on &lt;a title="Distributed database" href="http://en.wikipedia.org/wiki/Distributed_database"&gt;distributed database&lt;/a&gt; systems and &lt;a title="Database machine" href="http://en.wikipedia.org/wiki/Database_machine"&gt;database machines&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In the 1990s, attention shifted to &lt;a title="OODB" href="http://en.wikipedia.org/wiki/OODB"&gt;object-oriented databases&lt;/a&gt;. These had some success in fields where it was necessary to handle more complex data than relational systems could easily cope with, such as &lt;a title="Spatial database" href="http://en.wikipedia.org/wiki/Spatial_database"&gt;spatial databases&lt;/a&gt;, engineering data (including software &lt;a title="Software repository" href="http://en.wikipedia.org/wiki/Software_repository"&gt;repositories&lt;/a&gt;), and multimedia data.&lt;br /&gt;&lt;br /&gt;In the 2000s, the fashionable area for innovation is the &lt;a title="XML database" href="http://en.wikipedia.org/wiki/XML_database"&gt;XML database&lt;/a&gt;. As with object databases, this has spawned a new collection of start-up companies, but at the same time the key ideas are being integrated into the established relational products.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Some of DBMS Products : &lt;/strong&gt;&lt;br /&gt;                   &lt;a title="ADABAS" href="http://en.wikipedia.org/wiki/ADABAS"&gt;ADABAS&lt;/a&gt;&lt;br /&gt;                   &lt;a title="BerkeleyDB" href="http://en.wikipedia.org/wiki/BerkeleyDB"&gt;BerkeleyDB&lt;/a&gt;&lt;br /&gt;                   &lt;a title="DBase" href="http://en.wikipedia.org/wiki/DBase"&gt;dBase&lt;/a&gt;&lt;br /&gt;                   &lt;a title="IBM DB2" href="http://en.wikipedia.org/wiki/IBM_DB2"&gt;IBM DB2&lt;/a&gt;&lt;br /&gt;                   &lt;a title="Informix" href="http://en.wikipedia.org/wiki/Informix"&gt;Informix&lt;/a&gt;&lt;br /&gt;                   &lt;a title="Microsoft Access" href="http://en.wikipedia.org/wiki/Microsoft_Access"&gt;Microsoft Access&lt;/a&gt;&lt;br /&gt;                   &lt;a title="Microsoft SQL Server" href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server"&gt;Microsoft SQL Server&lt;/a&gt;&lt;br /&gt;                   &lt;a title="MySQL" href="http://en.wikipedia.org/wiki/MySQL"&gt;MySQL&lt;/a&gt;&lt;br /&gt;                   &lt;a title="Oracle Database" href="http://en.wikipedia.org/wiki/Oracle_Database"&gt;Oracle Database&lt;/a&gt;&lt;br /&gt;                   &lt;a title="Paradox (database)" href="http://en.wikipedia.org/wiki/Paradox_%28database%29"&gt;Paradox (database)&lt;/a&gt;&lt;br /&gt;                   &lt;a title="Sybase" href="http://en.wikipedia.org/wiki/Sybase"&gt;Sybase&lt;/a&gt;&lt;br /&gt;                   &lt;a title="Teradata" href="http://en.wikipedia.org/wiki/Teradata"&gt;Teradata&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;MS SQL SERVER&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Microsoft SQL Server is a &lt;a title="Relational database management system" href="http://en.wikipedia.org/wiki/Relational_database_management_system"&gt;relational database management system&lt;/a&gt; (RDBMS) produced by &lt;a title="Microsoft" href="http://en.wikipedia.org/wiki/Microsoft"&gt;Microsoft&lt;/a&gt;. Its primary &lt;a title="Query language" href="http://en.wikipedia.org/wiki/Query_language"&gt;query language&lt;/a&gt; is &lt;a title="Transact-SQL" href="http://en.wikipedia.org/wiki/Transact-SQL"&gt;Transact-SQL&lt;/a&gt;, an implementation of the ANSI/ISO standard Structured Query Language (&lt;a title="SQL" href="http://en.wikipedia.org/wiki/SQL"&gt;SQL&lt;/a&gt;) used by both Microsoft and &lt;a title="Sybase" href="http://en.wikipedia.org/wiki/Sybase"&gt;Sybase&lt;/a&gt;.&lt;br /&gt;For each databse query languge will use :&lt;br /&gt;Oracle : PL/SQL&lt;br /&gt;Sqlserver : T-Sql&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Architecture&lt;/strong&gt;&lt;br /&gt;The architecture of Microsoft SQL Server is broadly divided into three components: SQLOS which implements the basic services required by SQL Server, including thread scheduling, memory management and I/O management; the Relational Engine, which implements the relational database components including support for databases, tables, queries and stored procedures as well as implementing the type system; and the Protocol Layer which exposes the SQL Server functionality.&lt;a title="" href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#cite_note-storageengine-0#cite_note-storageengine-0"&gt;[1]&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQLOS&lt;br /&gt;&lt;/strong&gt;SQLOS is the base component in the SQL Server architecture. It implements functions normally associated with the Operating System - thread scheduling, memory management, I/O management, buffer pool management, resource management, synchronization primitives and locking, and deadlock detection.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Relational engine&lt;br /&gt;&lt;/strong&gt;The Relational engine implements the &lt;a title="Relational database" href="http://en.wikipedia.org/wiki/Relational_database"&gt;relational data store&lt;/a&gt; using the capabilities provided by SQLOS, which is exposed to this layer via the private SQLOS &lt;a title="API" href="http://en.wikipedia.org/wiki/API"&gt;API&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Protocol layer&lt;/strong&gt;&lt;br /&gt;Protocol layer implements the external interface to SQL Server.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Server 2005&lt;br /&gt;&lt;/strong&gt;SQL Server 2005, released in November 2005, is the successor to SQL Server 2000. It included native support for managing &lt;a title="XML" href="http://en.wikipedia.org/wiki/XML"&gt;XML&lt;/a&gt; data, in addition to &lt;a title="Relational database" href="http://en.wikipedia.org/wiki/Relational_database"&gt;relational data&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a name="SQL_Server_2008"&gt;&lt;/a&gt;&lt;strong&gt;SQL Server 2008&lt;/strong&gt;&lt;br /&gt;The next version of SQL Server is SQL Server 2008,&lt;a title="" href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#cite_note-2k8-28#cite_note-2k8-28"&gt;[29]&lt;/a&gt; code-named "Katmai",&lt;a title="" href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#cite_note-PaulFlessner-29#cite_note-PaulFlessner-29"&gt;[30]&lt;/a&gt; slated to launch on &lt;a title="February 27" href="http://en.wikipedia.org/wiki/February_27"&gt;February 27&lt;/a&gt;, &lt;a title="2008" href="http://en.wikipedia.org/wiki/2008"&gt;2008&lt;/a&gt; and release (RTM) in Q3 2008.&lt;a title="" href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#cite_note-30#cite_note-30"&gt;[31]&lt;/a&gt;&lt;a title="" href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#cite_note-31#cite_note-31"&gt;[32]&lt;/a&gt; The most recent CTP was made available on February 19, 2008. SQL Server 2008 aims&lt;a title="" href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#cite_note-32#cite_note-32"&gt;[33]&lt;/a&gt; to make data management &lt;a title="Self-tuning" href="http://en.wikipedia.org/wiki/Self-tuning"&gt;self-tuning&lt;/a&gt;, self organizing, and self maintaining with the development of SQL Server Always On technologies, to provide near-zero downtime. SQL Server 2008 will also include support for &lt;a title="Structured data" href="http://en.wikipedia.org/wiki/Structured_data"&gt;structured&lt;/a&gt; and semi-structured data, including digital media formats for pictures, audio, video and other multimedia data. In current versions, such multimedia data can be stored as &lt;a title="Binary large object" href="http://en.wikipedia.org/wiki/Binary_large_object"&gt;BLOBs&lt;/a&gt; (binary large objects), but they are generic bitstreams. Intrinsic awareness of multimedia data will allow specialized functions to be performed on them. According to Paul Flessner, senior Vice President, Server Applications, &lt;a title="Microsoft" href="http://en.wikipedia.org/wiki/Microsoft"&gt;Microsoft Corp.&lt;/a&gt;, SQL Server 2008 can be a data storage backend for different varieties of data: XML, email, time/calendar, file, document, spatial, etc as well as perform search, query, analysis, sharing, and synchronization across all data types.&lt;a title="" href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#cite_note-PaulFlessner-29#cite_note-PaulFlessner-29"&gt;[30]&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Tools&lt;br /&gt;&lt;/strong&gt;&lt;a name="SQLCMD"&gt;&lt;/a&gt;&lt;strong&gt;SQLCMD&lt;/strong&gt;&lt;br /&gt;SQLCMD is a command line application that comes with Microsoft SQL Server, and exposes the management features of SQL Server. It allows SQL queries to be written and executed from the command prompt.&lt;br /&gt;&lt;a name="Visual_Studio"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt; Visual Studio&lt;br /&gt;&lt;/strong&gt;&lt;a title="Microsoft Visual Studio" href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio"&gt;Microsoft Visual Studio&lt;/a&gt; includes native support for data programming with Microsoft SQL Server. It can be used to write and debug code to be executed by SQL CLR.&lt;br /&gt;&lt;a name="SQL_Server_Management_Studio"&gt;&lt;/a&gt;&lt;a title="SQL Server Management Studio" href="http://en.wikipedia.org/wiki/SQL_Server_Management_Studio"&gt;SQL Server Management Studio&lt;/a&gt; is a &lt;a title="GUI" href="http://en.wikipedia.org/wiki/GUI"&gt;GUI&lt;/a&gt; tool included with SQL Server 2005 and later for configuring, managing, and administering all components within Microsoft SQL Server.&lt;br /&gt;&lt;a name="Business_Intelligence_Development_Studio"&gt;&lt;/a&gt;Business Intelligence Development Studio&lt;br /&gt;&lt;a title="Business Intelligence Development Studio" href="http://en.wikipedia.org/wiki/Business_Intelligence_Development_Studio"&gt;Business Intelligence Development Studio&lt;/a&gt; (BIDS) is the &lt;a title="Integrated Development Environment" href="http://en.wikipedia.org/wiki/Integrated_Development_Environment"&gt;IDE&lt;/a&gt; from &lt;a title="Microsoft" href="http://en.wikipedia.org/wiki/Microsoft"&gt;Microsoft&lt;/a&gt; used for developing data analysis and &lt;a title="Business Intelligence" href="http://en.wikipedia.org/wiki/Business_Intelligence"&gt;Business Intelligence&lt;/a&gt; solutions utilizing the Microsoft SQL Server &lt;a title="SQL Server Analysis Services" href="http://en.wikipedia.org/wiki/SQL_Server_Analysis_Services"&gt;Analysis Services&lt;/a&gt;, &lt;a title="SQL Server Reporting Services" href="http://en.wikipedia.org/wiki/SQL_Server_Reporting_Services"&gt;Reporting Services&lt;/a&gt; and &lt;a title="SQL Server Integration Services" href="http://en.wikipedia.org/wiki/SQL_Server_Integration_Services"&gt;Integration Services&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; SQL Server Release HistoryVersion     Year        Release Name       Codename&lt;/p&gt;&lt;p&gt;1.0  1989 SQL Server 1.0 -&lt;/p&gt;&lt;p&gt;4.21 1993 SQL Server &lt;/p&gt;&lt;p&gt;6.0 1995 SQL Server &lt;/p&gt;&lt;p&gt;6.5 1996 SQL Server 6.5 Hydra&lt;/p&gt;&lt;p&gt;7.0 1998 SQL Server 7.0 Sphinx- &lt;/p&gt;&lt;p&gt;1999 SQL Server 7.0&lt;br /&gt;OLAP Tools&lt;br /&gt;8.0 2000 SQL Server 2000 Shiloh&lt;/p&gt;&lt;p&gt;8.0 2003 SQL Server 2000 64-bit Edition Liberty&lt;/p&gt;&lt;p&gt;9.0 2005 SQL Server 2005 Yukon&lt;/p&gt;&lt;p&gt;10.0 2008 SQL Server 2008 Katmai&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-6310046575165166628?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/6310046575165166628/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=6310046575165166628' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/6310046575165166628'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/6310046575165166628'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/07/class-1-introduction-of-sql-server.html' title='Class 1 - Introduction of SQL Server'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-1085139314586708959</id><published>2009-07-05T05:26:00.000-07:00</published><updated>2009-07-05T05:33:57.682-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql learn'/><category scheme='http://www.blogger.com/atom/ns#' term='Sql server 2000 learning'/><category scheme='http://www.blogger.com/atom/ns#' term='Sql Server learning'/><title type='text'>SQL SERVER CLASS</title><content type='html'>Hi All,&lt;br /&gt;&lt;br /&gt;I have prepared this class material for the learners who are new to SQL Server. By studying this you can gain knowledge in SQL Server. Actually I have take SQL Server 2000 for preparing this class materials, because I felt like it would be better first learn the older versions then come to newer. Hope it will helpful for everyone who are new to SQL Server.&lt;br /&gt;&lt;br /&gt;Follow my lession in the Blog :&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-1085139314586708959?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/1085139314586708959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=1085139314586708959' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/1085139314586708959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/1085139314586708959'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/07/sql-server-class.html' title='SQL SERVER CLASS'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-2706167851263448742</id><published>2009-07-02T00:31:00.000-07:00</published><updated>2009-07-02T00:36:15.823-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hierarchyid'/><category scheme='http://www.blogger.com/atom/ns#' term='Sql server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='Sql Server 2008 new features'/><category scheme='http://www.blogger.com/atom/ns#' term='New datatypes in Sql server'/><category scheme='http://www.blogger.com/atom/ns#' term='Filestream'/><category scheme='http://www.blogger.com/atom/ns#' term='Filestream in Sql Server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='Hierarchyid in sql server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='New Data types in Sql Server 2008'/><title type='text'>SQL SERVER 2008 NEW DATA TYPES</title><content type='html'>NEW DATA TYPES in SQL Server 2008&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;• Date and Time:&lt;/strong&gt; Four new date and time data types have been added, making working with time much easier than it ever has in the past. They include: DATE, TIME, DATETIME2, and DATETIMEOFFSET.&lt;br /&gt;&lt;strong&gt;• Spatial:&lt;/strong&gt; Two new spatial data types have been added GEOMETRY and GEOGRAPHY which you can use to natively store and manipulate location-based information, such as Global Positioning System (GPS) data.&lt;br /&gt;&lt;strong&gt;• HIERARCHYID:&lt;/strong&gt; The HIERARCHYID data type is used to enable database applications to model hierarchical tree structures, such as the organization chart of a business.&lt;br /&gt;&lt;strong&gt;• FILESTREAM: &lt;/strong&gt;FILESTREAM is not a data type as such, but is a variation of the&lt;br /&gt;VARBINARY(MAX) data type that allows unstructured data to be stored in the file system&lt;br /&gt;instead of inside the SQL Server database. Because this option requires a lot of involvement&lt;br /&gt;from both the DBA administration and development side.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;…. Working on each data type practical, I will post with examples once I finished.&lt;/em&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-2706167851263448742?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/2706167851263448742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=2706167851263448742' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/2706167851263448742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/2706167851263448742'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/07/sql-server-2008-new-data-types.html' title='SQL SERVER 2008 NEW DATA TYPES'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-7026615724306042551</id><published>2009-07-01T07:12:00.000-07:00</published><updated>2009-07-01T07:14:06.327-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL SERVER JOBS'/><category scheme='http://www.blogger.com/atom/ns#' term='JOB DETAILS'/><category scheme='http://www.blogger.com/atom/ns#' term='LIST OF JOBS AND ITS DETAILS'/><category scheme='http://www.blogger.com/atom/ns#' term='SQLSERVER 2005 JOBS AND DETAILS'/><category scheme='http://www.blogger.com/atom/ns#' term='FIND THE SQL SERVER JOB DETAILS'/><category scheme='http://www.blogger.com/atom/ns#' term='JOBS'/><title type='text'>FIND LIST OF JOBS AND ITS DETAILS IN SQL SERVER</title><content type='html'>&lt;p&gt;&lt;br /&gt;-- JOBWISE INFORMATION&lt;br /&gt;select distinct a.name JOBNAME, isnull(DESCRIPTION,'No description available') DESCRIPTION,c.Name Category, isnull (b.database_name,'None') DATABASE_NAME, isnull(f.name, 'None') Job_Owner,&lt;br /&gt;case when d.name is null then 'No Schedule' else d.name end Schedule,&lt;br /&gt;isnull (case d.freq_type&lt;br /&gt;when '1 ' then 'Once'&lt;br /&gt;when '4' then 'Daily'&lt;br /&gt;when '8' then 'Weekly'&lt;br /&gt;when '16' then 'Monthly'&lt;br /&gt;when '32' then 'Monthly relative'&lt;br /&gt;when '64' then 'When SQL Server Agent starts' end, 'None') as Frequency,&lt;br /&gt;isnull (case d.freq_interval&lt;br /&gt;when '1' then 'None'&lt;br /&gt;when '2' then 'Monday'&lt;br /&gt;when '4' then 'Tuesday'&lt;br /&gt;when '8' then 'Wednesday'&lt;br /&gt;when '16' then 'Thursday'&lt;br /&gt;when '32' then 'Friday'&lt;br /&gt;when '64' then 'Saturday'&lt;br /&gt;end,'None') as DAY,&lt;br /&gt;case when active_start_time &lt; 120000 then&lt;br /&gt;isnull(left(convert(varchar,convert(decimal,D.Active_start_time)/10000),4) + ' AM','None') else&lt;br /&gt;isnull(left(convert(varchar,convert(decimal,D.Active_start_time)/10000-12),4) + ' PM','None') END&lt;br /&gt;JOB_start_time,&lt;br /&gt;isnull (convert (varchar,d.Date_Created), 'None') Created_Date from sysjobs a&lt;br /&gt;Inner join sysjobsteps b on&lt;br /&gt;a.job_id = b.job_id&lt;br /&gt;left outer join syscategories c on a.category_id = c.category_id&lt;br /&gt;left outer join master.dbo.syslogins f on a.Owner_sid = f.sid&lt;br /&gt;left outer join sysjobschedules e on e.job_id = a.job_id&lt;br /&gt;left outer join sysschedules d on e.schedule_id = d.schedule_id&lt;br /&gt;order by a.name&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;--JOB STEP WISE INFORMATION&lt;br /&gt;select distinct a.name JOBNAME, isnull(DESCRIPTION,'No description available') DESCRIPTION,c.Name Category, isnull (b.database_name,'None') DATABASE_NAME, isnull(f.name,'None') Job_Owner,&lt;br /&gt;b.step_id STEP, b.step_name STEPNAME,b.subsystem TYPE,b.command,&lt;br /&gt;case when d.name is null then 'No Schedule' else d.name end Schedule,&lt;br /&gt;isnull (case d.freq_type&lt;br /&gt;when '1 ' then 'Once'&lt;br /&gt;when '4' then 'Daily'&lt;br /&gt;when '8' then 'Weekly'&lt;br /&gt;when '16' then 'Monthly'&lt;br /&gt;when '32' then 'Monthly relative'&lt;br /&gt;when '64' then 'When SQL Server Agent starts' end, 'None') as Frequency,&lt;br /&gt;isnull (case d.freq_interval&lt;br /&gt;when '1' then 'None'&lt;br /&gt;when '2' then 'Monday'&lt;br /&gt;when '4' then 'Tuesday'&lt;br /&gt;when '8' then 'Wednesday'&lt;br /&gt;when '16' then 'Thursday'&lt;br /&gt;when '32' then 'Friday'&lt;br /&gt;when '64' then 'Saturday'&lt;br /&gt;end,'None') as DAY,&lt;br /&gt;case when active_start_time &lt; 120000 then&lt;br /&gt;isnull(left(convert(varchar,convert(decimal,D.Active_start_time)/10000),4) + ' AM','None') else&lt;br /&gt;isnull(left(convert(varchar,convert(decimal,D.Active_start_time)/10000-12),4) + ' PM','None') END&lt;br /&gt;JOB_start_time,&lt;br /&gt;isnull (convert (varchar,d.Date_Created), 'None') Created_Date from sysjobs a&lt;br /&gt;left outer join sysjobsteps b on&lt;br /&gt;a.job_id = b.job_id&lt;br /&gt;left outer join syscategories c on a.category_id = c.category_id&lt;br /&gt;left outer join master.dbo.syslogins f on a.Owner_sid = f.sid&lt;br /&gt;left outer join sysjobschedules e on e.job_id = a.job_id&lt;br /&gt;left outer join sysschedules d on e.schedule_id = d.schedule_id&lt;br /&gt;order by a.name&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-7026615724306042551?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/7026615724306042551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=7026615724306042551' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/7026615724306042551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/7026615724306042551'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/07/find-list-of-jobs-and-its-details-in.html' title='FIND LIST OF JOBS AND ITS DETAILS IN SQL SERVER'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-3559145758351858538</id><published>2009-04-28T22:58:00.000-07:00</published><updated>2009-04-28T23:03:12.484-07:00</updated><title type='text'>MOVING TEMPDB</title><content type='html'>&lt;p&gt;MOVING TEMPDB FROM DEFAULT LOCATION TO REQUIRED PATH : &lt;/p&gt;&lt;p&gt;When installa SQL Server all system databases will be intsalled at Progra Files - Microsoft SQL Server - Data folder.     But it is suggestable that move Tempdb databsae into another driver for better performance.     Moving tempdb is not like normal process, Attach/Detach, Backup/Restore, it can be done in following way. &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;How to move tempdb&lt;/p&gt;&lt;p&gt;1) Find the tempdb database file details.&lt;/p&gt;&lt;p&gt;sp_helpdb tempdb&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;2)&lt;br /&gt;ALTER DATABASE tempdb&lt;br /&gt;MODIFY FILE (NAME = tempdev, FILENAME = 'C:\tempdb\tempdb2005.mdf')&lt;br /&gt;GO&lt;br /&gt;ALTER DATABASE tempdb&lt;br /&gt;MODIFY FILE (NAME = templog, FILENAME = 'C:\tempdb\tempdb2005.ldf')&lt;br /&gt;&lt;br /&gt;* C:\tempdb is the new location where we want to move the tempdb files.   &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-3559145758351858538?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/3559145758351858538/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=3559145758351858538' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/3559145758351858538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/3559145758351858538'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/04/moving-tempdb.html' title='MOVING TEMPDB'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-384329413009382468</id><published>2009-03-31T04:29:00.000-07:00</published><updated>2009-03-31T04:37:10.176-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='how to find users wise permissions in sql server'/><category scheme='http://www.blogger.com/atom/ns#' term='roles assigned to users'/><category scheme='http://www.blogger.com/atom/ns#' term='find permissions'/><category scheme='http://www.blogger.com/atom/ns#' term='list of users with their permissions'/><category scheme='http://www.blogger.com/atom/ns#' term='database wise user permissions'/><title type='text'>How to findout list of users and thier permissions in a Database</title><content type='html'>I have struggled almost a week to findout the solution.   From google also I found different suggestions in various sites, but it doesn't met to my requirement.  Finally I got up the solution.&lt;br /&gt;&lt;br /&gt;1) SELECT UID, NAME, HASDBACCESS,B.* FROM SYSUSERS A INNER JOIN SYSPERMISSIONS B ON A.UID = B.ID&lt;br /&gt;&lt;br /&gt;2)  Exec sp_helprotect null,'UserName'&lt;br /&gt;&lt;br /&gt;for assigning role to login we can use sys procedures like&lt;br /&gt;sp_addrolemember, sp_change_users_login ........&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-384329413009382468?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/384329413009382468/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=384329413009382468' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/384329413009382468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/384329413009382468'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/03/how-to-findout-list-of-users-and-thier.html' title='How to findout list of users and thier permissions in a Database'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-7491279059219648683</id><published>2009-03-24T01:40:00.000-07:00</published><updated>2009-03-24T01:45:58.567-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sql Server 2005 new concept'/><category scheme='http://www.blogger.com/atom/ns#' term='Mirroring'/><category scheme='http://www.blogger.com/atom/ns#' term='Mirror'/><category scheme='http://www.blogger.com/atom/ns#' term='Snapshot'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL SErver 2005'/><title type='text'>Mirror the Database using SQL Server 2005</title><content type='html'>Mirroing is the new concept introduced in SQL Server 2005.  It is very useful to maintain a standby database when disaster occurs.  Following is the process how to configure mirroring and test.&lt;br /&gt;&lt;br /&gt;1) Create &amp; backup database test_mirror to disk='d:\test_mirror.bkp' &lt;br /&gt;&lt;br /&gt;2) backup log test_mirror to disk='d:\test_mirror_log.bkp' &lt;br /&gt;&lt;br /&gt;3) move the backup file into destination server&lt;br /&gt;&lt;br /&gt;4) Restore the database with norecovery&lt;br /&gt;&lt;br /&gt;RESTORE DATABASE [test_mirror] FROM  DISK = N'd:\test_mirror.bkp' WITH  FILE = 1,  &lt;br /&gt;&lt;br /&gt;NORECOVERY,  NOUNLOAD,  REPLACE,  STATS = 10&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;5) Restore the log with norecovery&lt;br /&gt;&lt;br /&gt;RESTORE log [test_mirror] FROM  DISK = N'd:\test_mirror_log.bkp' WITH  FILE = 1,  &lt;br /&gt;&lt;br /&gt;NORECOVERY,  NOUNLOAD,  REPLACE,  STATS = 10&lt;br /&gt;&lt;br /&gt;6) Configure the mirroring &lt;br /&gt; &lt;br /&gt; a) Select test_mirror database right click - go to tasks - select mirror&lt;br /&gt; b) Configure the Security using configure Security button.  It will prompt for the &lt;br /&gt;&lt;br /&gt;connections and authentication.  You can configure different servers or 2 instances for &lt;br /&gt;&lt;br /&gt;mirroring.  &lt;br /&gt; c) As first step it will ask for Witness server, this is optional.  Witness server &lt;br /&gt;&lt;br /&gt;can be configured to watch the mirroring from different server. &lt;br /&gt; d) Principal and Mirror servers can be configured using next steps.&lt;br /&gt; e) Select Operating Mode either Asynchronous(high performance) or Synchronous (high protection).  &lt;br /&gt; Asynchronous is nothing but changes will happend at principal server first then  changes pass to mirror server.&lt;br /&gt; Synchronous is like changes will happend same time at both the servers.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;7) create the test table before start the mirroring.&lt;br /&gt;&lt;br /&gt;create table test_1(regno numeric)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;8) Start the mirroring&lt;br /&gt;&lt;br /&gt;9) create the test_2 table after start the mirroring&lt;br /&gt;&lt;br /&gt;create table test_2(regno numeric)&lt;br /&gt;&lt;br /&gt;10) Create the snapshot copy in destination&lt;br /&gt;&lt;br /&gt;CREATE DATABASE test_mirror_copy ON&lt;br /&gt;( &lt;br /&gt; NAME = test_mirror, &lt;br /&gt; FILENAME = 'd:\testmirror.ss' &lt;br /&gt;)&lt;br /&gt;AS SNAPSHOT OF test_mirror&lt;br /&gt;&lt;br /&gt;11) In the snapshot copy I can see both test-1 and test_2 tables.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;12) Insert data into test_1 table&lt;br /&gt;&lt;br /&gt;insert into test_1 values(1)&lt;br /&gt;&lt;br /&gt;13) drop the existing snapshot&lt;br /&gt;&lt;br /&gt;EXEC msdb.dbo.sp_delete_database_backuphistory @database_name = N'test_mirror_copy'&lt;br /&gt;GO&lt;br /&gt;USE [master]&lt;br /&gt;GO&lt;br /&gt;/****** Object:  Database [test_mirror_copy]    Script Date: 03/18/2009 05:38:05 ******/&lt;br /&gt;DROP DATABASE [test_mirror_copy]&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;14) create the new snapshot&lt;br /&gt;&lt;br /&gt;CREATE DATABASE test_mirror_copy ON&lt;br /&gt;( &lt;br /&gt; NAME = test_mirror, &lt;br /&gt; FILENAME = 'd:\testmirror.ss' &lt;br /&gt;)&lt;br /&gt;AS SNAPSHOT OF test_mirror&lt;br /&gt;&lt;br /&gt;15) So we can able to see one row in test_1 table.  It means mirror happening from &lt;br /&gt;&lt;br /&gt;principle to mirror server. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Note : &lt;br /&gt;** If you are using SQL server 2005 with Service Pack 2, then no need to configure any trace flags.  Otherwise Trace Flag 1400 is required to put in start up Parameters. &lt;br /&gt;&lt;br /&gt; - Open Configuration Tools &lt;br /&gt; - Goto Sql Server Configuration Manager&lt;br /&gt; - Goto SQL Server 2005 Services&lt;br /&gt; - then open the sql server service&lt;br /&gt; - goto Advanced&lt;br /&gt; - in startup parameters mention ;-T1400 (T should be capital)&lt;br /&gt; - restart the service to effect the settings&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-7491279059219648683?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/7491279059219648683/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=7491279059219648683' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/7491279059219648683'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/7491279059219648683'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/03/mirror-database-using-sql-server-2005.html' title='Mirror the Database using SQL Server 2005'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-5771029103426199172</id><published>2009-03-17T05:41:00.000-07:00</published><updated>2009-03-17T05:43:37.724-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Output Keyword'/><category scheme='http://www.blogger.com/atom/ns#' term='Apply Operator'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2005 New Features'/><category scheme='http://www.blogger.com/atom/ns#' term='UNPIVOT'/><category scheme='http://www.blogger.com/atom/ns#' term='Index Features'/><category scheme='http://www.blogger.com/atom/ns#' term='Ranking functions'/><category scheme='http://www.blogger.com/atom/ns#' term='Schema Binding View'/><category scheme='http://www.blogger.com/atom/ns#' term='CTE'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL SErver 2005'/><category scheme='http://www.blogger.com/atom/ns#' term='PIVOT'/><category scheme='http://www.blogger.com/atom/ns#' term='sp_executesql'/><title type='text'>SQL Server 2005 New Features for improving Performance</title><content type='html'>TABLE OF CONTENTS&lt;br /&gt;&lt;br /&gt;1. SCHEMA BINDING VIEW (Materialized View) :   &lt;br /&gt;2.   CTE (Common Table Expression) :  &lt;br /&gt;3.  TABLE PARTITION : &lt;br /&gt;4.    OUTPUT Keyword :  &lt;br /&gt;5.  PIVOT / UNPIVOT : &lt;br /&gt;6. APPLY Operator :  &lt;br /&gt;7.   RANKING FUNCTIONS : &lt;br /&gt;8.   SQL SERVER 2005 INDEX FEATURES : &lt;br /&gt;9.  Sp_Executesql&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. SCHEMA BINDING VIEW (Materialized View) :   &lt;br /&gt;&lt;br /&gt;Schema Binding View is nothing but a view but it will bind the schema like a table.  It means the view will hold the data.   So we can able to create indexes on that. When index is created on a table automatically it improves the performance.&lt;br /&gt;&lt;br /&gt;Benefits of Using Indexed Views :&lt;br /&gt;&lt;br /&gt;• It is possible to create a unique clustered index on a view, as well as nonclustered indexes, to improve data access performance on the most complex queries.&lt;br /&gt;• Aggregations can be precomputed and stored in the index to minimize expensive computations during query execution.&lt;br /&gt;• Tables can be prejoined and the resulting data set stored.&lt;br /&gt;• Combinations of joins or aggregations can be stored.&lt;br /&gt;&lt;br /&gt;Considerations :   The following considerations should follow while creating SB views ..&lt;br /&gt;• The view, and all tables referenced in the view, must be in the same database and have the same owner.&lt;br /&gt;• The indexed view does not need to contain all the tables referenced in the query to be used by the optimizer.&lt;br /&gt;• A unique clustered index must be created before any other indexes can be created on the view.&lt;br /&gt;• The view must be created using schema binding and any user-defined functions referenced in the view must also be created with the SCHEMABINDING option.&lt;br /&gt;• Additional disk space will be required to hold the data defined by the indexed view.&lt;br /&gt;• DTA (Database Tuning Advisor) tool can be used to findout indexed view requirement.  It is a new tool available in SQL 2005 only.&lt;br /&gt;&lt;br /&gt;Creating Indexed Views: &lt;br /&gt;&lt;br /&gt;The steps required to create an indexed view are critical to the successful implementation of the view.&lt;br /&gt;1. Verify the setting of ANSI_NULLS is correct for all existing tables that will be referenced in the view.&lt;br /&gt;2. Verify ANSI_NULLS is set correctly for the current session as shown in the table below before creating any new tables.&lt;br /&gt;3. Verify ANSI_NULLS and QUOTED_IDENTIFIER are set correctly for the current session as shown in the table below before creating the view.&lt;br /&gt;4. Verify the view definition is deterministic.&lt;br /&gt;5. Create the view using the WITH SCHEMABINDING option.&lt;br /&gt;6. Verify your session's SET options are set correctly as shown in the table below before creating the unique clustered index on the view.&lt;br /&gt;7. Create the unique clustered index on the view.&lt;br /&gt;8. The OBJECTPROPERTY function can be used to check the value of ANSI_NULLS and QUOTED_IDENTIFIER on an existing table or view.&lt;br /&gt;&lt;br /&gt;Note The indexed view may contain float and real columns; however, such columns cannot be included in the clustered index key if they are non-persisted computed columns.&lt;br /&gt;GROUP BY Restrictions&lt;br /&gt;If GROUP BY is present, the VIEW definition:&lt;br /&gt;• Must contain COUNT_BIG(*).&lt;br /&gt;• Must not contain HAVING, CUBE, ROLLUP, or GROUPING()&lt;br /&gt;These restrictions are applicable only to the indexed view definition. A query can use an indexed view in its execution plan even if it does not satisfy these GROUP BY restrictions&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example : &lt;br /&gt;&lt;br /&gt;CREATE VIEW Vdiscount1 WITH SCHEMABINDING AS &lt;br /&gt;SELECT SUM(UnitPrice*OrderQty) AS SumPrice, &lt;br /&gt;SUM(UnitPrice*OrderQty*(1.00-UnitPriceDiscount)) AS SumDiscountPrice, &lt;br /&gt;COUNT_BIG(*) AS Count, ProductID&lt;br /&gt;FROM Sales.SalesOrderDetail &lt;br /&gt;GROUP BY ProductID&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;CREATE UNIQUE CLUSTERED INDEX VDiscountInd ON Vdiscount1 (ProductID)&lt;br /&gt;&lt;br /&gt;Go&lt;br /&gt;&lt;br /&gt;Can create many non clustered indexes&lt;br /&gt;  &lt;br /&gt;2.  CTE (Common Table Expression) :  &lt;br /&gt;A named temporary result set based on a SELECT query.  By mentioning WITH CTE Name we can write the query and the result set can be used again in the same query.   The main purpose of CTE is we can avoid temporary table. &lt;br /&gt;&lt;br /&gt;Advantages : &lt;br /&gt;• Result set can be used in SELECT, INSERT, UPDATE, or DELETE&lt;br /&gt;• Queries with derived tables become more readable&lt;br /&gt;• Provide traversal of recursive hierarchies&lt;br /&gt;&lt;br /&gt;Example :&lt;br /&gt;&lt;br /&gt;WITH TopSales (SalesPersonID, NumSales) AS&lt;br /&gt;(SELECT SalesPersonID, Count(*) &lt;br /&gt; FROM Sales.SalesOrderHeader GROUP BY SalesPersonId)&lt;br /&gt;&lt;br /&gt;SELECT LoginID, NumSales&lt;br /&gt;FROM HumanResources.Employee e INNER JOIN TopSales &lt;br /&gt;ON TopSales.SalesPersonID = e.EmployeeID&lt;br /&gt;ORDER BY NumSales DESC&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;3. TABLE PARTITION : &lt;br /&gt;Partition Tables &lt;br /&gt;Vertical Table Partitioning : &lt;br /&gt;You can use vertical table partitioning to move infrequently used columns into another table. Moving the infrequently used columns makes the main table narrower and allows more rows to fit on a page.&lt;br /&gt;&lt;br /&gt;Horizontal Table Partitioning : &lt;br /&gt;Horizontal table partitioning is a bit more complicated. But when tables that use horizontal table partitioning are designed correctly, you may obtain huge scalability gains. One of the most common scenarios for horizontal table partitioning is to support history or archive databases where partitions can be easily delineated by date. A simple method that you can use to view the data is to use partitioned views in conjunction with check constraints.&lt;br /&gt;&lt;br /&gt;How to partition a table using Horizontal Partitioning : &lt;br /&gt;Step 1: Create the partition function&lt;br /&gt;CREATE PARTITION FUNCTION emailPF (nvarchar(30))&lt;br /&gt;AS RANGE RIGHT FOR VALUES ('G', 'N')&lt;br /&gt;&lt;br /&gt;Step 2: Create the partition scheme&lt;br /&gt;CREATE PARTITION SCHEME emailPS&lt;br /&gt;AS PARTITION emailPF TO (fg1, fg2, fg3)&lt;br /&gt;&lt;br /&gt;Step 3 : Create the partitioned table&lt;br /&gt;CREATE TABLE Sales.CustomerEmail &lt;br /&gt;(CustID int, email nvarchar(30))&lt;br /&gt;ON EMailPS (email)&lt;br /&gt;&lt;br /&gt;* fg1,fg2,fg3 are filegroups located in different drives.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;4.   OUTPUT Keyword :  &lt;br /&gt;&lt;br /&gt;With help of Output keyword we can avoid multiple declarations and assigning the values.    While performing INSERT/Update we can take the value into variable and it can be used in further queries. &lt;br /&gt;&lt;br /&gt;Example : &lt;br /&gt;&lt;br /&gt;DECLARE @InsertDetails TABLE&lt;br /&gt;(ProductModelID int,&lt;br /&gt; InsertedBy sysname)&lt;br /&gt;&lt;br /&gt;INSERT INTO Production.ProductModel(Name, ModifiedDate)&lt;br /&gt;OUTPUT inserted.ProductModel ID, suser_name() &lt;br /&gt;       INTO @InsertDetails&lt;br /&gt;VALUES&lt;br /&gt;('Racing Bike', getdate())&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT * FROM @InsertDetails&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;5.  PIVOT / UNPIVOT : &lt;br /&gt;&lt;br /&gt;PIVOT – converts values to columns :&lt;br /&gt;&lt;br /&gt;Cust Prod Qty&lt;br /&gt;Mike Bike 3&lt;br /&gt;Mike Chain 2&lt;br /&gt;Mike Bike 5&lt;br /&gt;Lisa Bike 3&lt;br /&gt;Lisa Chain 3&lt;br /&gt;Lisa Chain 4&lt;br /&gt;&lt;br /&gt;SELECT * FROM Sales.Order &lt;br /&gt;PIVOT (SUM(Qty) FOR Prod IN ([Bike],[Chain])) PVT&lt;br /&gt;&lt;br /&gt;Cust Bike Chain&lt;br /&gt;Mike 8 2&lt;br /&gt;Lisa 3 7&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;UNPIVOT – converts columns to values :&lt;br /&gt;&lt;br /&gt;Cust Bike Chain&lt;br /&gt;Mike 8 2&lt;br /&gt;Lisa 3 7&lt;br /&gt;&lt;br /&gt;SELECT Cust, Prod, Qty&lt;br /&gt;FROM Sales.PivotedOrder &lt;br /&gt;UNPIVOT (Qty FOR Prod IN ([Bike],[Chain])) UnPVT&lt;br /&gt;&lt;br /&gt;Cust Prod Qty&lt;br /&gt;Mike Bike 8&lt;br /&gt;Mike Chain 2&lt;br /&gt;Lisa Bike 3&lt;br /&gt;Lisa Chain 7&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;6. APPLY Operator :  &lt;br /&gt;&lt;br /&gt;With help of APPLY operator we can join a function with table and get the result.   In SQL 2000 then function result need to be inserted in a table, then only we can make a join from that.    But using APPLY operator directly joining with table we can get the output. &lt;br /&gt;&lt;br /&gt;Advantages :  Invokes a table-valued function once per row&lt;br /&gt; CROSS APPLY – only rows with matching function results&lt;br /&gt; OUTER APPLY – all rows, regardless of matching function results&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Example : &lt;br /&gt;&lt;br /&gt;CREATE FUNCTION Sales.MostRecentOrders&lt;br /&gt;(@CustID AS int) RETURNS TABLE AS&lt;br /&gt;RETURN&lt;br /&gt;  SELECT TOP(3) SalesOrderID, OrderDate&lt;br /&gt;  FROM Sales.SalesOrderHeader&lt;br /&gt;  WHERE CustomerID = @CustID&lt;br /&gt;  ORDER BY OrderDate DESC&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT Name AS Customer, MR.*&lt;br /&gt;FROM Sales.Store &lt;br /&gt;CROSS APPLY Sales.MostRecentOrders(CustomerID) AS MR&lt;br /&gt; &lt;br /&gt;7.   RANKING FUNCTIONS : &lt;br /&gt;&lt;br /&gt;Function Description&lt;br /&gt;RANK Returns a rank for each row within a specified partition in a result set&lt;br /&gt;DENSE_RANK Returns a consecutive rank for each row within a specified partition in a result set&lt;br /&gt;ROW_NUMBER Returns the ordinal row position of each row in a grouping within a result set&lt;br /&gt;NTILE Divides the rows in each partition of a result set into a specified number of ranks based on a given value. &lt;br /&gt;&lt;br /&gt;With help of ranking functions we can find the data sequentially, like we can avoid top and other keywords.   &lt;br /&gt;8.   SQL SERVER 2005 INDEX FEATURES : &lt;br /&gt;&lt;br /&gt;ONLINE INDEXING : &lt;br /&gt;The online index option allows concurrent modifications (updates, deletes, and inserts) to the underlying table or clustered index data and any associated indexes during index data definition language (DDL) execution. For example, while a clustered index is being rebuilt, you can continue to make updates to the underlying data and perform queries against the data.&lt;br /&gt;Eg : &lt;br /&gt;CREATE CLUSTERED INDEX [PK_Employee_EmployeeID] ON [HumanResources].[Employee] ([EmployeeID] ASC) &lt;br /&gt;WITH (PAD_INDEX  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = ON) ON [PRIMARY]&lt;br /&gt;&lt;br /&gt;ALTER INDEX ALL on HumanResources.Employee REBUILD WITH (ONLINE=ON)&lt;br /&gt;&lt;br /&gt;INCLUDE CLAUSE : &lt;br /&gt;With help of include clause, by including non-key columns we can create non-clustered indexes that cover more queries. The Database Engine does not consider non-key columns when calculating the number of index key columns or index key size. Non-key columns can be included in non-clustered index to avoid exceeding the current index size limitations of a maximum of 16 key columns and a maximum index key size of 900 bytes.  INCLUDE clause to CREATE INDEX for nonkey columns – stored in leaf nodes of the index&lt;br /&gt;&lt;br /&gt;Eg : &lt;br /&gt;&lt;br /&gt;create unique index XUpersonInterest_firstName_inclInterest &lt;br /&gt; on personInterest(firstName) include (interest)&lt;br /&gt;&lt;br /&gt;CREATE NONCLUSTERED INDEX IX_Address_PostalCode&lt;br /&gt;ON Person.Address (PostalCode)&lt;br /&gt;INCLUDE (AddressLine1, AddressLine2, City, StateProvinceID)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ALTER INDEX :&lt;br /&gt;  Disabling&lt;br /&gt;ALTER INDEX IX_Customer_TerritoryID ON Sales.Customer DISABLE&lt;br /&gt;&lt;br /&gt;  Rebuilding&lt;br /&gt;ALTER INDEX PK_Customer_CustomerID ON Sales.Customer REBUILD&lt;br /&gt;&lt;br /&gt;  Reorganizing&lt;br /&gt;ALTER INDEX PK_Customer_CustomerID ON Sales.Customer REORGANIZE&lt;br /&gt;&lt;br /&gt;  Setting of options&lt;br /&gt;ALTER INDEX PK_Customer_CustomerId ON Sales.Customer SET(...)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Index related considerations for improving performance : &lt;br /&gt;• Create indexes based on use :&lt;br /&gt;Do not create indexes if a table is rarely queried, or if a table does not ever seem to be used by the optimizer. Avoid indexes on bit, text, ntext, or image data types because they are rarely used. Avoid very wide indexes and indexes that are not selective.&lt;br /&gt;• Keep clustered index keys as small as possible. &lt;br /&gt;• Consider range data for clustered indexes. &lt;br /&gt;• Create an index on all foreign keys. &lt;br /&gt;• Create highly selective indexes.&lt;br /&gt;Create indexes that exhibit high selectivity. In other words, create indexes that have many distinct values. For example, an index on a region column may have a small number of distinct values. Therefore, there may not be enough distinct values for the optimizer to use. Another example of an item that may not have enough distinct values is a bit column. Since there are only two values, an index cannot be very selective and as a result, the index may not be used.&lt;br /&gt;• Consider a covering index for often-used, high-impact queries. &lt;br /&gt;• Use multiple narrow indexes rather than a few wide indexes. &lt;br /&gt;• Create composite indexes with the most restrictive column first. &lt;br /&gt;• Consider indexes on columns used in WHERE, ORDER BY, GROUP BY, and DISTINCT clauses. &lt;br /&gt;• Remove unused indexes. &lt;br /&gt;• Use the Index Tuning Wizard to tune the indexes.&lt;br /&gt;• Keep statistics up to date  &lt;br /&gt; &lt;br /&gt;9. sp_executesql :&lt;br /&gt;&lt;br /&gt;This system procedure can be used to execute dynamic sql queries instead of using EXEC keyword.    Compare with EXEC keyword it will give the much performance. &lt;br /&gt;&lt;br /&gt;Example : &lt;br /&gt;&lt;br /&gt;DECLARE @SQLString NVARCHAR(500);&lt;br /&gt;&lt;br /&gt;--Set column list. CHAR(13) is a carriage return, line feed&lt;br /&gt;SET @SQLString = N'SELECT FirstName, LastName, JobTitle' + CHAR(13);&lt;br /&gt;&lt;br /&gt;-- Set FROM clause with carriage return, line feed. &lt;br /&gt;SET @SQLString = @SQLString + N'FROM HumanResources.vEmployee' + CHAR(13);&lt;br /&gt;&lt;br /&gt;--Set WHERE clause.&lt;br /&gt;SET @SQLString = @SQLString + N'WHERE LastName LIKE ''D%''';&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;EXEC sp_executesql @SQLString;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;*  The declared data type should be ntext/nchar/nvarchar&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-5771029103426199172?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/5771029103426199172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=5771029103426199172' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5771029103426199172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5771029103426199172'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/03/sql-server-2005-new-features-for.html' title='SQL Server 2005 New Features for improving Performance'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-3761060990961527482</id><published>2009-03-10T07:36:00.000-07:00</published><updated>2009-03-16T08:19:17.440-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DCL'/><category scheme='http://www.blogger.com/atom/ns#' term='Grant'/><category scheme='http://www.blogger.com/atom/ns#' term='Revoke'/><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='TCL'/><category scheme='http://www.blogger.com/atom/ns#' term='DDL'/><category scheme='http://www.blogger.com/atom/ns#' term='Transact SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='DML'/><title type='text'>Brief about TSQL (Transact SQL)</title><content type='html'>Transact SQL is Structure Query Language which is using by SQL Server.  When working with  Oracle; PL-SQL can be used.    A brief about TSQL query language.........&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DDL – DATA DEFINITION LANGUAGE&lt;br /&gt;DML – DATA MANIPULATION LANGUAGE&lt;br /&gt;DCL – DATA CONTROL LANGUAGE&lt;br /&gt;TCL – TRANSACT CONTROL LANGUAGE&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DDL – CREATE, ALTER, DROP, TRUNCATE&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Eg :   CREATE DATABASE SampleDatabase&lt;br /&gt;ON&lt;br /&gt;( NAME = MyDatabase,&lt;br /&gt;FILENAME = ‘C:\program files\MyData\mydatabasefile.mdf’,&lt;br /&gt;SIZE = 10MB,&lt;br /&gt;MAXSIZE = UNLIMITED,&lt;br /&gt;FILEGROWTH = 1MB)&lt;br /&gt;LOG ON&lt;br /&gt;( NAME = MyDatabase_LOG,&lt;br /&gt;FILENAME = ‘C:\program files\MyData\mydatabaselog.ldf’,&lt;br /&gt;SIZE = 5MB,&lt;br /&gt;MAXSIZE = 25MB,&lt;br /&gt;FILEGROWTH = 5MB )&lt;br /&gt;&lt;br /&gt;Eg :&lt;br /&gt;CREATE TABLE MyTable (&lt;br /&gt;Field1 int PRIMARY KEY,&lt;br /&gt;Field2 char(10) NOT NULL),&lt;br /&gt;Field3 datetime&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;Eg :  ALTER DATABASE SampleDatabase&lt;br /&gt;ADD FILE&lt;br /&gt;(&lt;br /&gt;NAME = MyDatabase1,&lt;br /&gt;FILENAME =’c:\program files\MyData\mydatabasefile2.ndf’,&lt;br /&gt;SIZE = 10MB,&lt;br /&gt;MAXSIZE = 50MB,&lt;br /&gt;FILEGROWTH = 1MB&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;Eg :  ALTER TABLE MyTable ADD Field4 VARCHAR(10) NULL&lt;br /&gt;ALTER TABLE MyTable DROP COLUMN Field4&lt;br /&gt;&lt;br /&gt;Eg :  DROP DATABASE SampleDatabase&lt;br /&gt;&lt;br /&gt;Eg :  DROP TABLE MyTable&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DML – SELECT, INSERT, UPDATE, DELETE&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;SELECT :&lt;br /&gt;Select * from [ABCD]&lt;br /&gt;&lt;br /&gt;INSERT :&lt;br /&gt;Insert into ABCD [ColumnA, ColumnB] values 5, 6&lt;br /&gt;&lt;br /&gt;Insert into ABCD values 5,6&lt;br /&gt;&lt;br /&gt;DELETE&lt;br /&gt;Delete from ABCD where ColumnA = 5&lt;br /&gt;&lt;br /&gt;UPDATE&lt;br /&gt;Update ABCD set ColumnA = 8 where ColumnA = 5&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DCL – GRANT, REVOKE&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;CREATE LOGIN [venky] WITH PASSWORD=N'111'&lt;br /&gt;CREATE USER [venky] FOR LOGIN [venky]&lt;br /&gt;EXEC sp_addrolemember N'db_owner', N'venky'&lt;br /&gt;DROP LOGIN [venky]&lt;br /&gt;&lt;br /&gt;Grant select to venkat&lt;br /&gt;Revoke select to venkat&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;TCL – COMMIT, ROLLBACK&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Commit&lt;br /&gt;Rollback&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-3761060990961527482?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/3761060990961527482/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=3761060990961527482' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/3761060990961527482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/3761060990961527482'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/03/brief-about-tsql-transact-sql.html' title='Brief about TSQL (Transact SQL)'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-5665310455296225999</id><published>2009-03-10T07:12:00.000-07:00</published><updated>2009-03-10T07:13:43.998-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CONSTRAINTS'/><category scheme='http://www.blogger.com/atom/ns#' term='FOREIGN KEY'/><category scheme='http://www.blogger.com/atom/ns#' term='UNIQUE'/><category scheme='http://www.blogger.com/atom/ns#' term='NULL'/><category scheme='http://www.blogger.com/atom/ns#' term='NOT NULL'/><category scheme='http://www.blogger.com/atom/ns#' term='DEFAULT'/><category scheme='http://www.blogger.com/atom/ns#' term='PRIMARY KEY'/><title type='text'>CONSTRAINTS IN SQL SERVER</title><content type='html'>CONSTRAINTS :&lt;br /&gt;Primary Key, Foreign Key,Unique ,Default Key,Check,Null&lt;br /&gt;&lt;br /&gt;primary key&lt;br /&gt;NEW TABLE : create table abc (sl int identity(1,1), name varchar(100), constraint PK_sl Primary key(Sl))&lt;br /&gt;&lt;br /&gt;ON EXISTING :  ALTER TABLE ABC ADD CONSTRAINT pk_sL PRIMARY KEY (SL)&lt;br /&gt;&lt;br /&gt;DROPPING : ALTER TABLE ABC DROP CONSTRAINT pk_sL&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Foreign Key&lt;br /&gt;NEW TABLE : CREATE TABLE ABCD (SL INT, PLACE VARCHAR(100),DISTRICT VARCHAR(50), CITY VARCHAR(50),  CONSTRAINT FK_sl$abc$sl Foreign Key (Sl) references abc(Sl))&lt;br /&gt;&lt;br /&gt;ON EXISTING :  alter table abcd ADD constraint FK_Sl$abc$sl FOREIGN KEY (SL) REFERENCES ABC(SL)&lt;br /&gt;&lt;br /&gt;DROPPNG :  alter table abcd drop constraint FK_Sl$abc$sl&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;unique&lt;br /&gt;NEW TABLE : create table abcde (sl int, rollnum int, classname varchar(10),&lt;br /&gt;Constraint UQ_rollnum Unique(rollnum))&lt;br /&gt;&lt;br /&gt;ON EXISTING :  ALTER TABLE ABCDE ADD CONSTRAINT uq_ROLLNUM UNIQUE CLUSTERED (ROLLNUM)&lt;br /&gt;&lt;br /&gt;DROPPING : ALTER TABLE ABCDE  DROP CONSTRAINT UQ_ROLLNUM&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;check&lt;br /&gt;NEW TABLE :  CREATE TABLE ABCDEF (SL INT, AMOUNT INT, CONSTRAINT ch_AMOUNT CHECK(AMOUNT&gt;5))&lt;br /&gt;&lt;br /&gt;ON EXISTING :  ALTER TABLE ABCDEF  ADD CONSTRAINT CH_AMOUNT CHECK(AMOUNT&gt;5)&lt;br /&gt;&lt;br /&gt;DROPPING : ALTER TABLE ABCDEF DROP CONSTRAINT CH_AMOUNT&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;default&lt;br /&gt;CREATE TABLE ABCDEFF (SL INT, MARKS INT DEFAULT 35)&lt;br /&gt;&lt;br /&gt;Null / not null&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-5665310455296225999?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/5665310455296225999/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=5665310455296225999' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5665310455296225999'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/5665310455296225999'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2009/03/constraints-in-sql-server.html' title='CONSTRAINTS IN SQL SERVER'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4994764928445852078.post-891139635187093889</id><published>2008-09-25T02:48:00.000-07:00</published><updated>2009-03-10T07:34:44.514-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='venkat profile'/><title type='text'>ABOUT ME</title><content type='html'>I have started this blog for sharing knowledge in SQL Server in all aspects like Database Development / Administration / Packages.   Thank you for watching my blog and you can keep asking me questions related to SQL Server.&lt;br /&gt;&lt;br /&gt;Thanks &amp;amp; regards&lt;br /&gt;Venkat&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4994764928445852078-891139635187093889?l=sqlvenkat.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlvenkat.blogspot.com/feeds/891139635187093889/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4994764928445852078&amp;postID=891139635187093889' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/891139635187093889'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4994764928445852078/posts/default/891139635187093889'/><link rel='alternate' type='text/html' href='http://sqlvenkat.blogspot.com/2008/09/about-me.html' title='ABOUT ME'/><author><name>venkat</name><uri>http://www.blogger.com/profile/03496083157691943314</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_20DZwQsD82M/SlCn8J6qGWI/AAAAAAAAACw/-XICR2cVUms/S220/Roxio+Wallpaper.bmp'/></author><thr:total>1</thr:total></entry></feed>
