<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-495177919198719500</atom:id><lastBuildDate>Sat, 07 Nov 2009 12:55:00 +0000</lastBuildDate><title>Sql Server Blog</title><description /><link>http://www.sqlservercurry.com/</link><managingEditor>noreply@blogger.com (Suprotim Agarwal)</managingEditor><generator>Blogger</generator><openSearch:totalResults>248</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/sqlservercurry/blog" type="application/rss+xml" /><feedburner:emailServiceId>sqlservercurry/blog</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-7139412243310846806</guid><pubDate>Sat, 07 Nov 2009 12:55:00 +0000</pubDate><atom:updated>2009-11-07T04:55:00.166-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Transact SQL T-SQL</category><title>Insert Rows in between a SQL Server Table with Identity Column</title><description>&lt;p&gt;I have seen a lot of users asking this question – “I have accidentally deleted a row in a Table with Identity Column. How do I insert that row again?”&lt;/p&gt;&lt;p&gt;Let us assume that we have a table with ‘CustId’ as the Identity Column. The row for CustId 18 has got deleted by mistake. Now if you go ahead and insert the row for CustID=18 (specifying the value of the identity column explicitly) as shown below:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;YourTableName(CustId, FirstName, LastName)&lt;br /&gt;&lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;(18, &lt;span style="color:#a31515;"&gt;'Paul'&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;'Adams'&lt;/span&gt;)&lt;br /&gt;GO&lt;/pre&gt;&lt;p&gt;SQL Server throws an error as shown below:&lt;/p&gt;&lt;p&gt;Msg 544, Level 16, State 1, Line 1 &lt;/p&gt;&lt;p&gt;Cannot insert explicit value for identity column in table ‘yourtablename’ when IDENTITY_INSERT is set to OFF.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_0j4bzarlOBg/SvVbhWDAxqI/AAAAAAAAAeM/MNVlUperQHw/s1600-h/image%5B7%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="67" alt="image" src="http://lh5.ggpht.com/_0j4bzarlOBg/SvVbilxJMRI/AAAAAAAAAeQ/8qMw1HPB5T4/image_thumb%5B5%5D.png?imgmax=800" width="584" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;To insert and specify the value in an Identity Column, use the following query:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;SET IDENTITY_INSERT &lt;/span&gt;YourTableName &lt;span style="color:blue;"&gt;ON&lt;br /&gt;&lt;br /&gt;INSERT INTO &lt;/span&gt;YourTableName&lt;span style="color:gray;"&gt;(&lt;/span&gt;CustId&lt;span style="color:gray;"&gt;, &lt;/span&gt;FirstName&lt;span style="color:gray;"&gt;, &lt;/span&gt;LastName&lt;span style="color:gray;"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;18&lt;span style="color:gray;"&gt;, &lt;/span&gt;&lt;span style="color:red;"&gt;'Paul'&lt;/span&gt;&lt;span style="color:gray;"&gt;, &lt;/span&gt;&lt;span style="color:red;"&gt;'Adams'&lt;/span&gt;&lt;span style="color:gray;"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;GO&lt;br /&gt;&lt;br /&gt;SET IDENTITY_INSERT &lt;/span&gt;YourTableName &lt;span style="color:blue;"&gt;OFF&lt;/span&gt;&lt;/pre&gt;You will now be able to insert details for CustId=18 successfully!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-7139412243310846806?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/W_eR7CPj5Kk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/W_eR7CPj5Kk/insert-rows-in-between-sql-server-table.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/11/insert-rows-in-between-sql-server-table.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-6293722700647825184</guid><pubDate>Thu, 05 Nov 2009 12:55:00 +0000</pubDate><atom:updated>2009-11-05T04:55:00.243-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Reporting Services SSRS</category><title>Create a SSRS Report based on a Cube and Deploy it</title><description>&lt;p&gt;In our &lt;a href="http://www.sqlservercurry.com/2009/11/overview-of-sql-server-reporting.html"&gt;previous article&lt;/a&gt;, we took an overview and need of SSRS and various kinds of report delivery. In this article, we will discuss how to create a report and deploy it. We will create a report based on the cube we created in the article &lt;a href="http://www.sqlservercurry.com/2009/10/creating-cube-and-dimension-using-ssas.html"&gt;Creating a Cube and Dimension using SSAS&lt;/a&gt;&lt;/p&gt;&lt;p&gt;1. Add a new Report Server Project Wizard in the same solution and name it ReportDemo. As we have selected the wizard, it will automatically start with report creation.&lt;/p&gt;&lt;p&gt;2. Since we need to create this report on a cube, we need to change the type to Microsoft SQL Server Analysis Services and click on Edit button as shown below:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/SvBWqBuGH9I/AAAAAAAAAN0/UFYt-0mu6eo/s1600-h/image%5B9%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="452" alt="image" src="http://lh4.ggpht.com/_toA00pxrCRM/SvBWriGVS3I/AAAAAAAAAN4/_Bkq1ZGHOdc/image_thumb%5B5%5D.png?imgmax=800" width="484" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;Enter the server name for analysis services and select the previously created DemoCube, click Next.&lt;/p&gt;&lt;p&gt;3. Click on Query Builder which will take us to the query designer. Drag Line Total and Order Quantity from measures on to design. Also drag and drop Product Category and Year – Quarter – Month – Data hierarchies. Select Time dimension in filter area and specify the Year as hierarchy. Select Operator as equal, select years 2003 and 2004 and click the checkbox for the parameter as follows&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_toA00pxrCRM/SvBWt9-4kPI/AAAAAAAAAN8/oYT7LPY-WWk/s1600-h/image%5B8%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="366" alt="image" src="http://lh3.ggpht.com/_toA00pxrCRM/SvBWv6e3gSI/AAAAAAAAAOA/5MtBETBSi54/image_thumb%5B4%5D.png?imgmax=800" width="484" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;Click Ok. The created query will be shown in next screen. Click Next.&lt;/p&gt;&lt;p&gt;4. Select Matrix as the report type and click Next.&lt;/p&gt;&lt;p&gt;5. Do the selection for design the matrix as follows&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_toA00pxrCRM/SvBWxV4cRJI/AAAAAAAAAOE/WA_EQseXwgY/s1600-h/image%5B13%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="456" alt="image" src="http://lh3.ggpht.com/_toA00pxrCRM/SvBWyyA_QoI/AAAAAAAAAOI/C3H0QyoVi_s/image_thumb%5B7%5D.png?imgmax=800" width="484" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;Note the check box for Enable drilldown.&lt;/p&gt;&lt;p&gt;Click Next. Select Corporate as the style and click next.&lt;/p&gt;&lt;p&gt;6. In ‘Choose the deployment location’ screen, enter the Report Server name and the deployment folder. If you have the default instance then you can keep the URL as it is. If you have the named instance enter URL as http://&amp;lt;machine name&amp;gt;/ReportServer_&amp;lt;instance name. Enter the report name as Product Information and click Finish. You can click the check box for Preview Report if required.&lt;/p&gt;&lt;p&gt;7. Select Build and deploy the report project or right click on project name in solution explorer and select deploy. To view the deployed report enter the URL for Report Server as follows:&lt;/p&gt;&lt;p&gt;&lt;a href="http://localhost/ReportServer"&gt;http://localhost/ReportServer&lt;/a&gt; (default instance)&lt;br /&gt;http://&amp;lt;machine name&amp;gt;/ReportServer_&amp;lt;instance name&amp;gt; (named instance)&lt;/p&gt;&lt;p&gt;The URL for Report Manager is&lt;br /&gt;http://localhost/Reports (default instance)&lt;br /&gt;http://&amp;lt;machine name&amp;gt;/Reports_&amp;lt;instance name&amp;gt; (named instance)&lt;/p&gt;&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; if the port number is other than 80 it will be given with the machine name followed by semicolon (:)&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_toA00pxrCRM/SvBW053-ppI/AAAAAAAAAOM/UA17rA-70jc/s1600-h/image%5B17%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="364" alt="image" src="http://lh3.ggpht.com/_toA00pxrCRM/SvBW29z_M4I/AAAAAAAAAOQ/io34A_kndtY/image_thumb%5B9%5D.png?imgmax=800" width="484" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-6293722700647825184?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/Mv4ptUu2YC8" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/Mv4ptUu2YC8/create-ssrs-report-based-on-cube-and.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/11/create-ssrs-report-based-on-cube-and.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-5425692153710964499</guid><pubDate>Tue, 03 Nov 2009 15:56:00 +0000</pubDate><atom:updated>2009-11-03T08:00:01.614-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Reporting Services SSRS</category><title>Overview of SQL Server Reporting Services (SSRS)</title><description>&lt;p align="justify"&gt;In the previous articles, we have discussed the following:&lt;/p&gt;&lt;p align="justify"&gt;&lt;a href="http://www.sqlservercurry.com/2009/10/overview-of-sql-server-integration.html"&gt;Overview of SQL Server Integration Services (SSIS)&lt;/a&gt;&lt;/p&gt;&lt;p align="justify"&gt;&lt;a href="http://www.sqlservercurry.com/2009/10/creating-your-first-ssis-package-with.html"&gt;Creating your first SSIS package with the help of Import Export Wizard&lt;/a&gt;&lt;/p&gt;&lt;p align="justify"&gt;&lt;a href="http://www.sqlservercurry.com/2009/10/overview-of-sql-server-analysis.html"&gt;Overview of SQL Server Analysis Services (SSAS)&lt;/a&gt;&lt;/p&gt;&lt;p align="justify"&gt;&lt;a href="http://www.sqlservercurry.com/2009/10/creating-cube-and-dimension-using-ssas.html"&gt;Creating a Cube and Dimension using SSAS&lt;/a&gt;&lt;/p&gt;&lt;p align="justify"&gt;In this article we will discuss an overview and need for SSRS and various kinds of report delivery. In the next article, we will discuss how to create a report and deploy it.&lt;/p&gt;&lt;p align="justify"&gt;We have discussed how organizations maintain data in various forms, how the data can be fetched and placed at a uniform platform. We also discussed 2 different ways of storing data, for transactional requirement (OLTP – Online Transactional Processing) and for historical usage (DW - Data Warehouse).&lt;/p&gt;&lt;p align="justify"&gt;We need to now present this data in a user friendly format so that business decisions can be taken based on it. The business decisions example can be - what may be the planned percent of business growth? or which business units to focus on for expansion? and so on. For making these decisions it is better to base the decisions on some reports, rather than making abstract decisions without any data support. There can two kinds of reports that are required by business. One of them is trend analysis, in which trends in the business transactions can be displayed. The trend can be in the form of - how different customers have given business and which customers are giving more business. The trend can provide us output in the form of list of customers which have given us more business. The management can concentrate on this list to increase business. The other form of report is a status or snapshot report. There can be snapshot of inventory of material with ABC analysis for items in the organization depending upon the fast, medium and slow moving items. It can be in the form of pricing of items, high priced, moderate priced and low priced. The snapshot can comprise of current status of organization regarding the employees working, getting retired towards year end.&lt;/p&gt;&lt;p align="justify"&gt;In order to create these kinds of reports we require processed and organized data. It can come in the form of transactional data or OLAP (Online analytical processing) data. We have discussed how to &lt;a href="http://www.sqlservercurry.com/2009/10/creating-your-first-ssis-package-with.html"&gt;fetch data on a common platform with the help of SQL Server Integration Services&lt;/a&gt; and &lt;a href="http://www.sqlservercurry.com/2009/10/creating-cube-and-dimension-using-ssas.html"&gt;how the data can be aggregated and made available for querying with the help of SQL Server Analysis Services&lt;/a&gt;.&lt;/p&gt;&lt;p align="justify"&gt;Let us see how the reports can be created with the help of SQL Server Reporting Services (SSRS). This tool is one of the major tools for report creation provided by Microsoft. The other tools are Report Builder 1.0 and Report Builder 2.0. Check &lt;a href="http://www.sqlservercurry.com/2009/10/some-similarities-and-dissimilarities.html"&gt;this article&lt;/a&gt; to find out some differences between the three.&lt;/p&gt;&lt;p align="justify"&gt;With SSRS, the data related to reports is stored in 2 databases namely ReportServerDB and ReportServerTempDB. Item like reports, linked reports, shared data sources, report models subscriptions and schedules, report snapshots which are managed by report server are stored in Report Server database. Session and execution data are stored with temporary database. &lt;/p&gt;&lt;p align="justify"&gt;Report Server architecture provides 2 main features namely Report Manager and Report Server Web Service. Report Manager provides web interface to the report server web service. Report Manager runs in the browser on client side. Nothing is stored on client side like files or settings. Any setting to a particular user is stored in database and retrieved when required. You can associate URL for Report Manager. Report Server Web service is the main feature which provided all reports and report models. The user authentication and authorization is handled by web service for any report processing. &lt;/p&gt;&lt;p align="justify"&gt;There can be different delivery kinds of reports, pull delivery, push delivery and local processing. In pull delivery the URL for the report is given to view the report. In push delivery a subscription for the reports is created and the report gets automatically delivered to the concerned person or in a shared folder when the criterion for subscription matches. In local processing the report can be viewed on client with the help of report viewer with windows form or web form.&lt;/p&gt;&lt;p align="justify"&gt;In this article, we took a quick overview of the SSRS and the various kinds of report delivery. In the next article, we will create a report based on the cube created in the last article &lt;a href="http://www.sqlservercurry.com/2009/10/creating-cube-and-dimension-using-ssas.html"&gt;Creating a Cube and Dimension using SSAS&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-5425692153710964499?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/iw3-VLfLPEM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/iw3-VLfLPEM/overview-of-sql-server-reporting.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/11/overview-of-sql-server-reporting.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-2452078753249650658</guid><pubDate>Sun, 01 Nov 2009 17:32:00 +0000</pubDate><atom:updated>2009-11-01T09:36:07.289-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Transact SQL T-SQL</category><title>Identify Valid Numeric Expressions in SQL Server</title><description>&lt;p&gt;Sometimes the solution to a weird ‘looking’ problem lies in simple SQL Server functions!&lt;/p&gt;&lt;p&gt;I was recently analyzing data of a SQL Server table with a varchar column that contained both numbers and alphabets. The client however now wanted to filter out the rows that contained only numbers in them. Here’s how the requirement was solved&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;DECLARE &lt;/span&gt;@TT &lt;span style="color:blue;"&gt;table&lt;br /&gt;&lt;/span&gt;(&lt;br /&gt;ProductID &lt;span style="color:blue;"&gt;int&lt;/span&gt;,&lt;br /&gt;CodeIdentification &lt;span style="color:blue;"&gt;varchar&lt;br /&gt;&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;-- Create Sample Data&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;@TT &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;( 101, &lt;span style="color:#a31515;"&gt;'A2'&lt;/span&gt;)&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;@TT &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;( 203, &lt;span style="color:#a31515;"&gt;'2'&lt;/span&gt;);&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;@TT &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;( 305, &lt;span style="color:#a31515;"&gt;'2'&lt;/span&gt;);&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;@TT &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;( 403, &lt;span style="color:#a31515;"&gt;'3'&lt;/span&gt;);&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;@TT &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;( 553, &lt;span style="color:#a31515;"&gt;'B3'&lt;/span&gt;);&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;@TT &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;( 634, &lt;span style="color:#a31515;"&gt;'3'&lt;/span&gt;);&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;@TT &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;( 744, &lt;span style="color:#a31515;"&gt;'3'&lt;/span&gt;);&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;@TT &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;( 838, &lt;span style="color:#a31515;"&gt;'4'&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;* &lt;span style="color:blue;"&gt;FROM &lt;/span&gt;@TT &lt;span style="color:blue;"&gt;WHERE IsNumeric&lt;/span&gt;(CodeIdentification) = 1&lt;/pre&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;The &lt;a href="http://msdn.microsoft.com/en-us/library/ms186272.aspx" target="_blank"&gt;IsNumeric&lt;/a&gt; function determines if the expression passed to it is valid, by returning 1; else it returns 0&lt;/p&gt;&lt;p&gt;The output on running the above query is as shown below:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_0j4bzarlOBg/Su3GM0UlzMI/AAAAAAAAAdk/i1h1J62OntE/s1600-h/image%5B2%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="149" alt="image" src="http://lh3.ggpht.com/_0j4bzarlOBg/Su3GOcOIOmI/AAAAAAAAAdo/aCO-tT3CguA/image_thumb.png?imgmax=800" width="203" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-2452078753249650658?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/8U1ORADFHZQ" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/8U1ORADFHZQ/identify-valid-numeric-expressions-in.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/11/identify-valid-numeric-expressions-in.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-99377508274608968</guid><pubDate>Fri, 30 Oct 2009 23:06:00 +0000</pubDate><atom:updated>2009-10-30T21:08:40.457-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Analysis Services SSAS</category><title>Creating a Cube and Dimension using SSAS</title><description>&lt;p&gt;In my previous article, we took an &lt;a href="http://www.sqlservercurry.com/2009/10/overview-of-sql-server-analysis.html"&gt;&lt;strong&gt;Overview of SSAS and its various components&lt;/strong&gt;&lt;/a&gt;. In this article, we will create a cube by using Business Intelligence Development Studio (BIDS).&lt;/p&gt;&lt;p&gt;We will continue with the &lt;a href="http://www.sqlservercurry.com/2009/10/creating-your-first-ssis-package-with.html"&gt;&lt;strong&gt;example we discussed&lt;/strong&gt;&lt;/a&gt; with SQL Server Integration Services where we created a database with the help of Import Export wizard&lt;/p&gt;&lt;p&gt;1. In the existing solution named DemoBeginning, add an Analysis Services Project and name it DemoCube.&lt;/p&gt;&lt;p&gt;2. In the Solution Explorer, right click on Data Sources and click on New Data Source. This action launches the Data Source Wizard. Connect to the database created &lt;a href="http://www.sqlservercurry.com/2009/10/creating-your-first-ssis-package-with.html"&gt;earlier&lt;/a&gt; named DemoDB. Select the impersonation information as ‘Use the Service Account’. Keep the default name and click Finish.&lt;/p&gt;&lt;p&gt;3. In the Solution Explorer, right click on Data Source View (DSV) and select New Data Source. Select 3 tables from the Production schema and SalesOrderDetail from Sales schema. We will fetch the last table in a short while. Keep the default name for DSV and click Finish. In this DSV you will see that no tables are related to each other.&lt;/p&gt;&lt;p&gt;Note we did not fetch any keys or relationships from the original database to the newly created database.&lt;/p&gt;&lt;p&gt;4. We will create the logical relationships in the DSV. Right click on each table from the Production schema and make ProductID, ProductSubCategoryID and ProductCategoryID as logical primary keys. To create relationships, drag ProductSubCategoryID from Product table and drop on ProductSubCategory. Verify the relationship is as follows:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_toA00pxrCRM/Suu3jEjF6uI/AAAAAAAAAMc/XWfhGmPPFk4/s1600-h/clip_image002%5B4%5D.jpg"&gt;&lt;img title="clip_image002" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="270" alt="clip_image002" src="http://lh6.ggpht.com/_toA00pxrCRM/Suu3j4kjh3I/AAAAAAAAAMg/MDKFWX5M7Pw/clip_image002_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;Similarly drag ProductCategoryID from ProductSubCategory table and drop it on ProductCategory table. Drag ProductID from SalesOrderDetail and create the relationship by dropping it on ProductID of Product table. We have now created primary keys in dimension tables and subsequent foreign keys in fact tables.&lt;/p&gt;&lt;p&gt;5. Dimensions for cube can be created in 2 ways. One is by right clicking on Dimension in Solution Explorer and the other when we create a cube, the dimensions automatically get created. Right click on the cube in Solution Explorer and start the cube wizard. Select existing tables from the ‘Select Creation Method’ screen. Click Next.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_toA00pxrCRM/Suu3krMH2oI/AAAAAAAAAMk/B0Yum3Lk7mo/s1600-h/clip_image004%5B4%5D.jpg"&gt;&lt;img title="clip_image004" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="400" alt="clip_image004" src="http://lh3.ggpht.com/_toA00pxrCRM/Suu3lkMZ3XI/AAAAAAAAAMo/pczrI0clU7I/clip_image004_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;6. Click on the Suggest button from the next screen and you will see that the table named SalesOrderDetails is picked as the table with measures. This suggestion is based on the relationship we created in the previous step. Click Next.&lt;/p&gt;&lt;p&gt;7. Select Order Qty, Unit Price and Line Total as the only measures and click Next&lt;/p&gt;&lt;p&gt;8. Click Next, enter the name DemoCube and click Finish. The result will be as shown below.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_toA00pxrCRM/Suu3mQunRfI/AAAAAAAAAMs/ByMsFnZit7w/s1600-h/clip_image006%5B4%5D.jpg"&gt;&lt;img title="clip_image006" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="164" alt="clip_image006" src="http://lh4.ggpht.com/_toA00pxrCRM/Suu3na0nFiI/AAAAAAAAAMw/ZpHLsFm-wQQ/clip_image006_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;You can now see the relationship which we created.&lt;/p&gt;&lt;p&gt;9. Right click on the project and select properties. Click Deployment tab and enter your server name. For default instance you can keep it as  localhost; for named instance it will be &amp;lt;machine name&amp;gt;\&amp;lt;instance name&amp;gt;. Select Build, Deploy DemoCube.&lt;/p&gt;&lt;p&gt;10. After successful deployment ,select the Browser tab for cube. If you drag and drop Unit Price, Line Total to the data area and Product category Id to the row area, you will see the result as follows.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_toA00pxrCRM/Suu3oCRBVZI/AAAAAAAAAM0/epVG5m9pDbo/s1600-h/clip_image008%5B4%5D.jpg"&gt;&lt;img title="clip_image008" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="200" alt="clip_image008" src="http://lh5.ggpht.com/_toA00pxrCRM/Suu3pNx9E0I/AAAAAAAAAM4/625YRe6ccpY/clip_image008_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;This result shows category id which is not very user friendly, it will be better if we see the name instead.&lt;/p&gt;&lt;p&gt;11. Go to solution explorer and double click on Product dimension.&lt;/p&gt;&lt;p&gt;Go to properties for Product Id and change NameColumn property as shown below&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/Suu3qGcb7PI/AAAAAAAAAM8/mrQEKlG_3lA/s1600-h/clip_image010%5B4%5D.jpg"&gt;&lt;img title="clip_image010" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="336" alt="clip_image010" src="http://lh6.ggpht.com/_toA00pxrCRM/Suu3rF-qWsI/AAAAAAAAANA/hQmvO9Vb1xM/clip_image010_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Similarly change the NameColumn for Product Subcategory ID and Product Category Id. &lt;/p&gt;&lt;p&gt;Create a hierarchy named Product Category as follows:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_toA00pxrCRM/Suu3r6q1RkI/AAAAAAAAANE/vL6Mf_PYm68/s1600-h/clip_image012%5B3%5D.jpg"&gt;&lt;img title="clip_image012" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="148" alt="clip_image012" src="http://lh4.ggpht.com/_toA00pxrCRM/Suu3spAi6jI/AAAAAAAAANI/GmTFWqFTRDY/clip_image012_thumb.jpg?imgmax=800" width="196" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;We need to process the dimension with the changed properties. Now the previous result is as shown below&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_toA00pxrCRM/Suu3tS45EzI/AAAAAAAAANM/ejB5_uc6L0Q/s1600-h/clip_image014%5B4%5D.jpg"&gt;&lt;img title="clip_image014" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="218" alt="clip_image014" src="http://lh4.ggpht.com/_toA00pxrCRM/Suu3uPHgzwI/AAAAAAAAANQ/0iLInyYm6ts/clip_image014_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;12. We can format the Line Total by selecting Cube structure tab, select Line Total, select properties and specify FormatString as currency with the following result:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/Suu3vMXPzVI/AAAAAAAAANU/tIgWo1W5iL0/s1600-h/clip_image016%5B4%5D.jpg"&gt;&lt;img title="clip_image016" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="224" alt="clip_image016" src="http://lh6.ggpht.com/_toA00pxrCRM/Suu3v3pzJkI/AAAAAAAAANY/1jBtyeF2yh8/clip_image016_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;13. We get a warning for the dimension as “Avoid visible attribute hierarchies for attributes used as levels in user-defined hierarchies”. To implement this best practice, select each attributes and change its AttributeHierarchyVisible property to False.&lt;/p&gt;&lt;p&gt;14. Let us add one more dimension for Time. Select DSV, right click on the empty area and select Add/Remove tables, add SalesOrderHeader and click. Specify SalesOrderId from SalesOrderDetails as logical primary key and establish relationship to the newly added table. &lt;/p&gt;&lt;p&gt;15. Right click on Dimensions in solution explorer and add a new dimension. Select ‘Generate a Time Table’ on server, and enter details as shown below:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_toA00pxrCRM/Suu3xMYJ7FI/AAAAAAAAANc/QdylOW4-Ifs/s1600-h/clip_image018%5B4%5D.jpg"&gt;&lt;img title="clip_image018" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="393" alt="clip_image018" src="http://lh6.ggpht.com/_toA00pxrCRM/Suu3yBa2sJI/AAAAAAAAANg/in2_n1EPkDs/clip_image018_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Click Next, Next again and finally Finish. Verify that the wizard automatically creates one hierarchy with year, quarter, month and Data as attributes&lt;/p&gt;&lt;p&gt;16. We need to add this dimension to the cube, so select the cube structure tab, right click on the empty area for dimensions and select add a cube dimension and select Time. Process and deploy the changes.&lt;/p&gt;&lt;p&gt;17. Go to Browser tab, click reconnect and you will see the newly created dimension added.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/Suu3y-VcAqI/AAAAAAAAANk/ak2p0cH7TkI/s1600-h/clip_image020%5B4%5D.jpg"&gt;&lt;img title="clip_image020" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="136" alt="clip_image020" src="http://lh6.ggpht.com/_toA00pxrCRM/Suu32K_6vNI/AAAAAAAAANo/XUNSJVHtTnU/clip_image020_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;18. We can filter the data in following manner&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_toA00pxrCRM/Suu328eP10I/AAAAAAAAANs/vixff7HiJvg/s1600-h/clip_image022%5B4%5D.jpg"&gt;&lt;img title="clip_image022" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="242" alt="clip_image022" src="http://lh6.ggpht.com/_toA00pxrCRM/Suu33jY8nnI/AAAAAAAAANw/rQQkx6Vt5Go/clip_image022_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;In next article, we will discuss an overview of SQL Server Reporting Services and create a report based on this cube.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-99377508274608968?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/MJQ-NIDvSXI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/MJQ-NIDvSXI/creating-cube-and-dimension-using-ssas.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/creating-cube-and-dimension-using-ssas.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-1938248533403757558</guid><pubDate>Wed, 28 Oct 2009 15:05:00 +0000</pubDate><atom:updated>2009-10-28T08:06:52.088-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Analysis Services SSAS</category><title>Overview of SQL Server Analysis Services (SSAS)</title><description>&lt;p&gt;In a previous article, we discussed &lt;a href="http://www.sqlservercurry.com/2009/10/overview-of-sql-server-integration.html"&gt;SQL Server Integration Services&lt;/a&gt;, its components and how to &lt;a href="http://www.sqlservercurry.com/2009/10/creating-your-first-ssis-package-with.html"&gt;create package by using Import Export Wizard&lt;/a&gt;. In this article we will take an overview of SSAS and its various components. &lt;/p&gt;&lt;p&gt;With SSIS, we discussed how data can be fetched and cleansed before it is put into a uniform platform. With SSAS, as the name suggests, we can use the data for analysis. &lt;/p&gt;&lt;p&gt;With any organization we have two kinds of data, one which stores transactional details and the other which has historical (Data Warehouse - DW) details. The data in DW will be populated periodically from the data from transactional (OLTP – OnLine Transactional Processing). The data in OLTP is optimized for faster insertion and updations, but the data in DW is meant for faster querying. With DW we can store duplicate data, computed columns, non normalized data as the storage is not important. The important aspect is that when a query is fired, it should give faster results.&lt;/p&gt;&lt;p&gt;When we want to take any decisions based on data, the data needs to be in an analyzed format. For e.g.  we want to find out the code churn for developers in an organization. We need to have all the details for each developer; such as how many lines of code were written, modified or deleted. When we need the report, if we start calculating the numbers for each developer for a day, a week, a month or a quarter, it will be time consuming job. If I already have this aggregated data in cache, my job will be very easy. This aggregated data is put in cubes which are termed as multidimensional databases. As the normal cube has multiple dimensions, the data can be viewed with various axes. In this case one axis can be for each developer; another can be for a particular period and third can be for a particular department or for a particular project. Thus we can create different slices for looking at the same data. These slices are termed as dimensions and the actual data is the fact. The sales related data (like the sales person information, data for sales, quantity, and price) will be termed as fact and the axes (like sales person wise information, location wise details, quarterly details) will be termed as dimensions. &lt;/p&gt;&lt;p&gt;The thumb rule says that facts are numeric measures while dimension has primary keys. Thus primary keys in dimension tables are related to foreign keys in fact tables so as to get the details as and when required. There are 2 dimensional models namely star schema and snowflake schema. In star schema, single fact table is related to multiple dimension tables based on primary key in dimension tables (which resembles start like shape) as follows.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_toA00pxrCRM/SuhdtP-fVMI/AAAAAAAAAMI/cA62UrJ1hv8/s1600-h/image%5B6%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="438" alt="image" src="http://lh6.ggpht.com/_toA00pxrCRM/SuhduXhAnII/AAAAAAAAAMM/5wf2fh-jXco/image_thumb%5B4%5D.png?imgmax=800" width="534" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;In snowflake schema, one of the dimension acts as a fact for another dimension thus giving snowflake like appearance as below&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/SuhdvM9WApI/AAAAAAAAAMU/Y6v4CYZnshw/s1600-h/image%5B10%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="140" alt="image" src="http://lh6.ggpht.com/_toA00pxrCRM/SuhdwOU9zyI/AAAAAAAAAMY/gCs-8GwqsTw/image_thumb%5B6%5D.png?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;With SSAS, we first need to specify the source from which data is to be fetched. Later the data can be analyzed. After the source, we can create a Data Source View (DSV) to the source. If the source database has 50 tables, we need not want to work with all of them in a given situation. So we create a window to the data with required tables in it. We can also group tables from different sources and put it in the same DSV. &lt;/p&gt;&lt;p&gt;We can even create logical relationships amongst the table in the DSV where the source database remains intact. We are just creating a logical view to the tables.&lt;/p&gt;&lt;p&gt;In this article, we took an overview of SSAS and its various components. In the next article, we will create a cube by using Business Intelligence Development Studio (BIDS).&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-1938248533403757558?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/m9JQICicusM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/m9JQICicusM/overview-of-sql-server-analysis.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/overview-of-sql-server-analysis.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-1306884969438326883</guid><pubDate>Mon, 26 Oct 2009 23:31:00 +0000</pubDate><atom:updated>2009-10-26T22:32:33.477-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Integration Services SSIS</category><title>Creating your first SSIS package with the help of Import Export Wizard</title><description>&lt;p&gt;In my previous article &lt;a href="http://www.sqlservercurry.com/2009/10/overview-of-sql-server-integration.html"&gt;Overview of SQL Server Integration Services (SSIS)&lt;/a&gt;, we had a quick overview of SSIS and the different features it provides. In this post, I will show you how to create your first SSIS package with the help of Import Export Wizard&lt;/p&gt;  &lt;p&gt;1. Start BIDS and create a solution named ‘DemoBeginning’&lt;/p&gt;  &lt;p&gt;2. Add a SQL Server Integration Services Project with name ‘DemoImportExport’ to the solution.&lt;/p&gt;  &lt;p&gt;3. Delete the default package given in the solution explorer &amp;gt; right click on packages and select SSIS Import Export Wizard&lt;/p&gt;  &lt;p&gt;4. We will fetch tables from the sample database AdventureWorks and put them in a newly created database named ‘DemoDB’&lt;/p&gt;  &lt;p&gt;5. After the initial screen of the wizard, select AdventureWorks database from the database server as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_toA00pxrCRM/SuaFiKVKOAI/AAAAAAAAAL4/fGkUUXIKVuo/s1600-h/image%5B3%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="453" alt="image" src="http://lh5.ggpht.com/_toA00pxrCRM/SuaFjaLJMRI/AAAAAAAAAL8/VFt7YL-6PrE/image_thumb%5B1%5D.png?imgmax=800" width="434" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;6. Click Next &amp;gt; Click on New tab for destination database and give name DemoDB. Keep all default settings and click OK.&lt;/p&gt;  &lt;p&gt;7. From specify table copy or query screen selec,t copy data from one or more tables or views and click Next&lt;/p&gt;  &lt;p&gt;8. Select tables Production.Product, Production.SubCategory, Production.ProductCategory, Sales.SalesOrderDetail and Sales.SalesOrderHeader. We will keep all the default settings, hence will not do any Edit Mappings &amp;gt; click Next&lt;/p&gt;  &lt;p&gt;9. On complete the Wizard screen, you will see the following screen:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_toA00pxrCRM/SuaFkm9Pf9I/AAAAAAAAAMA/6cdyAHaStfc/s1600-h/image%5B7%5D.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="450" alt="image" src="http://lh3.ggpht.com/_toA00pxrCRM/SuaFmNtUeGI/AAAAAAAAAME/osAyZhDG_xY/image_thumb%5B3%5D.png?imgmax=800" width="437" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Click Finish and click on Close after the required actions.&lt;/p&gt;  &lt;p&gt;10. In solution explorer you will a see a package created with 2 tasks in control flow and 5 data sources and 5 destinations in data flow task. We can see only 2 connection managers, one used for source and one for destination.&lt;/p&gt;  &lt;p&gt;11. We have just created the package but the data is not present in database. You can verify that the database is created without any tables in it. The ‘Prepare SQL Task’ from control flow creates the tables. &lt;/p&gt;  &lt;p&gt;12. Execute the package by right clicking on the package in solution explorer and execute package. &lt;/p&gt;  &lt;p&gt;You can verify the creation of tables and the data after successful execution. The components will first be shown in yellow color which will subsequently turn to green on execution or red if any error encountered. You can verify that the newly created tables do not have any primary keys and also any relationship. If we want to persist this we need to select Edit Mappings and do the necessary changes.&lt;/p&gt;  &lt;p&gt;In next article we will continue with the same database and create a cube based on it.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-1306884969438326883?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/dqz3wK3L1oU" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/dqz3wK3L1oU/creating-your-first-ssis-package-with.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/creating-your-first-ssis-package-with.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-8172622543506235232</guid><pubDate>Sat, 24 Oct 2009 23:24:00 +0000</pubDate><atom:updated>2009-10-24T19:30:06.841-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Integration Services SSIS</category><title>Overview of SQL Server Integration Services (SSIS)</title><description>&lt;p align="justify"&gt;In one of the previous article &lt;a href="http://www.sqlservercurry.com/2009/07/exploring-business-intelligence-with.html"&gt;&lt;strong&gt;Exploring Business Intelligence (BI) with SQL Server&lt;/strong&gt;&lt;/a&gt; , I discussed an overview of Business Intelligence and the three main tools provided by Microsoft for the same. The three tools are SQL Server Integration Services (SSIS), SQL Server Analysis Services (SSAS) and SQL Server Reporting Services (SSRS). In this article we will discuss the various components in SSIS, its architecture and how to create a small package using SSIS.&lt;/p&gt;  &lt;p align="justify"&gt;BI is a set of tools and technologies provided to make better business decisions. These tools can be used for querying and reporting, data mining, data gathering or OLAP (Online analytical processing). Every organization deals with a lot of data. Every department in any organization has its own way of data storage. Some prefer to store in excel, some use access while some departments may store the data in relational database like SQL Server. If we are creating a report for Order Processing and we get the customers’ orders in printed form we require data entry for this. Suppose this data is entered with excel sheet. We have an Inventory processing system purchased from a third party where the data is stored in Oracle and we store all our customers’ information in SQL Server. We want to create a report which uses data from all these disparate sources. We can put all these data in a common platform with the help of SSIS.&lt;/p&gt;  &lt;p align="justify"&gt;As the name suggests SSIS is used for fetching data (from disparate sources), doing some changes on it (like changing the type from excel to SQL, or creating calculated field) and put the data on a uniform format which can be subsequently used for further analyzing or reporting.&lt;/p&gt;  &lt;p align="justify"&gt;SSIS is a service so you can have only one service on a single box. We have 2 runtime engines in the form of control flow and data flow. It is commonly called as ETL (Extract, Transform and Load). With Business Intelligence Development Studio (BIDS) we have graphical tools as well as wizards for creating and debugging the packages. Packages form the intricate component in SSIS template. Each package is a basic unit of deployment. Every package has control flow and data flow element. Each package has single control flow which is like the workflow for the package. Data flow is a component of control flow but provided with a separate tab as most of the packages will use it for ETL.&lt;/p&gt;  &lt;p align="justify"&gt;With ETL, apart from extracting and loading data from various sources and destinations we can do a lot of transformations to the data. We can merge data from 2 sources into one, we can convert column data type to suit the destination data type, the data can be sorted before putting in, and we can split the data by giving a condition so as to continue with only conditional data and many more tasks.&lt;/p&gt;  &lt;p align="justify"&gt;When we start the template of SQL Server Integration services, with the help of BIDS, we get following screen&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_toA00pxrCRM/SuO2v6pR7II/AAAAAAAAALA/3-0wSUSt5ho/s1600-h/clip_image0024.jpg"&gt;&lt;img title="clip_image002" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="242" alt="clip_image002" src="http://lh3.ggpht.com/_toA00pxrCRM/SuO2w8AoMjI/AAAAAAAAALE/jbkPtBJwy_0/clip_image002_thumb1.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;The template automatically creates a package with the name as “Package.dtsx”. The extension dtsx stands for data transformation services with XML format. Everything in the package will be stored in XML format. The following screen shows the separate tab for Data Flow. &lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/SuO2xYA-NtI/AAAAAAAAALI/AAZLWLxJ1yo/s1600-h/clip_image0044.jpg"&gt;&lt;img title="clip_image004" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="77" alt="clip_image004" src="http://lh6.ggpht.com/_toA00pxrCRM/SuO2ydndQ4I/AAAAAAAAALM/Py4q5iyTgzk/clip_image004_thumb1.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;The following screen shows some of the components from control flow tab from toolbox&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_toA00pxrCRM/SuO2zcyxCVI/AAAAAAAAALQ/NNAzIcWDe0g/s1600-h/clip_image0065.jpg"&gt;&lt;img title="clip_image006" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="375" alt="clip_image006" src="http://lh6.ggpht.com/_toA00pxrCRM/SuO20P32j9I/AAAAAAAAALU/6pjmYGC-EjQ/clip_image006_thumb2.jpg?imgmax=800" width="288" border="0" /&gt;&lt;/a&gt;     &lt;br /&gt;We can just drag and drop the required component on the design area.&lt;/p&gt;  &lt;p align="justify"&gt;With the data flow we get three distinct components -- Data sources, Data Transformations and Data Destinations as shown here&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_toA00pxrCRM/SuO2075nDlI/AAAAAAAAALY/H0U6O8_kFlk/s1600-h/clip_image0083.jpg"&gt;&lt;img title="clip_image008" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="80" alt="clip_image008" src="http://lh3.ggpht.com/_toA00pxrCRM/SuO21ttVSzI/AAAAAAAAALc/Tuo0XlREK9E/clip_image008_thumb.jpg?imgmax=800" width="232" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;With Data flow, we normally fetch data from various sources, do any data cleansing on it if required and finally load into destination. &lt;/p&gt;  &lt;p align="justify"&gt;We also have debugging facility with control flow, where we can add break points when required. With Data flow we have data viewer as a debugger which will show the data in grid, histogram, scatter plot or column chart. &lt;/p&gt;  &lt;p align="justify"&gt;Apart from control flow and data flow, other components of package include connection managers, variables, Event handlers and log providers. When we are working with data source or data destinations we require specifying the connections from which we can fetch data or load data into. These can be created by dragging and dropping data source or destination component on the design area and configuring it or by right clicking in the empty area for connection managers as shown below&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_toA00pxrCRM/SuO22TrLFaI/AAAAAAAAALg/r8e_c1rxqiU/s1600-h/clip_image0105.jpg"&gt;&lt;img title="clip_image010" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="93" alt="clip_image010" src="http://lh5.ggpht.com/_toA00pxrCRM/SuO23TvwOEI/AAAAAAAAALk/9jt5CJyNw0I/clip_image010_thumb2.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;We can create variables with different scope with each package. SSIS has 2 types of variables, system variables and user defined variable. System variables store information about the running packages. The scope of user defined variables can be for complete package or for a control on the package. The variable name is case sensitive. These variables can be used for passing properties at run time, specify the value for loop iterations etc. &lt;/p&gt;  &lt;p align="justify"&gt;At run time, control flow components like loops, sequence containers and also packages raise events. Event handlers are used to enhance functionality depending upon the event raised like OnError, OnProgress, OnTaskFailed etc. The events for Package are shown below:&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_toA00pxrCRM/SuO24MDK0_I/AAAAAAAAALo/hIGmtRJV5WI/s1600-h/clip_image0124.jpg"&gt;&lt;img title="clip_image012" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="114" alt="clip_image012" src="http://lh6.ggpht.com/_toA00pxrCRM/SuO25JBW5CI/AAAAAAAAALs/78S3LF99dzM/clip_image012_thumb1.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Remember if any event has no handlers, event is raised to the next container up in hierarchy for package. &lt;/p&gt;  &lt;p align="justify"&gt;Logging can be provided for tasks, containers or packages. When you add logging to the package, you need to specify the provider and the location. The following figure shows types of log.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/SuO2574Mr4I/AAAAAAAAALw/LUwBMkPupDQ/s1600-h/clip_image0144.jpg"&gt;&lt;img title="clip_image014" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="178" alt="clip_image014" src="http://lh4.ggpht.com/_toA00pxrCRM/SuO266VZphI/AAAAAAAAAL0/5P0z8FYOY6Y/clip_image014_thumb1.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;You can configure log by giving the name and description. You also need to give the connection manager log needs. &lt;/p&gt;  &lt;p align="justify"&gt;In this article, we had a quick overview of SSIS and the different features it provides. In the next article, I will show you how to create your first SSIS package with the help of Import Export Wizard &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-8172622543506235232?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/YlEshFLR5kk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/YlEshFLR5kk/overview-of-sql-server-integration.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/overview-of-sql-server-integration.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-8308715051077289275</guid><pubDate>Thu, 22 Oct 2009 23:31:00 +0000</pubDate><atom:updated>2009-10-22T20:38:42.407-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Data Services</category><title>SQL Data Services (SDS) Series</title><description>&lt;p&gt;SDS is a part of the Azure platform. If you have missed out on the SQL Data Services (SDS) series written by Gouri Sohoni, here’s the link list for you:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.sqlservercurry.com/2009/10/sql-data-services-sds.html"&gt;SQL Data Services (SDS)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.sqlservercurry.com/2009/10/sql-data-services-sds-part-ii.html"&gt;SQL Data Services (SDS) Part II&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.sqlservercurry.com/2009/10/sql-data-services-sds-part-iii.html"&gt;SQL Data Services (SDS) Part III&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.sqlservercurry.com/2009/10/connecting-to-sql-data-services-sds.html"&gt;Connecting to SQL Data Services (SDS) with SQL Server Management Studio (SSMS)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.sqlservercurry.com/2009/10/sql-data-services-sds-part-iv.html"&gt;SQL Data Services (SDS) Part IV&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.sqlservercurry.com/2009/10/sql-data-services-sds-part-v.html"&gt;SQL Data Services (SDS) Part V&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.sqlservercurry.com/2009/10/sql-data-services-sds-part-vi.html"&gt;SQL Data Services (SDS) Part VI&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-8308715051077289275?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/54tIfSQPrJo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/54tIfSQPrJo/sql-data-services-sds-series.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/sql-data-services-sds-series.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-5534888672062822519</guid><pubDate>Tue, 20 Oct 2009 14:48:00 +0000</pubDate><atom:updated>2009-10-20T07:53:25.525-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Reporting Services SSRS</category><title>Some Similarities and Dissimilarities between 3 different Report Creation Tools from Microsoft</title><description>&lt;p&gt;The three main Report Creation tools from Microsoft are Business Intelligence Development Studio (BIDS), Report Builder 1.0 and Report Builder 2.0&lt;/p&gt;&lt;p&gt;- The main similarity in all the three of them is that all these tools create RDL (Report Definition Language)&lt;/p&gt;&lt;p&gt;- BIDS provides integrated environment for working with reporting services, integration services and analysis services, which is available with Visual Studio interface. Report Builder tools facilitate working for users who are not familiar with Business Intelligence Development Studio (BIDS).&lt;/p&gt;&lt;p&gt;- BIDS provides more flexibility in terms of deployment configurations as well as provides different rendering extensions. &lt;/p&gt;&lt;p&gt;- The query designer is available for BIDS and Report Builder 2.0 but is not available with Report Builder 1.0. &lt;/p&gt;&lt;p&gt;- We can only create reports on report models with Report Builder 1.0. With BIDS as well as Report Builder 2.0, the report can be based on data source other than report model like relational data sources. &lt;/p&gt;&lt;p&gt;- Multidimensional data source are directly available with query designer for BIDS. For Report Builder, we can create report models on multidimensional data and then subsequently reports can be created based on them. &lt;/p&gt;&lt;p&gt;- Use of query files (.sql) is available with BIDS and Report Builder 2.0&lt;/p&gt;&lt;p&gt;- Report designing wizard is available only with BIDS. We also have a wizard for Report Builder 2.0 for report creation. &lt;/p&gt;&lt;p&gt;- All the three tools provide rendering extensions for Word, Excel, PDF, CSV (Comma limited). &lt;/p&gt;&lt;p&gt;- Viewing of .RDL source is only supported with BIDS.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-5534888672062822519?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/wDhAOTW-kEA" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/wDhAOTW-kEA/some-similarities-and-dissimilarities.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/some-similarities-and-dissimilarities.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-7480164327451402499</guid><pubDate>Sun, 18 Oct 2009 12:09:00 +0000</pubDate><atom:updated>2009-10-18T05:12:32.818-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Data Services</category><title>SQL Data Services (SDS) Part VI</title><description>&lt;p&gt;In the &lt;a href="http://www.sqlservercurry.com/search/label/SQL%20Data%20Services"&gt;&lt;strong&gt;previous SDS posts&lt;/strong&gt;&lt;/a&gt;, we discussed how to create database, create table in the cloud by writing a query. We have also seen how to write &lt;a href="http://www.sqlservercurry.com/2009/10/sql-data-services-sds-part-v.html" target="_blank"&gt;&lt;strong&gt;T-SQL statements with SQL Azure&lt;/strong&gt;&lt;/a&gt;. &lt;/p&gt;&lt;p&gt;In this post, we will discuss how XML data type works with SQL Azure using some sample queries:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;How let clause works with FLOWR expression in SQL Azure&lt;/strong&gt;&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:green;"&gt;--Let clause with FLOWR expression for XML is supported in SQL Azure&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;declare &lt;/span&gt;@x &lt;span style="color:blue;"&gt;xml &lt;/span&gt;= &lt;span style="color:#a31515;"&gt;''&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:blue;"&gt;select &lt;/span&gt;@x.query(&lt;span style="color:#a31515;"&gt;'&lt;br /&gt;for $i in (1,2,3,4)&lt;br /&gt;return $i'&lt;/span&gt;)&lt;br /&gt;go&lt;br /&gt;&lt;span style="color:green;"&gt;-- returns 1 2 3 4&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;declare &lt;/span&gt;@x &lt;span style="color:blue;"&gt;xml &lt;/span&gt;= &lt;span style="color:#a31515;"&gt;''&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:blue;"&gt;select &lt;/span&gt;@x.query(&lt;span style="color:#a31515;"&gt;'&lt;br /&gt;for $i in ("A","B","C")&lt;br /&gt;order by $i descending&lt;br /&gt;return $i'&lt;/span&gt;)&lt;br /&gt;go&lt;br /&gt;&lt;span style="color:green;"&gt;-- returns  C B A&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;declare &lt;/span&gt;@x &lt;span style="color:blue;"&gt;xml &lt;/span&gt;= &lt;span style="color:#a31515;"&gt;''&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:blue;"&gt;select &lt;/span&gt;@x.query(&lt;span style="color:#a31515;"&gt;'&lt;br /&gt;let $x := 1&lt;br /&gt;return $x'&lt;/span&gt;)&lt;br /&gt;go&lt;br /&gt;&lt;span style="color:green;"&gt;-- returns 1&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;declare &lt;/span&gt;@x &lt;span style="color:blue;"&gt;xml &lt;/span&gt;= &lt;span style="color:#a31515;"&gt;''&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:blue;"&gt;select &lt;/span&gt;@x.query(&lt;span style="color:#a31515;"&gt;'&lt;br /&gt;let $x := ( &amp;lt;one&amp;gt;2&amp;lt;/one&amp;gt; )&lt;br /&gt;return $x'&lt;/span&gt;)&lt;br /&gt;go&lt;br /&gt;&lt;span style="color:green;"&gt;-- error:&lt;br /&gt;-- XQuery [query()]: let  is not supported with constructed XML&lt;br /&gt;&lt;br /&gt;-- When we use let inside a loop, it is evaluated each time for the loop&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;declare &lt;/span&gt;@x &lt;span style="color:blue;"&gt;xml &lt;/span&gt;= &lt;span style="color:#a31515;"&gt;''&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:blue;"&gt;select &lt;/span&gt;@x.query(&lt;span style="color:#a31515;"&gt;'&lt;br /&gt;for $i in (1,2)&lt;br /&gt;let $j := "try"&lt;br /&gt;return ($i, $j)'&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;-- returns 1 try 2 try&lt;br /&gt;-- $j is evaluated 2 times&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;How XQuery works with SQL Azure&lt;/strong&gt;&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;CREATE TABLE &lt;/span&gt;#Depts&lt;br /&gt;(DeptID &lt;span style="color:blue;"&gt;integer IDENTITY PRIMARY KEY&lt;/span&gt;,&lt;br /&gt; DeptName &lt;span style="color:blue;"&gt;nvarchar&lt;/span&gt;(40),&lt;br /&gt; Manager &lt;span style="color:blue;"&gt;nvarchar&lt;/span&gt;(40),&lt;br /&gt; Names &lt;span style="color:blue;"&gt;xml&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;#Depts&lt;br /&gt;&lt;span style="color:blue;"&gt;VALUES&lt;br /&gt;&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;'SQL zure'&lt;/span&gt;,&lt;span style="color:#a31515;"&gt;'Sane'&lt;/span&gt;,&lt;span style="color:#a31515;"&gt;'&amp;lt;Names&amp;gt;&lt;br /&gt;&amp;lt;Name FirstName="Geeta" LastName="Sohoni"/&amp;gt;&lt;br /&gt;&amp;lt;Name FirstName="Mani" LastName="Raje"/&amp;gt;&lt;br /&gt;&amp;lt;Name FirstName="Raja" LastName="Tembhe"/&amp;gt;&lt;br /&gt;&amp;lt;/Names&amp;gt;'&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;#Depts&lt;br /&gt;&lt;span style="color:blue;"&gt;VALUES&lt;br /&gt;&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;'SQL Server'&lt;/span&gt;,&lt;span style="color:#a31515;"&gt;'Dani'&lt;/span&gt;,&lt;span style="color:#a31515;"&gt;'&amp;lt;Names&amp;gt;&lt;br /&gt;&amp;lt;Name FirstName="Suruchi" LastName="Risbud"/&amp;gt;&lt;br /&gt;&amp;lt;/Names&amp;gt;'&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;#Depts&lt;br /&gt;&lt;span style="color:blue;"&gt;VALUES&lt;br /&gt;&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;'SQL Server 2005'&lt;/span&gt;,&lt;span style="color:#a31515;"&gt;'Kulkarni'&lt;/span&gt;,&lt;span style="color:blue;"&gt;NULL&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;* &lt;span style="color:blue;"&gt;FROM &lt;/span&gt;#Depts&lt;/pre&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;The result is as follows:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/StsFUsRRI8I/AAAAAAAAAKg/jC-t-SDrLJg/s1600-h/image%5B12%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="114" alt="image" src="http://lh5.ggpht.com/_toA00pxrCRM/StsFVoiXuDI/AAAAAAAAAKk/agiVMj7_uQI/image_thumb%5B4%5D.png?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;The following query gives similar results:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;DeptID, DeptName,Manager,Names.query(&lt;span style="color:#a31515;"&gt;'&lt;br /&gt;/Names/Name'&lt;/span&gt;)&lt;br /&gt;&lt;span style="color:blue;"&gt;FROM &lt;/span&gt;#Depts&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://lh5.ggpht.com/_toA00pxrCRM/StsFWSYgGtI/AAAAAAAAAKo/-zlxGMqcM2M/s1600-h/image%5B13%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="182" alt="image" src="http://lh6.ggpht.com/_toA00pxrCRM/StsFXdAtxHI/AAAAAAAAAKs/sq0ndHpGGoA/image_thumb%5B5%5D.png?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;The result of following query:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;DeptID, DeptName,Manager,Names.value(&lt;span style="color:#a31515;"&gt;'&lt;br /&gt;(/Names/Name/@FirstName)[2]'&lt;/span&gt;,&lt;span style="color:#a31515;"&gt;'char(10)'&lt;/span&gt;) SecondPerson&lt;br /&gt;&lt;span style="color:blue;"&gt;FROM &lt;/span&gt;#Depts&lt;/pre&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;is as follows:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_toA00pxrCRM/StsFX9e1eiI/AAAAAAAAAKw/dVpZBkEyUYg/s1600-h/image%5B8%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="99" alt="image" src="http://lh5.ggpht.com/_toA00pxrCRM/StsFY80K3iI/AAAAAAAAAK0/xc8mlm7zyn0/image_thumb%5B2%5D.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;as the last 2 records have a single person&lt;/p&gt;&lt;p&gt;To fetch the Manager Name&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;DeptName,Manager &lt;span style="color:blue;"&gt;FROM &lt;/span&gt;#Depts&lt;br /&gt;&lt;span style="color:blue;"&gt;WHERE &lt;/span&gt;Names.exist(&lt;span style="color:#a31515;"&gt;'/Names/Name/@FirstName[1]'&lt;/span&gt;) = 1&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://lh5.ggpht.com/_toA00pxrCRM/StsFZszbVPI/AAAAAAAAAK4/FImILeKt9tc/s1600-h/image%5B11%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="108" alt="image" src="http://lh3.ggpht.com/_toA00pxrCRM/StsFbNaLl9I/AAAAAAAAAK8/1dvEoY-TUKk/image_thumb%5B3%5D.png?imgmax=800" width="192" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;The following 2 queries gives exclusive results -- one returns data where there are no people under manager and the other where at least one person has a manager&lt;/p&gt;&lt;p&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;DeptName,Manager &lt;span style="color:blue;"&gt;FROM&lt;/span&gt;#Depts&lt;br /&gt;&lt;span style="color:blue;"&gt;WHERE&lt;/span&gt;Names.exist(&lt;span style="color:#a31515;"&gt;&lt;a href="mailto:"&gt;'/Names/Name/@FirstName[1]'&lt;/a&gt;&lt;/span&gt;) = 0&lt;br /&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;--using exist&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;SELECT&lt;/span&gt;DeptName,Manager &lt;span style="color:blue;"&gt;FROM&lt;/span&gt;#Depts&lt;br /&gt;&lt;span style="color:blue;"&gt;WHERE&lt;/span&gt;Names.exist(&lt;span style="color:#a31515;"&gt;'/Names/Name'&lt;/span&gt;) = 1&lt;/p&gt;&lt;p&gt;The following query will insert one of the relational column in XML as though it is an XML tag&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;DeptName, Names.query(&lt;span style="color:#a31515;"&gt;'&amp;lt;Names&amp;gt;&lt;br /&gt;    &amp;lt;Mgr&amp;gt;{sql:column("Manager")}&amp;lt;/Mgr&amp;gt;&lt;br /&gt;    {&lt;br /&gt;     for $i in /Names/Name&lt;br /&gt;     return $i&lt;br /&gt;    }&lt;br /&gt;    &amp;lt;/Names&amp;gt;'&lt;/span&gt;)&lt;br /&gt;&lt;span style="color:blue;"&gt;FROM &lt;/span&gt;#Depts&lt;br /&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;--use modify method and insert a column&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;UPDATE &lt;/span&gt;#Depts&lt;br /&gt;&lt;span style="color:blue;"&gt;SET &lt;/span&gt;Names.modify(&lt;span style="color:#a31515;"&gt;'insert element Peon {"Raju"}&lt;br /&gt;  as first&lt;br /&gt;  into (/Names)[1]'&lt;/span&gt;)&lt;br /&gt;&lt;span style="color:blue;"&gt;WHERE &lt;/span&gt;DeptID = 1&lt;br /&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;--delete the newly added tag&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;UPDATE &lt;/span&gt;#Depts&lt;br /&gt;&lt;span style="color:blue;"&gt;SET &lt;/span&gt;Names.modify(&lt;span style="color:#a31515;"&gt;'delete (/Names/Peon)[1]'&lt;/span&gt;)&lt;br /&gt;&lt;span style="color:blue;"&gt;WHERE &lt;/span&gt;DeptID = 1&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-7480164327451402499?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/SCKRccEv3fc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/SCKRccEv3fc/sql-data-services-sds-part-vi.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/sql-data-services-sds-part-vi.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-2896416412469608591</guid><pubDate>Fri, 16 Oct 2009 14:27:00 +0000</pubDate><atom:updated>2009-10-16T07:29:30.520-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Data Services</category><title>SQL Data Services (SDS) Part V</title><description>&lt;p&gt;We discussed some T-SQL statements in my previous post &lt;a href="http://www.sqlservercurry.com/2009/10/sql-data-services-sds-part-iv.html"&gt;SQL Data Services (SDS) Part IV.&lt;/a&gt; In this post, I will show some more T-SQL statements with SQL Azure and discuss the compulsion of using clustered index, and how try … catch and Transaction related statements differ with the use of SET XACT_ABORT clause&lt;/p&gt;&lt;p&gt;Note that SQL Azure does not support heap tables. You need to create clustered index. If a table is created without a clustered index, you must create one before inserting data. If you have no clustered index for a table and you try entering data in that table, you get following error in SQL Azure&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_toA00pxrCRM/StiCq45mpmI/AAAAAAAAAKI/r5vP3nB-iFM/s1600-h/image%5B9%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="200" alt="image" src="http://lh5.ggpht.com/_toA00pxrCRM/StiCr0Pla0I/AAAAAAAAAKM/6suSQm1SiRY/image_thumb%5B3%5D.png?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Following is the example with Try Catch and SET XACT_ABORT_OFF or ON&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;IF OBJECT_ID&lt;/span&gt;(N&lt;span style="color:#a31515;"&gt;'t2'&lt;/span&gt;, N&lt;span style="color:#a31515;"&gt;'U'&lt;/span&gt;) &lt;span style="color:blue;"&gt;IS NOT NULL&lt;br /&gt;    DROP TABLE &lt;/span&gt;t2;&lt;br /&gt;GO&lt;br /&gt;&lt;span style="color:blue;"&gt;IF OBJECT_ID&lt;/span&gt;(N&lt;span style="color:#a31515;"&gt;'t1'&lt;/span&gt;, N&lt;span style="color:#a31515;"&gt;'U'&lt;/span&gt;) &lt;span style="color:blue;"&gt;IS NOT NULL&lt;br /&gt;    DROP TABLE &lt;/span&gt;t1;&lt;br /&gt;GO&lt;br /&gt;&lt;span style="color:blue;"&gt;CREATE TABLE &lt;/span&gt;t1&lt;br /&gt;    (a &lt;span style="color:blue;"&gt;INT NOT NULL PRIMARY KEY&lt;/span&gt;);&lt;br /&gt;&lt;span style="color:blue;"&gt;CREATE TABLE &lt;/span&gt;t2&lt;br /&gt;    (id &lt;span style="color:blue;"&gt;int primary key identity&lt;/span&gt;,a &lt;span style="color:blue;"&gt;INT NOT NULL REFERENCES &lt;/span&gt;t1(a));&lt;br /&gt;GO&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;t1 &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;(1);&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;t1 &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;(3);&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;t1 &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;(4);&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;t1 &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;(6);&lt;br /&gt;GO&lt;br /&gt;&lt;span style="color:blue;"&gt;SET &lt;/span&gt;XACT_ABORT &lt;span style="color:blue;"&gt;OFF&lt;/span&gt;;&lt;br /&gt;GO&lt;br /&gt;&lt;span style="color:blue;"&gt;BEGIN TRANSACTION&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;t2 &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;(1);&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;t2 &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;(2); &lt;span style="color:green;"&gt;-- Foreign key error.&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;t2 &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;(3);&lt;br /&gt;&lt;span style="color:blue;"&gt;COMMIT TRANSACTION&lt;/span&gt;;&lt;br /&gt;GO&lt;br /&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;* &lt;span style="color:blue;"&gt;FROM &lt;/span&gt;t2&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/StiCsopAxYI/AAAAAAAAAKQ/IQMRD9JLJH4/s1600-h/image%5B11%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="94" alt="image" src="http://lh3.ggpht.com/_toA00pxrCRM/StiCtfA9QxI/AAAAAAAAAKU/N15bNHDp6vw/image_thumb%5B5%5D.png?imgmax=800" width="494" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Even if we use Transaction, we see that the statement which gives error is not executed. The remaining 2 inserts for which there was no error, are successful&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_toA00pxrCRM/StiCuALAj4I/AAAAAAAAAKY/grw7phXtdaQ/s1600-h/image%5B8%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="118" alt="image" src="http://lh4.ggpht.com/_toA00pxrCRM/StiCuhvJcBI/AAAAAAAAAKc/JNny5KJeoTE/image_thumb%5B2%5D.png?imgmax=800" width="195" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;as we see with the select statement&lt;/p&gt;&lt;p&gt;When we use the following statement, none of the records are inserted as required:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;SET &lt;/span&gt;XACT_ABORT &lt;span style="color:blue;"&gt;ON&lt;/span&gt;;&lt;br /&gt;GO&lt;br /&gt;&lt;span style="color:blue;"&gt;BEGIN TRANSACTION&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;t2 &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;(4);&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;t2 &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;(5); &lt;span style="color:green;"&gt;-- Foreign key error.&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;t2 &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;(6);&lt;br /&gt;&lt;span style="color:blue;"&gt;COMMIT TRANSACTION&lt;/span&gt;;&lt;br /&gt;GO&lt;br /&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;* &lt;span style="color:blue;"&gt;FROM &lt;/span&gt;t1&lt;br /&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;*&lt;br /&gt;    &lt;span style="color:blue;"&gt;FROM &lt;/span&gt;t2;&lt;br /&gt;GO&lt;/pre&gt;&lt;p&gt;And SELECT statement for table t2 shows same result as what was before the insert statements&lt;/p&gt;&lt;p&gt;In this post, we discussed the compulsion of using clustered index, how try … catch and Transaction related statements differ with the use of SET XACT_ABORT clause.&lt;/p&gt;&lt;p&gt;In next article we will discuss how to use the XML data type with SQL Azure&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-2896416412469608591?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/UN0TfZEboDA" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/UN0TfZEboDA/sql-data-services-sds-part-v.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/sql-data-services-sds-part-v.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-7330223020955890507</guid><pubDate>Wed, 14 Oct 2009 11:55:00 +0000</pubDate><atom:updated>2009-10-14T10:58:57.459-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Data Services</category><title>SQL Data Services (SDS) Part IV</title><description>&lt;p&gt;In the &lt;a href="http://www.sqlservercurry.com/search/label/SQL%20Data%20Services" target="_blank"&gt;previous SDS posts&lt;/a&gt;, we discussed how to create database, create table in the cloud by writing a query and also programmatically. When working with SQL Azure T-SQL provided is a subset of T-SQL for SQL Server.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Using T-SQL with SQL Azure&lt;/b&gt;&lt;/p&gt;&lt;p&gt;1. When referring to an object in SQL Azure following are the conventions. Note that server name is not allowed in the reference&lt;/p&gt;&lt;p&gt;schema name.object name&lt;/p&gt;&lt;p&gt;i. Create a new query in SQL Server Management Studio (SSMS)&lt;br /&gt;Enter query&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;CREATE SCHEMA &lt;/span&gt;MySchema&lt;/pre&gt;&lt;p&gt;ii. Create table as follows&lt;/p&gt;&lt;p&gt;&lt;span style="color:blue;"&gt;CREATE TABLE &lt;/span&gt;MySchema.MyTable&lt;br /&gt;(Id &lt;span style="color:blue;"&gt;int identity primary key&lt;/span&gt;,&lt;br /&gt;UserName &lt;span style="color:blue;"&gt;nvarchar&lt;/span&gt;(15))&lt;/p&gt;&lt;p&gt;iii. Insert rows as follows&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;MySchema.MyTable&lt;br /&gt;&lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;(Name1),(&lt;span style="color:#a31515;"&gt;'Name2'&lt;/span&gt;)&lt;/pre&gt;&lt;p&gt;Note you need to specify the schema name with the object. Currently using database name along with schema and object name is not supported&lt;/p&gt;&lt;p&gt;2. All normal data types are supported in SQL Azure. SQL Azure does not support User Defined Data type. It supports XML data type.&lt;/p&gt;&lt;p&gt;3. SQL Azure database does not support any of the SQL system table&lt;/p&gt;&lt;p&gt;a. There is no provision and requirement of backup and restore&lt;/p&gt;&lt;p&gt;b. There is no log shipping or replication requirement&lt;/p&gt;&lt;p&gt;4. A lot of T-SQL statements like ALTER SCHEMA, ALTER ROLE, DROP LOGIN, DROP USER, CAST, CONVERT, and SET @variable are supported. We will discuss some of them&lt;/p&gt;&lt;pre class="code"&gt;a.    --&lt;span style="color:green;"&gt;create a stored proc&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;CREATE PROC &lt;/span&gt;DispNames&lt;br /&gt;&lt;span style="color:blue;"&gt;AS&lt;br /&gt;SELECT &lt;/span&gt;* &lt;span style="color:blue;"&gt;FROM &lt;/span&gt;Names&lt;br /&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;-- execute the stored proc&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;EXEC &lt;/span&gt;DispNames&lt;br /&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;--alter the existing stored proc&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;ALTER PROC &lt;/span&gt;DispNames&lt;br /&gt;&lt;span style="color:blue;"&gt;AS&lt;br /&gt;SELECT &lt;/span&gt;UserId, [User Name] &lt;span style="color:blue;"&gt;FROM &lt;/span&gt;Names&lt;br /&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;--execute changed stored proc&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;EXEC &lt;/span&gt;DispNames&lt;br /&gt;&lt;span style="color:green;"&gt;--delete the proc&lt;br /&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;DROP PROC &lt;/span&gt;DispNames&lt;/pre&gt;&lt;p&gt;b.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/StYQgJjQE3I/AAAAAAAAAJw/CaOEUtxQ4Bk/s1600-h/image%5B3%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="294" alt="image" src="http://lh6.ggpht.com/_toA00pxrCRM/StYQhwjMamI/AAAAAAAAAJ0/tsAQcoja6GY/image_thumb%5B1%5D.png?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;Notice the first variable data is truncated due to wrong length&lt;/p&gt;&lt;p&gt;c. Merge statement works with SQL Azure in the same manner as SQL Server as follows&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;CREATE TABLE &lt;/span&gt;t1&lt;br /&gt;(Id &lt;span style="color:blue;"&gt;int NOT NULL primary key&lt;/span&gt;, FullName &lt;span style="color:blue;"&gt;varchar&lt;/span&gt;(100))&lt;br /&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;CREATE TABLE &lt;/span&gt;t2&lt;br /&gt;(Id &lt;span style="color:blue;"&gt;int NOT NULL primary key&lt;/span&gt;, FullName &lt;span style="color:blue;"&gt;varchar&lt;/span&gt;(100))&lt;br /&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;t1 &lt;span style="color:blue;"&gt;VALUES&lt;br /&gt;&lt;/span&gt;(1,&lt;span style="color:#a31515;"&gt;'Smita Sane'&lt;/span&gt;),&lt;br /&gt;(5,&lt;span style="color:#a31515;"&gt;'Sarita Bhave'&lt;/span&gt;),&lt;br /&gt;(6,&lt;span style="color:#a31515;"&gt;'John'&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;t2 &lt;span style="color:blue;"&gt;VALUES&lt;br /&gt;&lt;/span&gt;(1,&lt;span style="color:#a31515;"&gt;'Smita Sohoni'&lt;/span&gt;),&lt;br /&gt;(5,&lt;span style="color:#a31515;"&gt;'Sarita sonu Bhave'&lt;/span&gt;),&lt;br /&gt;(7,&lt;span style="color:#a31515;"&gt;'Danny'&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;* &lt;span style="color:blue;"&gt;FROM &lt;/span&gt;T1&lt;br /&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;* &lt;span style="color:blue;"&gt;FROM &lt;/span&gt;T2&lt;/pre&gt;&lt;p&gt;The result for this is as follows&lt;/p&gt;&lt;a href="http://lh6.ggpht.com/_toA00pxrCRM/StYQi4NsxFI/AAAAAAAAAJ4/Ts48UzrJZpc/s1600-h/image%5B10%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="351" alt="image" src="http://lh3.ggpht.com/_toA00pxrCRM/StYQkKjE7LI/AAAAAAAAAJ8/NllBHbccJiM/image_thumb%5B4%5D.png?imgmax=800" width="328" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;MERGE &lt;/span&gt;t1&lt;br /&gt;USING&lt;br /&gt;(&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;* &lt;span style="color:blue;"&gt;from &lt;/span&gt;t2) target&lt;br /&gt;&lt;span style="color:blue;"&gt;ON &lt;/span&gt;t1.Id=target.Id&lt;br /&gt;&lt;span style="color:blue;"&gt;WHEN &lt;/span&gt;MATCHED&lt;br /&gt;&lt;span style="color:blue;"&gt;THEN UPDATE SET &lt;/span&gt;t1.FullName=target.FullName&lt;br /&gt;&lt;span style="color:blue;"&gt;WHEN  NOT &lt;/span&gt;MATCHED &lt;span style="color:blue;"&gt;by &lt;/span&gt;target&lt;br /&gt;&lt;span style="color:blue;"&gt;THEN INSERT VALUES &lt;/span&gt;(target.Id,target.FullName);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;* &lt;span style="color:blue;"&gt;FROM &lt;/span&gt;t1&lt;br /&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;* &lt;span style="color:blue;"&gt;FROM &lt;/span&gt;t2&lt;/pre&gt;&lt;p&gt;After merge the result is as follows&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/StYQlYWf1KI/AAAAAAAAAKA/AMwlRr8SxwM/s1600-h/image%5B11%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="377" alt="image" src="http://lh6.ggpht.com/_toA00pxrCRM/StYQmupBV3I/AAAAAAAAAKE/vH99hTKWKfk/image_thumb%5B5%5D.png?imgmax=800" width="284" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;So we see that in table T1 records are updated as well as inserted depending upon the condition&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;DROP TABLE &lt;/span&gt;T1&lt;br /&gt;&lt;span style="color:blue;"&gt;DROP TABLE &lt;/span&gt;T2&lt;/pre&gt;&lt;p&gt;In next article we will discuss some more T-SQL statements with SQL Azure&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-7330223020955890507?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/n9La3SAmMv0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/n9La3SAmMv0/sql-data-services-sds-part-iv.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/sql-data-services-sds-part-iv.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-5620875831403430339</guid><pubDate>Mon, 12 Oct 2009 11:55:00 +0000</pubDate><atom:updated>2009-10-12T07:57:25.845-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Data Services</category><title>Connecting to SQL Data Services (SDS) with SQL Server Management Studio (SSMS)</title><description>&lt;p&gt;In order to connect to SQL Data Services, you should have an invitation for working with SQL Azure CTP (discussed in previous article &lt;a href="http://www.sqlservercurry.com/2009/10/sql-data-services-sds.html" target="_blank"&gt;working with SQL Data Services –SDS&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;1. Start SSMS 2008. When it asks for a connection to the services, click on Cancel. If by mistake you try connecting using this window, you get following error &lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_toA00pxrCRM/StNDOr6UL6I/AAAAAAAAAJA/uIvk0pE7wKM/s1600-h/clip_image002%5B4%5D.jpg"&gt;&lt;img title="clip_image002" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="145" alt="clip_image002" src="http://lh6.ggpht.com/_toA00pxrCRM/StNDPyf_CvI/AAAAAAAAAJE/y9Revk8Y1xg/clip_image002_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;2. Click on New query and enter following details. We can only connect using SQL Server authentication as that is the only mode supported in SQL Azure. &lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_toA00pxrCRM/StNDQ1Fv6gI/AAAAAAAAAJI/Qww4uVap37w/s1600-h/clip_image004%5B4%5D.jpg"&gt;&lt;img title="clip_image004" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="332" alt="clip_image004" src="http://lh4.ggpht.com/_toA00pxrCRM/StNDSYijvVI/AAAAAAAAAJM/wanLiUqGBpU/clip_image004_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;3. Click on Options and enter the database name as follows &lt;/p&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_toA00pxrCRM/StNDTfk3tBI/AAAAAAAAAJQ/_5AYYUIHe1E/s1600-h/clip_image006%5B4%5D.jpg"&gt;&lt;img title="clip_image006" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="529" alt="clip_image006" src="http://lh4.ggpht.com/_toA00pxrCRM/StNDU6gZx4I/AAAAAAAAAJU/NLeFDrYlpcA/clip_image006_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;If you select &amp;lt;default&amp;gt; option or &amp;lt;browse Server&amp;gt; option from Select Database we get errors &lt;/p&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_toA00pxrCRM/StNDWGHtUYI/AAAAAAAAAJY/XzvhKwNSn3U/s1600-h/clip_image008%5B4%5D.jpg"&gt;&lt;img title="clip_image008" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="147" alt="clip_image008" src="http://lh4.ggpht.com/_toA00pxrCRM/StNDXKwoeGI/AAAAAAAAAJc/_isHvNRpbvo/clip_image008_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/StNDX3Pg-vI/AAAAAAAAAJg/3GpgPJOfLp8/s1600-h/clip_image010%5B4%5D.jpg"&gt;&lt;img title="clip_image010" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="114" alt="clip_image010" src="http://lh4.ggpht.com/_toA00pxrCRM/StNDY_a1OCI/AAAAAAAAAJk/SiGeLDVtF3o/clip_image010_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;You will get a warning as shown below:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_toA00pxrCRM/StNDZsM3FkI/AAAAAAAAAJo/DYOTIx0qYwU/s1600-h/clip_image012%5B4%5D.jpg"&gt;&lt;img title="clip_image012" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="99" alt="clip_image012" src="http://lh6.ggpht.com/_toA00pxrCRM/StNDaSHlYDI/AAAAAAAAAJs/_cL03KeqVxg/clip_image012_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Click OK and you are connected to SQL Azure.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-5620875831403430339?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/aCc3T-hjhUk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/aCc3T-hjhUk/connecting-to-sql-data-services-sds.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/connecting-to-sql-data-services-sds.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-6255491640487049772</guid><pubDate>Sat, 10 Oct 2009 11:55:00 +0000</pubDate><atom:updated>2009-10-10T09:52:54.756-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Data Services</category><title>SQL Data Services (SDS) Part III</title><description>&lt;p&gt;In my previous article &lt;a href="http://www.sqlservercurry.com/2009/10/sql-data-services-sds-part-ii.html" target="_blank"&gt;SQL Data Services (SDS) Part II&lt;/a&gt;, we discussed how to create database and tables with the help of a query in SQL Server Management Studio (SSMS).&lt;/p&gt;&lt;p&gt;While writing the application we have the choice of using ADO.NET provider or SQL Server 2008 ODBC driver. In this example, we are using ADO.NET in the code snippet.&lt;/p&gt;&lt;p&gt;Following code is for a console application which creates a table named T1 with 3 columns in it.&lt;/p&gt;&lt;pre class="code"&gt;// Provide the following information &lt;span style="color:blue;"&gt;to connect to &lt;/span&gt;server&lt;br /&gt;private static string userName = "&amp;lt;administrator name&amp;gt;";&lt;br /&gt;private static string password = "&amp;lt;password&amp;gt;";&lt;br /&gt;private static string dataSource = "&amp;lt;data source name";&lt;br /&gt;// data source will be server &lt;span style="color:blue;"&gt;name &lt;/span&gt;we gave &lt;span style="color:blue;"&gt;for &lt;/span&gt;SSMS query &lt;span style="color:blue;"&gt;in last &lt;/span&gt;article&lt;br /&gt;private static string sampleDatabaseName = "&amp;lt;name of database we created&amp;gt;";&lt;br /&gt;&lt;br /&gt;static void Main(string[] args)&lt;span style="color:blue;"&gt;on &lt;/span&gt;we hav&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    // &lt;span style="color:blue;"&gt;Create &lt;/span&gt;a &lt;span style="color:blue;"&gt;connection &lt;/span&gt;string &lt;span style="color:blue;"&gt;for &lt;/span&gt;the existing &lt;span style="color:blue;"&gt;database&lt;br /&gt;    &lt;/span&gt;SqlConnectionStringBuilder connStringBuilder;&lt;br /&gt;    connStringBuilder = new SqlConnectionStringBuilder();&lt;br /&gt;    connStringBuilder.DataSource = dataSource;&lt;br /&gt;    connStringBuilder.InitialCatalog = sampleDatabaseName;&lt;br /&gt;    connStringBuilder.Encrypt = &lt;span style="color:blue;"&gt;true&lt;/span&gt;;&lt;br /&gt;    connStringBuilder.TrustServerCertificate = &lt;span style="color:blue;"&gt;true&lt;/span&gt;;&lt;br /&gt;    connStringBuilder.UserID = userName;&lt;br /&gt;    connStringBuilder.Password = password;&lt;br /&gt;&lt;br /&gt;    // &lt;span style="color:blue;"&gt;Connect to &lt;/span&gt;the existing &lt;span style="color:blue;"&gt;database&lt;/span&gt;, &lt;span style="color:blue;"&gt;create table and insert &lt;/span&gt;records&lt;br /&gt;    using (SqlConnection conn = new SqlConnection(connStringBuilder.ToString()))&lt;br /&gt;    {&lt;br /&gt;        using (SqlCommand command = conn.CreateCommand())&lt;br /&gt;        {&lt;br /&gt;            conn.Open();&lt;br /&gt;&lt;br /&gt;            // &lt;span style="color:blue;"&gt;Create &lt;/span&gt;a &lt;span style="color:blue;"&gt;table&lt;br /&gt;            &lt;/span&gt;command.CommandText = "CREATE TABLE T1([id] int primary key," +&lt;br /&gt;                "FirstName varchar(20), LastName varchar(20))";&lt;br /&gt;            command.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;            // &lt;span style="color:blue;"&gt;Insert &lt;/span&gt;sample records&lt;br /&gt;            command.CommandText = "INSERT INTO T1 ([id],FirstName, LastName)" +&lt;br /&gt;            "values (1, 'Name 1','Last1'), (2, 'Name 2','Last2')," +&lt;br /&gt;            " (3, 'Name 3','Last3')";&lt;br /&gt;            &lt;span style="color:blue;"&gt;int &lt;/span&gt;rowsAdded = command.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;            // Query &lt;span style="color:blue;"&gt;table and view &lt;/span&gt;data &lt;span style="color:blue;"&gt;in while loop&lt;br /&gt;            &lt;/span&gt;command.CommandText = "SELECT * FROM T1";&lt;br /&gt;&lt;br /&gt;            using (SqlDataReader reader = command.ExecuteReader())&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color:blue;"&gt;while &lt;/span&gt;(reader.Read())&lt;br /&gt;                {&lt;br /&gt;                    Console.WriteLine("Id: {0}, First Name: {1}, Last Name: {2}",&lt;br /&gt;                                    reader["Id"].ToString(),&lt;br /&gt;                                    reader["FirstName"].ToString(),&lt;br /&gt;                                    reader["LastName"].ToString());&lt;br /&gt;                }&lt;br /&gt;            // &lt;span style="color:blue;"&gt;Update &lt;/span&gt;a record&lt;br /&gt;            command.CommandText =&lt;br /&gt;                "UPDATE T1 SET [FirstName]='change name 2' WHERE [Id]=2";&lt;br /&gt;            command.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;            // &lt;span style="color:blue;"&gt;Delete &lt;/span&gt;a record&lt;br /&gt;            command.CommandText = "DELETE FROM T1 WHERE [Id]=1";&lt;br /&gt;            command.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    Console.WriteLine("Press enter to continue");&lt;br /&gt;    Console.ReadLine();&lt;br /&gt; }&lt;/pre&gt;After you run this application, you can verify the creation of table, insertion, modification and deletion of records by connecting to SQL Azure with the help of SQL Server Management Studio as &lt;a href="http://www.sqlservercurry.com/2009/10/sql-data-services-sds-part-ii.html"&gt;discussed in last article&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-6255491640487049772?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/z_USckhXfNc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/z_USckhXfNc/sql-data-services-sds-part-iii.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/sql-data-services-sds-part-iii.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-4129655689398900367</guid><pubDate>Thu, 08 Oct 2009 11:55:00 +0000</pubDate><atom:updated>2009-10-08T21:10:23.634-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Data Services</category><title>SQL Data Services (SDS) Part II</title><description>&lt;p&gt;In the last article, we discussed the &lt;a href="http://www.sqlservercurry.com/2009/10/sql-data-services-sds.html"&gt;&lt;strong&gt;overview of SDS&lt;/strong&gt;&lt;/a&gt; and how to start using the CTP by asking for an invitation.&lt;/p&gt;&lt;p&gt;Once you receive the invitation, you will have to go to URL &lt;a href="https://sql.azure.com/"&gt;https://sql.azure.com&lt;/a&gt; and login with your Windows Live Id where you have received the invitation. You will be shown a single project in My Projects tab with “SDS – only CTP project” and provided with ‘Manage’ as action.When you click on ‘Manage’ you will be shown Server name, Server administrator and the location for the server. You will need this information for further usage. You will observe that master database already exists. You can create a database of your choice by selecting Create Database button and enter name of the database.&lt;/p&gt;&lt;p&gt;In this article we will create our first table in the newly created database. Currently you cannot connect to SQL Azure by using SQL Server Management Studio (SSMS). This feature will be made available later. We can still make use of ‘New’ query, enter the server name and specify SQL Server authentication we created. SQL Azure only allows SQL Server authentication.&lt;/p&gt;&lt;p&gt;Make sure that you have selected the proper window for connection. Do not specify credentials in connect window for SSMS, as you will get an error similar to the one shown below&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_toA00pxrCRM/Ss624u41LvI/AAAAAAAAAIY/Mjl9rcdgnWw/s1600-h/clip_image002%5B4%5D.jpg"&gt;&lt;img title="clip_image002" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="217" alt="clip_image002" src="http://lh6.ggpht.com/_toA00pxrCRM/Ss625e_C-WI/AAAAAAAAAIc/XdGXqz66tq4/clip_image002_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Make sure you click on Options tab and specify the database you need to connect to as shown. Do not select browse on server but enter name of the database. Keep the remaining properties as default.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/Ss626DD4EkI/AAAAAAAAAIg/jcGHc1vC-0k/s1600-h/clip_image004%5B4%5D.jpg"&gt;&lt;img title="clip_image004" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="482" alt="clip_image004" src="http://lh6.ggpht.com/_toA00pxrCRM/Ss627AVD4zI/AAAAAAAAAIk/KbVWL9p50hQ/clip_image004_thumb%5B1%5D.jpg?imgmax=800" width="406" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;You will get a warning as follows&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/Ss628BlcSLI/AAAAAAAAAIo/UNKB1-EJarg/s1600-h/clip_image006%5B4%5D.jpg"&gt;&lt;img title="clip_image006" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="103" alt="clip_image006" src="http://lh3.ggpht.com/_toA00pxrCRM/Ss628-FB_wI/AAAAAAAAAIs/MtNi8R39sgk/clip_image006_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Click on OK and continue.&lt;/p&gt;&lt;p&gt;Enter first query as SELECT @@ version&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/Ss629jp-myI/AAAAAAAAAIw/5A7w7pygKUo/s1600-h/clip_image008%5B4%5D.jpg"&gt;&lt;img title="clip_image008" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="99" alt="clip_image008" src="http://lh5.ggpht.com/_toA00pxrCRM/Ss62-UFB_lI/AAAAAAAAAI0/TXfq8zvoJBw/clip_image008_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Let us create a table in the database with the name as Names and 3 columns as UserId , User Name and password. Make sure you are connected to the newly create database.&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_toA00pxrCRM/Ss62_PQtjUI/AAAAAAAAAI4/YZAO6-kN-XE/s1600-h/clip_image010%5B4%5D.jpg"&gt;&lt;img title="clip_image010" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="266" alt="clip_image010" src="http://lh4.ggpht.com/_toA00pxrCRM/Ss62_5RSkkI/AAAAAAAAAI8/lVSrcZzOaQI/clip_image010_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Add some records to the table by writing T-SQL as&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;INSERT INTO &lt;/span&gt;Names &lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;(1,’Name’,’Password’)&lt;/pre&gt;&lt;p&gt;And finally enter the query &lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;* &lt;span style="color:blue;"&gt;FROM &lt;/span&gt;Names &lt;/pre&gt;&lt;p&gt;to view the added rows.&lt;/p&gt;&lt;p&gt;In this post, we created a database, created a new table in the database, added rows to the table and even retrieved the newly added rows. In the next post, we will view and edit the table programmatically.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-4129655689398900367?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/B6V797F8Rxo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/B6V797F8Rxo/sql-data-services-sds-part-ii.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/sql-data-services-sds-part-ii.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-5678217551476100682</guid><pubDate>Tue, 06 Oct 2009 11:55:00 +0000</pubDate><atom:updated>2009-10-06T04:55:00.700-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Data Services</category><title>SQL Data Services (SDS)</title><description>&lt;p&gt;SDS is a part of Azure platform. Azure platform offers the following services: Windows Azure (Operating System in cloud), Microsoft .NET Services (set of WCF based services), SQL Azure (relational database in cloud) &lt;/p&gt;&lt;p&gt;&lt;b&gt;SQL Azure&lt;/b&gt;&lt;/p&gt;&lt;p&gt;This service provides SQL server capabilities in cloud. We can create a database which is currently in the CTP (Community Technology Preview) form. We can have all the benefits of working with SQL Server plus no hazards of doing the administration. Thus administration tasks like replication, availability will be automatically made available to us. There will be 3 copies of data maintained out of which 2 will be synchronized and the third one may lag a bit. This also leads to limiting the size of the database to 10 GB. The size limitation is for 2 reasons, one for availability (in order to replicate the data in cloud, it needs to be within limit) and the second being shared database box for multiple users (as the same box will be used for storing the data from many users. If the size of data is huge for a single user, then the box will not be scalable to other users hence limit in size)&lt;/p&gt;&lt;p&gt;When we are maintaining data in the cloud again, we have 2 options of creating applications. One in which data is near the code, which means we have application running on the same box where we have data. Another will be where data is far from the code, in which we will be always manipulating data from the cloud (in case of web based application client).&lt;/p&gt;&lt;p&gt;&lt;b&gt;How is the service provided?&lt;/b&gt;&lt;/p&gt;&lt;p&gt;The service is made available with the help of TDS (Tabular Data Stream) protocol. There are accounts available for billing purpose which will own one or more servers as per requirement. Each server will have one or more databases. These servers will use SQL Server authentication model. The databases will have one or more SQL users with respective permissions. Thus maintaining logical administration in the form of the creating views, creating triggers, tuning queries, tuning indexes etc. will be the job requirement of DBA rather than physical management in the form of how many file groups will be required, taking backup, recovery etc.&lt;/p&gt;&lt;p&gt;As of now, functionality like service broker, CLR (Common Language Runtime) functionality is not available with SDS, but will be subsequently made available.&lt;/p&gt;&lt;p&gt;&lt;b&gt;How can SDS be used?&lt;/b&gt;&lt;/p&gt;&lt;p&gt;There can be various scenarios in which this service can be used. &lt;/p&gt;&lt;p&gt;- In small organizations, IT groups for maintaining relational database may not be available.&lt;br /&gt;- In big organizations, if there is an inter department requirement for maintaining another copy of relational database, proving IT support becomes very difficult as IT staff is already overburdened.&lt;br /&gt;- For creating web applications in which maintaining SQL Server for the web application may be very costly. &lt;/p&gt;&lt;p&gt;&lt;b&gt;How can I start using SQL Azure?&lt;/b&gt;&lt;/p&gt;&lt;p&gt;You will have to register for using the current CTP over here &lt;a href="http://msdn.microsoft.com/en-us/sqlserver/dataservices/default.aspx"&gt;http://msdn.microsoft.com/en-us/sqlserver/dataservices/default.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;You will receive the invitation for using SQL Azure which can be used with your Windows Live ID.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-5678217551476100682?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/-rtl8z_NyHk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/-rtl8z_NyHk/sql-data-services-sds.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/sql-data-services-sds.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-7661431592262847922</guid><pubDate>Sun, 04 Oct 2009 11:55:00 +0000</pubDate><atom:updated>2009-10-04T11:18:09.643-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Server Administration</category><category domain="http://www.blogger.com/atom/ns#">SQL Server General</category><title>SQL Server 2008 Compliance Features – Some Resources</title><description>&lt;p&gt;Compliances are standards, regulatory requirements or organizational policies which help organizations to operate securely and efficiently. SQL Server 2008 has got a number of compliance-related features that makes compliance relatively easier. Here are some documents and videos related to the same:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=6E1021DD-65B9-41C2-8385-438028F5ACC2"&gt;Compliance Guide for SQL Server 2008&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://edge.technet.com/Media/SQL-Server-Auditing-and-Compliance/" target="_blank"&gt;SQL Server Auditing and Compliance&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/sql/experience/DecisionMakers.aspx?loc=en&amp;amp;v=http%3a%2f%2fmediadl.microsoft.com%2fmediadl%2fwww%2fs%2fsqlserver%2f2008%2fsqlvee%2fenglish%2ffordecisionmakers%2f14-English-JCCannon1.wmv"&gt;Compliance for Decision Makers Video&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/sql/experience/ITPros.aspx?loc=en&amp;amp;v=http%3a%2f%2fmschnlnine.vo.llnwd.net%2fd1%2fedge%2f3%2f6%2f6%2f1%2f15EnglishJCCannon2_edge.wmv"&gt;Compliance for IT Professionals Video&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You can get more details about it in the &lt;a href="http://www.microsoft.com/sqlserver/2008/en/us/compliance.aspx" target="_blank"&gt;SQL Server 2008 Compliance page&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-7661431592262847922?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/Sz9IG_Qc6Lw" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/Sz9IG_Qc6Lw/sql-server-2008-compliance-features.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/sql-server-2008-compliance-features.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-6939010651140792006</guid><pubDate>Fri, 02 Oct 2009 11:55:00 +0000</pubDate><atom:updated>2009-10-04T11:22:56.258-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Server Administration</category><title>Specify a Condition while Editing TOP Rows using SQL Server 2008 Management Studio (SSMS)</title><description>&lt;p&gt;I had recently posted about &lt;a href="http://www.sqlservercurry.com/2009/09/using-ssms-to-change-edit-top-rows.html"&gt;Using SSMS to change the Edit TOP Rows option&lt;/a&gt; . A user Greg commented asking me if it was possible to specify a condition while Editing the TOP Rows.&lt;/p&gt;&lt;p&gt;Here’s my observations. I am using the Purchasing.VendorContact table from the AdventureWorks database as a sample. Right click on the VendorContact table &amp;gt; Edit Top 5 rows&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_0j4bzarlOBg/SsYD5iDa7yI/AAAAAAAAAbc/cwGW5wiVeN4/s1600-h/image%5B19%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="413" alt="image" src="http://lh6.ggpht.com/_0j4bzarlOBg/SsYD7rK5Y2I/AAAAAAAAAbg/WgiyeWVIX5I/image_thumb%5B9%5D.png?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;I get the following results:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_0j4bzarlOBg/SsYD9ewkTgI/AAAAAAAAAbk/mkUFMgnZCQw/s1600-h/image%5B18%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="162" alt="image" src="http://lh4.ggpht.com/_0j4bzarlOBg/SsYD-95SdeI/AAAAAAAAAbo/0LPPHUR6yGU/image_thumb%5B8%5D.png?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;Now let us say that using SSMS, you want to Edit only those rows having ContactTypeID=2. SQL Server 2008 gives you no option out of the box to do so – at least I couldn’t find one.&lt;/p&gt;&lt;p&gt;Here’s how I solved Greg’s requirement. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Psy has shared the right way to do this. Follow these steps:&lt;/p&gt;&lt;p&gt;* Click edit top x rows. Click the "view sql pane" button (the letters SQL in a white box) from the query designer toolbar that appears in edit mode.&lt;/p&gt;&lt;p&gt;* Change the sql as needed.&lt;/p&gt;&lt;p&gt;* Click the red exclaimation mark to re-query the dataset.&lt;/p&gt;&lt;p&gt;* Edit as needed.&lt;/p&gt;&lt;p&gt;* You can also click the 'view sql pane' a 2nd time to hide it and still keep the changed query. You can also hit the execute icon as many times as needed to refresh the data.&lt;/p&gt;&lt;p&gt;The other way to handle this requirement is to Create a View! However this solution &lt;strong&gt;should be avoided&lt;/strong&gt;:&lt;/p&gt;&lt;p&gt;Right click Views &amp;gt; New View. Type the following query:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_0j4bzarlOBg/SsYD_vGKf5I/AAAAAAAAAbs/xtEnR7jYllw/s1600-h/image%5B17%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="230" alt="image" src="http://lh5.ggpht.com/_0j4bzarlOBg/SsYEA24304I/AAAAAAAAAbw/fYcttd9m0Kg/image_thumb%5B7%5D.png?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;Save this view as ‘EditVendorContact’. Now Right Click this newly created view &amp;gt; Edit Top 5 Rows&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_0j4bzarlOBg/SsYECXbyTaI/AAAAAAAAAb0/u923OorH8r8/s1600-h/image%5B16%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="352" alt="image" src="http://lh6.ggpht.com/_0j4bzarlOBg/SsYEEhlNp0I/AAAAAAAAAb4/t8r71Bn6qpg/image_thumb%5B6%5D.png?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;And here’s what you get&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_0j4bzarlOBg/SsYEFc10kWI/AAAAAAAAAb8/dcQqLsPn-jg/s1600-h/image%5B15%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="193" alt="image" src="http://lh3.ggpht.com/_0j4bzarlOBg/SsYEG8lx7cI/AAAAAAAAAcA/acvngZi3Pzs/image_thumb%5B5%5D.png?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-6939010651140792006?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/FOWKFKi-LV8" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/FOWKFKi-LV8/edit-top-rows-using-sql-server-2008.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/10/edit-top-rows-using-sql-server-2008.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-903287802936259410</guid><pubDate>Wed, 30 Sep 2009 11:55:00 +0000</pubDate><atom:updated>2009-09-30T10:02:29.148-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Server Administration</category><title>Using SSMS to change the Edit TOP Rows option</title><description>&lt;p&gt;SQL Server 2008 Management Studio has an option to Edit the Top 200 Rows. Just Right Click on the Table and you get the following options:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_0j4bzarlOBg/SsOOEndqbjI/AAAAAAAAAbM/FQ1jM1B9350/s1600-h/image%5B7%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="268" alt="image" src="http://lh4.ggpht.com/_0j4bzarlOBg/SsOOGUKHoXI/AAAAAAAAAbQ/Gv_9YC5qn0g/image_thumb%5B3%5D.png?imgmax=800" width="344" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;If your table contains many columns, opening 200 rows to edit them would be slow to execute. However not many know that this number can changed using a simple setting.&lt;/p&gt;&lt;p&gt;So let us say we want to edit only the TOP 5 Rows. A quick way to do this would be to go to Tools &amp;gt; Options &amp;gt; SQL Server Object Explorer and change the ‘Value of Edit Top &amp;lt;n&amp;gt; Rows Command to 5&lt;/p&gt;&lt;p&gt;Now when you Right Click the Table, you see the option to Edit only TOP 5 rows&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_0j4bzarlOBg/SsOOIHouzbI/AAAAAAAAAbU/IR68kxfGDqo/s1600-h/image%5B6%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="505" alt="image" src="http://lh3.ggpht.com/_0j4bzarlOBg/SsOOJ3w0e-I/AAAAAAAAAbY/s3QF2NYGj9o/image_thumb%5B2%5D.png?imgmax=800" width="344" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;A very simple tip, but known to many!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-903287802936259410?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/PxWsjam3OZ8" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/PxWsjam3OZ8/using-ssms-to-change-edit-top-rows.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/09/using-ssms-to-change-edit-top-rows.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-3318434574066117701</guid><pubDate>Mon, 28 Sep 2009 11:55:00 +0000</pubDate><atom:updated>2009-09-28T07:08:35.330-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Server Administration</category><title>Enable and Disable All the Triggers in a SQL Server Database</title><description>&lt;p&gt;A database developer recently asked on the MSDN forums for a quick way to enable and disable all the triggers in a SQL Server 2005/2008 database. In my opinion, the quickest option is to use the undocumented stored procedure &lt;a href="http://www.sqlservercurry.com/2009/04/8-common-uses-of-undocumented-stored.html"&gt;&lt;strong&gt;sp_MSforeachtable&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;To Disable All the Triggers&lt;/p&gt;&lt;pre class="code"&gt;sp_MSforeachtable "ALTER TABLE ? DISABLE TRIGGER ALL"&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;To Enable All the Triggers&lt;/p&gt;&lt;pre class="code"&gt;sp_MSforeachtable "ALTER TABLE ? ENABLE TRIGGER ALL"&lt;/pre&gt;&lt;pre class="code"&gt; &lt;/pre&gt;&lt;p&gt;Similarly to Enable and Disable all the Constraints, use this query:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:maroon;"&gt;sp_MSforeachtable &lt;/span&gt;"ALTER TABLE ? NOCHECK CONSTRAINT ALL"&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color:maroon;"&gt;sp_MSforeachtable &lt;/span&gt;"ALTER TABLE ? WITH CHECK CHECK CONSTRAINT ALL"&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-3318434574066117701?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/MIQG2cp1d4E" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/MIQG2cp1d4E/enable-and-disable-all-triggers-in-sql.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/09/enable-and-disable-all-triggers-in-sql.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-7541526260627010853</guid><pubDate>Sat, 26 Sep 2009 11:55:00 +0000</pubDate><atom:updated>2009-09-26T11:33:07.392-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Transact SQL T-SQL</category><category domain="http://www.blogger.com/atom/ns#">SQL Server Administration</category><title>List All Tables and Views with the XML Data Type in SQL Server 2005/2008</title><description>&lt;p&gt;Here’s a simple way of listing all tables and Views with the XML datatype using the &lt;a href="http://msdn.microsoft.com/en-us/library/ms186778.aspx"&gt;INFORMATION_SCHEMA&lt;/a&gt; views.&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;SELECT DISTINCT &lt;/span&gt;col.TABLE_NAME, col.COLUMN_NAME, col.DATA_TYPE  &lt;br /&gt;&lt;span style="color:blue;"&gt;FROM &lt;/span&gt;INFORMATION_SCHEMA.COLUMNS &lt;span style="color:blue;"&gt;as &lt;/span&gt;col&lt;br /&gt;&lt;span style="color:blue;"&gt;WHERE &lt;/span&gt;col.DATA_TYPE = &lt;span style="color:#a31515;"&gt;'xml'&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;As given in the Books Online “&lt;em&gt;Information schema views provide an internal, system table-independent view of the SQL Server metadata. Information schema views enable applications to work correctly although significant changes have been made to the underlying system tables. The information schema views included in SQL Server comply with the ISO standard definition for the INFORMATION_SCHEMA.”&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;OUTPUT&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_0j4bzarlOBg/Sr5dWk_QqLI/AAAAAAAAAa8/eHMEvImynsI/s1600-h/image%5B3%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="209" alt="image" src="http://lh4.ggpht.com/_0j4bzarlOBg/Sr5dXmajgII/AAAAAAAAAbA/0e7pd1KKGRI/image_thumb%5B1%5D.png?imgmax=800" width="344" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-7541526260627010853?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/Tbi8ijq45aU" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/Tbi8ijq45aU/list-all-tables-and-views-with-xml-data.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/09/list-all-tables-and-views-with-xml-data.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-2662619259997805702</guid><pubDate>Thu, 24 Sep 2009 11:55:00 +0000</pubDate><atom:updated>2009-09-24T04:55:00.102-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Reporting Services SSRS</category><title>Working With Report Model in SSRS – Part III</title><description>&lt;p&gt;&lt;/p&gt;&lt;p&gt;In last 2 articles &lt;a href="http://www.sqlservercurry.com/2009/09/working-with-report-models-in-ssrs.html"&gt;Working with Report Model Part I&lt;/a&gt; and &lt;a href="http://www.sqlservercurry.com/2009/09/working-with-report-model-in-ssrs-part.html"&gt;Working with Report Model Part II&lt;/a&gt;, we discussed overview of report model and how to create report model with the help of designer. In this article, we will create Report with Report Builder 2.0 based on the Report Model created in the previous article (Working with Report Model Part II)&lt;/p&gt;&lt;p&gt;Report Builder 2.0 can be downloaded from &lt;b&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9f783224-9871-4eea-b1d5-f3140a253db6&amp;amp;displaylang=en"&gt;here&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;1. For working with Report Builder 2.0 go to Start &amp;gt; All Programs &amp;gt; Microsoft SQL Server 2008 &amp;gt; Report Builder 2.0&lt;/p&gt;&lt;p&gt;2. Create a New Report &amp;gt; Select table or matrix report &amp;gt; the connection to data source screen will be shown. Click on Browse (ensure you have given proper URL for report server) &amp;gt; in select data source it displays folders for models &amp;gt; Select “Report Model Demo” &amp;gt; click on Next.&lt;/p&gt;&lt;p&gt;3. A Design query screen will be provided as follows:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_toA00pxrCRM/SrSx3HkEdFI/AAAAAAAAAIA/Aj9BYXjfz8s/s1600-h/image%5B15%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="333" alt="image" src="http://lh5.ggpht.com/_toA00pxrCRM/SrSx4WFXoLI/AAAAAAAAAIE/WlZltHyY51w/image_thumb%5B7%5D.png?imgmax=800" width="484" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;4. Under Entities, if you double click on ‘Customer’, all the entities will be automatically added to drag and column fields area. But we will not be working with only Customer.&lt;/p&gt;&lt;p&gt;5. Select Product from entities; double click “English Product Name” from fields. You will see that once we select Product, only related entities to Product are displayed in entities. Select Product SubCategory and double click on “English Product Subcategory Name” so as to get selected. Select Product Category and double click on “English Product Category Name”.&lt;/p&gt;&lt;p&gt;6. Select Internet Sales from entities. Double click on “Total Unit Price” and “Total Unit Quantity”.&lt;/p&gt;&lt;p&gt;7. Select Order Date from entities. Double click on “Calendar Quarter Desc”, “Calendar Year Desc” and “Month Name” and click on Next.&lt;/p&gt;&lt;p&gt;8. Drag and drop the fields so that the screen looks as follows:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/SrSx5-rXbqI/AAAAAAAAAII/gNQO6l8u6QY/s1600-h/image%5B16%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="356" alt="image" src="http://lh5.ggpht.com/_toA00pxrCRM/SrSx7CkcJ8I/AAAAAAAAAIM/TSB5Y1sSI3w/image_thumb%5B8%5D.png?imgmax=800" width="484" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;and click on Next.&lt;/p&gt;&lt;p&gt;9. Keep the default settings for Choose the layout screen and click Next.&lt;/p&gt;&lt;p&gt;10. Select the required style and click Finish.&lt;/p&gt;&lt;p&gt;11. After doing certain changes like changing names of some columns, providing format for Unit Price the report looks as follows:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_toA00pxrCRM/SrSx8xurzLI/AAAAAAAAAIQ/0kwFtZIxQls/s1600-h/image%5B17%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="364" alt="image" src="http://lh5.ggpht.com/_toA00pxrCRM/SrSx-vGGc6I/AAAAAAAAAIU/k_FcJQ8hICE/image_thumb%5B9%5D.png?imgmax=800" width="484" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;And there you have your first report created using a custom Report Model in Report Builder 2.0&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-2662619259997805702?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/aPSTQdRtQF8" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/aPSTQdRtQF8/working-with-report-model-in-ssrs-part_24.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/09/working-with-report-model-in-ssrs-part_24.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-5613227502106707565</guid><pubDate>Tue, 22 Sep 2009 11:55:00 +0000</pubDate><atom:updated>2009-09-22T04:55:00.694-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Reporting Services SSRS</category><title>Working with Report Model in SSRS - Part II</title><description>&lt;p&gt;&lt;b&gt;Creating Report Model using BIDS (Business Intelligence Development Studio)&lt;/b&gt;&lt;/p&gt;&lt;p&gt;In Part 1 of this series, &lt;a href="http://www.sqlservercurry.com/2009/09/working-with-report-models-in-ssrs.html"&gt;Working With Report Model in SSRS – Overview - Part 1&lt;/a&gt;, we discussed the Report Model, the items in Report Model and its uses. Let us now see how a Report Model can be created with the Report Model Designer. Report Model Project is provided as a template with BIDS. With this tool you can do certain customizations to the Report Model items as required.&lt;/p&gt;&lt;p&gt;1. Select Report Model Project template and give it a name - “Report Model Demo”&lt;/p&gt;&lt;p&gt;2. Create a Data Source named “Adventure works DW 2008” pointing to AdventureWorksDW2008 database. It can be downloaded from following link &lt;a href="http://msftdbprodsamples.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=18407"&gt;http://msftdbprodsamples.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=18407&lt;/a&gt;&lt;/p&gt;&lt;p&gt;3. Create a Data Source View (DSV) with following tables &lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_toA00pxrCRM/SrSs01aijCI/AAAAAAAAAHw/TYwZPAFhwnI/s1600-h/clip_image002%5B4%5D.jpg"&gt;&lt;img title="clip_image002" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="398" alt="clip_image002" src="http://lh4.ggpht.com/_toA00pxrCRM/SrSs138MaBI/AAAAAAAAAH0/dgMEwmUuYtw/clip_image002_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;namely “Adventure Works DW2008”&lt;/p&gt;&lt;p&gt;4. Before creating model let us do the following changes to DSV. Change the friendly names of the tables so that they look as follows: &lt;/p&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_toA00pxrCRM/SrSs3XPDvMI/AAAAAAAAAH4/1vBl8hnMkmM/s1600-h/clip_image004%5B4%5D.jpg"&gt;&lt;img title="clip_image004" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="226" alt="clip_image004" src="http://lh6.ggpht.com/_toA00pxrCRM/SrSs4fcwn1I/AAAAAAAAAH8/qDaQ99kSSiw/clip_image004_thumb%5B1%5D.jpg?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;5. Add 3 calculated fields as follows :&lt;/p&gt;&lt;p&gt;- Calendar Quarter Description: 'Q' + CONVERT(CHAR (1), CalendarQuarter) +' '+ 'CY ' +&lt;br /&gt;CONVERT(CHAR (4), CalendarYear)&lt;br /&gt;- Calendar year description: 'CY '+ CONVERT(CHAR (4), CalendarYear)&lt;br /&gt;- MonthName: EnglishMonthName+' '+ CONVERT(CHAR (4), CalendarYear)&lt;/p&gt;&lt;p&gt;6. In the solution explorer, right click on Report Model and select Add New Report Model which will start the wizard for model creation. It is based on the DSV created in the last step.&lt;/p&gt;&lt;p&gt;7. Keep default settings for Report Model Creation Rules, Collect Model Statistics, name for the model and click on Run and finally Finish.&lt;/p&gt;&lt;p&gt;8. Remove attributes such as Spanish Education, French Education, Spanish Occupation, French Occupation from Customer entity. You will observe that Internet Sales and Geography are added to this entity as Roles. If you select properties for any one you will see the foreign key relationship between the two specified in Bindings. Similarly you can remove descriptions from Product. &lt;/p&gt;&lt;p&gt;9. You can also remove attributes from Total Children like avg, min and max. You can change the alignment of numeric fields to Right.&lt;/p&gt;&lt;p&gt;10. Right click on “Report Model Demo” in the solution explorer and select properties. Check if the TargetServerURL is correct. &lt;/p&gt;&lt;p&gt;In case of a named instance of SQL Server, it should be &lt;em&gt;http://&amp;lt;machine name&amp;gt;/ReportServer_&amp;lt;instance name&amp;gt;&lt;/em&gt;. &lt;/p&gt;&lt;p&gt;If the port number is other than 80 it should also be included as follows &lt;em&gt;http://&amp;lt;machine name&amp;gt;:8080/ReportServer_&amp;lt;instance name&amp;gt;&lt;/em&gt;. Machine name can be replaced by localhost.&lt;/p&gt;&lt;p&gt;11. Deploy this Report Model&lt;/p&gt;&lt;p&gt;12. Start Report Manager by giving the URL. In case of named instance of SQL Server it should be &lt;em&gt;http://&amp;lt;machine name&amp;gt;/Reports_&amp;lt; instance name&amp;gt;&lt;/em&gt; and verify that the newly created model is available in Models Folder. After installing Report Builder we can specify the report builder setting within which report server URL can be provided.&lt;/p&gt;&lt;p&gt;In next article we will discuss how to create a report using this report model with the help of Report Builder 2.0&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-5613227502106707565?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/H8YaPdDcXx4" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/H8YaPdDcXx4/working-with-report-model-in-ssrs-part.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/09/working-with-report-model-in-ssrs-part.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-495177919198719500.post-5183699449505042720</guid><pubDate>Sun, 20 Sep 2009 11:55:00 +0000</pubDate><atom:updated>2009-09-20T04:55:00.062-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Reporting Services SSRS</category><title>Working with Report Models in SSRS - Overview – Part I</title><description>&lt;p&gt;When we are creating reports with the help of SSRS (SQL Server Reporting Services) using BIDS (Business Intelligence Development Studio), we are dealing with predefined report formats. Sometimes it is required to create certain reports on the fly. We do not have a set format for these reports. These report formats are required to be created as and when required by the client. For this reason, a very important feature has been provided called ‘Report Builder’ in SSRS. With the help of Report Builder, ad-hoc reports can be created. These reports are based on Report Models.&lt;/p&gt;&lt;p&gt;Business users who want to create reports on demand may not be familiar with the physical data source schemas of the databases. Report Model provides user friendly and easy to understand entities based on which report creation becomes easy. These people may also not be familiar with the designer for creating reports.&lt;/p&gt;&lt;p&gt;Report Model thus becomes a prerequisite of Report Builder, when working with Report Builder 1.0. However with &lt;a href="http://www.microsoft.com/sqlserver/2008/en/us/report-builder.aspx"&gt;Report Builder 2.0&lt;/a&gt;, it is no more a prerequisite, as we can create ad-hoc reports without Report Models created previously. A report model contains metadata of data source and the relationships within. This metadata is in the form of SMDL (Semantic Model Definition Language). This is an XML based way of presenting model items. Models can be created with Report Model Template provided by BIDS. Models can also be created with Report Manager or Microsoft Office SharePoint Server 2007, but using BIDS provides maximum flexibility. You can base the model on Analysis Services cube if required. If we change the cube later, we need to regenerate the model. Report Model on Analysis Services cube cannot be created using designer. &lt;/p&gt;&lt;p&gt;Report Models comprise of following components&lt;/p&gt;&lt;p&gt;1. Entities: similar to objects in tables (entities have attributes and roles)&lt;/p&gt;&lt;p&gt;2. Attributes : similar to columns in tables&lt;/p&gt;&lt;p&gt;3. Roles: specifies relation between entities&lt;/p&gt;&lt;p&gt;4. Folders: used to organize entities and perspectives, certain model items can be grouped&lt;/p&gt;&lt;p&gt;5. Perspectives: subset of model, useful when models are very large, perspectives in themselves can contain entities, roles, folders etc.&lt;/p&gt;&lt;p&gt;In next article we will discuss how a model can be created using BIDS.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/495177919198719500-5183699449505042720?l=www.sqlservercurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sqlservercurry/blog/~4/hiCCtXm-eDE" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/sqlservercurry/blog/~3/hiCCtXm-eDE/working-with-report-models-in-ssrs.html</link><author>noreply@blogger.com (Gouri Sohoni)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.sqlservercurry.com/2009/09/working-with-report-models-in-ssrs.html</feedburner:origLink></item></channel></rss>
