<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9205551643478578590</id><updated>2024-11-01T02:10:16.398-07:00</updated><category term="T-SQL"/><category term="MDX"/><category term="SSAS"/><category term="Python"/><category term="Redshift"/><category term="SSRS"/><category term="ASP.NET"/><category term="Data Model"/><category term="Django"/><title type='text'>Mahadevan Business Intelligence</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>60</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-8741989875222188665</id><published>2017-02-22T08:20:00.001-08:00</published><updated>2017-03-18T08:18:01.800-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Django"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Django migrate Sqllite to Mysql</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Steps to migrate Django Sqllite DB to MySql DB&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;
1. python manage.py dumpdata &amp;nbsp;-o datadump.json&lt;br /&gt;
2. Change settings.py to your mysql&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-color: white; font-family: &amp;quot;Courier New&amp;quot;; font-size: 9pt;&quot;&gt;DATABASES = {
    &lt;span style=&quot;color: teal; font-size: 9pt; font-weight: bold;&quot;&gt;&#39;default&#39;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;: {&lt;/span&gt;
        &lt;span style=&quot;color: teal; font-size: 9pt; font-weight: bold;&quot;&gt;&#39;ENGINE&#39;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: teal; font-size: 9pt; font-weight: bold;&quot;&gt;&#39;django.db.backends.mysql&#39;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;,&lt;/span&gt;
        &lt;span style=&quot;color: teal; font-size: 9pt; font-weight: bold;&quot;&gt;&#39;NAME&#39;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: teal; font-size: 9pt; font-weight: bold;&quot;&gt;&#39;database&#39;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;,&lt;/span&gt;
        &lt;span style=&quot;color: teal; font-size: 9pt; font-weight: bold;&quot;&gt;&#39;USER&#39;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: teal; font-size: 9pt; font-weight: bold;&quot;&gt;&#39;username&#39;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;,&lt;/span&gt;
        &lt;span style=&quot;color: teal; font-size: 9pt; font-weight: bold;&quot;&gt;&#39;PASSWORD&#39;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: teal; font-size: 9pt; font-weight: bold;&quot;&gt;&#39;password&#39;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;,&lt;/span&gt;
        &lt;span style=&quot;color: teal; font-size: 9pt; font-weight: bold;&quot;&gt;&#39;HOST&#39;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: teal; font-size: 9pt; font-weight: bold;&quot;&gt;&#39;localhost&#39;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;,   &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: 9pt; font-style: italic;&quot;&gt;# Or an IP Address that your DB is hosted on&lt;/span&gt;
        &lt;span style=&quot;color: teal; font-size: 9pt; font-weight: bold;&quot;&gt;&#39;PORT&#39;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: teal; font-size: 9pt; font-weight: bold;&quot;&gt;&#39;3306&#39;&lt;/span&gt;&lt;span style=&quot;font-size: 9pt;&quot;&gt;,&lt;/span&gt;
    }
}&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #242729; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #242729; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;3. Check you have mysqlclient, else run below command:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #242729; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #242729; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #242729; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;inconsolata&amp;quot; , monospace , sans-serif; white-space: pre-wrap;&quot;&gt;apt-get install python-dev libmysqlclient-dev&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #242729; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pip install mysqlclient&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #242729; font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #242729; font-family: &amp;quot;consolas&amp;quot; , &amp;quot;menlo&amp;quot; , &amp;quot;monaco&amp;quot; , &amp;quot;lucida console&amp;quot; , &amp;quot;liberation mono&amp;quot; , &amp;quot;dejavu sans mono&amp;quot; , &amp;quot;bitstream vera sans mono&amp;quot; , &amp;quot;courier new&amp;quot; , monospace , sans-serif; white-space: pre-wrap;&quot;&gt;4. python manage.py migrate --run-syncdb&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #242729; font-family: &amp;quot;consolas&amp;quot; , &amp;quot;menlo&amp;quot; , &amp;quot;monaco&amp;quot; , &amp;quot;lucida console&amp;quot; , &amp;quot;liberation mono&amp;quot; , &amp;quot;dejavu sans mono&amp;quot; , &amp;quot;bitstream vera sans mono&amp;quot; , &amp;quot;courier new&amp;quot; , monospace , sans-serif; white-space: pre-wrap;&quot;&gt;5. python manage.py loaddata datadump.json&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/8741989875222188665/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2017/02/django-migrate-sqllite-to-mysql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/8741989875222188665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/8741989875222188665'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2017/02/django-migrate-sqllite-to-mysql.html' title='Django migrate Sqllite to Mysql'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-7810644186002972321</id><published>2016-08-23T02:07:00.002-07:00</published><updated>2017-02-22T08:22:05.003-08:00</updated><title type='text'>Google BigQuery - Calculating Minutes and Hours Differences</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Assume you have a date column &quot;OrderedDate&quot;, then we can calculate the total difference in minute and hour with respect to current date time:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;(CURRENT_TIMESTAMP() - TIMESTAMP_TO_USEC(OrderedDate)) / 1000000/ 3600 AS Diff_Hour,&lt;br /&gt;&amp;nbsp;(CURRENT_TIMESTAMP() - TIMESTAMP_TO_USEC(OrderedDate)) / 1000000/ 60 AS Diff_Minute&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;FROM [Project:Dataset.Table]&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/7810644186002972321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2016/08/google-bigquery-calculating-minutes-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/7810644186002972321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/7810644186002972321'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2016/08/google-bigquery-calculating-minutes-and.html' title='Google BigQuery - Calculating Minutes and Hours Differences'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-6356710544651345079</id><published>2015-03-26T00:43:00.002-07:00</published><updated>2017-02-22T08:22:05.000-08:00</updated><title type='text'>General Copy Command to load S3 file data to Redshift</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
General Copy Command to load S3 file data to Redshift table:&lt;br /&gt;
COPY &amp;lt;tablename&amp;gt; from &#39;s3://bucket/folder/file.txt&#39; &lt;br /&gt;CREDENTIALS &#39;aws_access_key_id=**********;aws_secret_access_key=*********&#39;&lt;br /&gt;DELIMITER&amp;nbsp;&amp;nbsp; &#39;|&#39; IGNOREHEADER 1;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/6356710544651345079/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2015/03/general-copy-command-to-load-s3-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/6356710544651345079'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/6356710544651345079'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2015/03/general-copy-command-to-load-s3-file.html' title='General Copy Command to load S3 file data to Redshift'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-7687889385578682110</id><published>2015-03-26T00:42:00.002-07:00</published><updated>2015-03-26T00:42:42.334-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Redshift"/><title type='text'>AWS Redshift: &#39;String contains invalid or unsupported UTF8 codepoints. Bad UTF8 hex sequence: b6 </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
When you receive below error message from AWS redshift while executing 
use copy command then use &#39;ACCEPTINVCHARS ESCAPE&#39; syntax in copy 
command:&lt;br /&gt;
&lt;br /&gt;
Error Code: &#39;String contains invalid or unsupported UTF8 codepoints. Bad UTF8 hex sequence: b6 (error 3) &#39;&lt;br /&gt;
&lt;br /&gt;
COPY &amp;lt;tablename&amp;gt; from &#39;s3://bucket/folder/file.txt&#39; &lt;br /&gt;
CREDENTIALS &#39;**********;aws_secret_access_key=******&#39;&lt;br /&gt;
DELIMITER&amp;nbsp;&amp;nbsp; &#39;|&#39; ACCEPTINVCHARS ESCAPE IGNOREHEADER 1;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/7687889385578682110/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2015/03/aws-redshift-string-contains-invalid-or.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/7687889385578682110'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/7687889385578682110'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2015/03/aws-redshift-string-contains-invalid-or.html' title='AWS Redshift: &#39;String contains invalid or unsupported UTF8 codepoints. Bad UTF8 hex sequence: b6 '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-2899370749042171848</id><published>2015-03-26T00:38:00.001-07:00</published><updated>2015-03-26T00:38:43.894-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Redshift"/><title type='text'>AWS String contains invalid or unsupported UTF8 codepoints. Bad UTF8 hex sequence: b6 </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
When you receive below error message from AWS redshift while executing use copy command then use &#39;ACCEPTINVCHARS ESCAPE&#39; syntax in copy command:&lt;br /&gt;
&lt;br /&gt;
Error Code: &#39;String contains invalid or unsupported UTF8 codepoints. Bad UTF8 hex sequence: b6 (error 3) &#39;&lt;br /&gt;
&lt;br /&gt;
COPY &amp;lt;tablename&amp;gt; from &#39;s3://bucket/folder/file.txt&#39; &lt;br /&gt;
CREDENTIALS &#39;**********;aws_secret_access_key=******&#39;&lt;br /&gt;
DELIMITER&amp;nbsp;&amp;nbsp; &#39;|&#39; ACCEPTINVCHARS ESCAPE IGNOREHEADER 1;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/2899370749042171848/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2015/03/aws-string-contains-invalid-or.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/2899370749042171848'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/2899370749042171848'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2015/03/aws-string-contains-invalid-or.html' title='AWS String contains invalid or unsupported UTF8 codepoints. Bad UTF8 hex sequence: b6 '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-1870298731346836383</id><published>2015-03-26T00:31:00.001-07:00</published><updated>2015-03-26T00:31:35.770-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Redshift"/><title type='text'>General COPY command to load data from S3 file</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
General Copy Command trom to load S3 file data to Redshift table:&lt;br /&gt;
COPY &amp;lt;tablename&amp;gt; from &#39;s3://bucket/folder/file.txt&#39; &lt;br /&gt;CREDENTIALS &#39;aws_access_key_id=**********;aws_secret_access_key=*********&#39;&lt;br /&gt;DELIMITER&amp;nbsp;&amp;nbsp; &#39;|&#39; IGNOREHEADER 1;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/1870298731346836383/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2015/03/general-copy-command-to-load-data-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/1870298731346836383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/1870298731346836383'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2015/03/general-copy-command-to-load-data-from.html' title='General COPY command to load data from S3 file'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-9067387171094339697</id><published>2015-02-16T07:23:00.002-08:00</published><updated>2015-02-16T07:23:22.952-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>PYODBC Connection in Python</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Creating ODBC Connection in Python&lt;br /&gt;
&lt;br /&gt;
STEP 1: Installing pypyodbc can be done via the commandline:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt;C:\Python34\Scripts&amp;gt;pip install pypyodbc&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
Using the below command in your code for better naming conventions:&lt;br /&gt;&lt;br /&gt;&amp;gt;&amp;gt; import pypyodbc as pyodbc&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/9067387171094339697/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2015/02/pyodbc-connection-in-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/9067387171094339697'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/9067387171094339697'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2015/02/pyodbc-connection-in-python.html' title='PYODBC Connection in Python'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-9026588210708051021</id><published>2015-02-16T07:19:00.000-08:00</published><updated>2015-02-16T07:19:07.097-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Python Script to Connect to SQL Server and Retrieve Date From a Table</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
# Python Script to Connect to SQL Server and Retrieve Date From a Table &lt;br /&gt;
&lt;br /&gt;
import sys&lt;br /&gt;import pypyodbc&lt;br /&gt;&lt;br /&gt;# Create a new database:&lt;br /&gt;connection_str =&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;&quot;&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Driver={SQL Server Native Client 11.0};&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Server=localhost;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Database=master;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Trusted_Connection=yes;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;&quot;&quot;&lt;br /&gt;db_connection = pypyodbc.connect(connection_str)&lt;br /&gt;db_connection.autocommit = True&lt;br /&gt;db_cursor = db_connection.cursor()&lt;br /&gt;sql_command =&amp;nbsp;&amp;nbsp; &quot;&quot;&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREATE DATABASE MYDB&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;&quot;&quot;&lt;br /&gt;try:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; db_cursor.execute(sql_command)&lt;br /&gt;except pypyodbc.ProgrammingError:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(&quot;Database &#39;MYDB&#39; already exists.&quot;)&lt;br /&gt;db_connection.autocommit = False&lt;br /&gt;&lt;br /&gt;db_cursor.close()&lt;br /&gt;del db_cursor&lt;br /&gt;db_connection.close()&lt;br /&gt;&lt;br /&gt;# Connect a database.&lt;br /&gt;connection_str =&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;&quot;&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Driver={SQL Server Native Client 11.0};&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Server=Localhost;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Database=MYDB;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Trusted_Connection=yes;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;&quot;&quot;&lt;br /&gt;db_connection = pypyodbc.connect(connection_str)&lt;br /&gt;db_connection.autocommit = True&lt;br /&gt;db_connection.autocommit = False&lt;br /&gt;db_cursor = db_connection.cursor()&lt;br /&gt;&lt;br /&gt;# Select rows from a table:&lt;br /&gt;# 1) Select all columns of all rows:&lt;br /&gt;sql_command =&amp;nbsp;&amp;nbsp; &quot;&quot;&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT *&amp;nbsp; FROM [ods].[MYTABLE]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;&quot;&quot;&lt;br /&gt;db_cursor.execute(sql_command)&lt;br /&gt;rows = db_cursor.fetchall()&lt;br /&gt;for row in rows:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; userid, fname= row[0] ,row[1]&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Now print fetched result&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print (userid,fname)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/9026588210708051021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2015/02/python-script-to-connect-to-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/9026588210708051021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/9026588210708051021'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2015/02/python-script-to-connect-to-sql-server.html' title='Python Script to Connect to SQL Server and Retrieve Date From a Table'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-1819969269967255063</id><published>2014-11-04T04:11:00.002-08:00</published><updated>2017-02-22T08:22:04.993-08:00</updated><title type='text'>SQL CLR Error: Publishing SQL Server Project from C# Visual Studio</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Created new SQL Server project in Visual studio, to generate dll file having SQL function, when we tried to use published function we ended with below error message:&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Execution of user code in the .NET Framework is disabled. Enable &quot;clr enabled&quot; configuration option.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
To fix the above issue enable CLR in sql server:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;sp_configure &#39;show advanced options&#39;, 1;&lt;br /&gt;GO&lt;br /&gt;RECONFIGURE;&lt;br /&gt;GO&lt;br /&gt;sp_configure &#39;clr enabled&#39;, 1;&lt;br /&gt;GO&lt;br /&gt;RECONFIGURE;&lt;br /&gt;GO&lt;br /&gt;
&lt;br /&gt;
After applying the code we tried to execute the created function, but ended in below error:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;A .NET Framework error occurred during execution of user-defined routine or aggregate &quot;&amp;lt;functionname&amp;gt;&quot;: &lt;br /&gt;System.Security.HostProtectionException: Attempted to perform an operation that was forbidden by the CLR host.&lt;br /&gt;&lt;br /&gt;The protected resources (only available with full trust) were: All&lt;br /&gt;The demanded resources were: MayLeakOnAbort&lt;br /&gt;&lt;br /&gt;System.Security.HostProtectionException: &lt;br /&gt;&amp;nbsp;&amp;nbsp; at UserDefinedFunctions.&amp;lt;functionname&amp;gt;(SqlDateTime pstTime, String Timezone)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
To overcome the above issue, run below commands:&lt;br /&gt;
&lt;br /&gt;
ALTER ASSEMBLY &amp;lt;functionname&amp;gt; WITH PERMISSION_SET = Safe&lt;br /&gt;&lt;br /&gt;ALTER DATABASE &amp;lt;DBNAME&amp;gt;&lt;br /&gt;SET TRUSTWORTHY ON&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ALTER ASSEMBLY Timezone WITH PERMISSION_SET = UnSafe&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/1819969269967255063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2014/11/sql-clr-error-publishing-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/1819969269967255063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/1819969269967255063'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2014/11/sql-clr-error-publishing-sql-server.html' title='SQL CLR Error: Publishing SQL Server Project from C# Visual Studio'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-6472969938171369968</id><published>2013-11-25T21:59:00.001-08:00</published><updated>2013-11-25T21:59:51.250-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL"/><title type='text'>Convert Unix Timestamp to Date Format</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
SELECT&amp;nbsp; DATE_FORMAT(FROM_UNIXTIME(TimeStamp), &#39;%d-%m-%Y %h:%i:%s&#39;) AS LogDate &lt;br /&gt;FROM dbo.reportlog&lt;br /&gt;ORDER BY Timestamp DESC&lt;br /&gt;LIMIT 10&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/6472969938171369968/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2013/11/convert-unix-timestamp-to-date-format.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/6472969938171369968'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/6472969938171369968'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2013/11/convert-unix-timestamp-to-date-format.html' title='Convert Unix Timestamp to Date Format'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-2567357743624662979</id><published>2013-08-23T11:22:00.002-07:00</published><updated>2013-08-23T11:22:45.014-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL"/><title type='text'>T-SQL to Diable all Jobs in SQL Agent</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
USE MSDB;&lt;br /&gt;GO&lt;br /&gt;UPDATE MSDB.dbo.sysjobs&lt;br /&gt;SET Enabled = 0&lt;br /&gt;WHERE Enabled = 1;&lt;br /&gt;GO&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/2567357743624662979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2013/08/t-sql-to-diable-all-jobs-in-sql-agent.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/2567357743624662979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/2567357743624662979'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2013/08/t-sql-to-diable-all-jobs-in-sql-agent.html' title='T-SQL to Diable all Jobs in SQL Agent'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-3355176092731363173</id><published>2012-10-16T02:44:00.000-07:00</published><updated>2017-02-22T08:22:04.996-08:00</updated><title type='text'>ODBC Connectivity Issue -  Missing System DSN connection in SSIS</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
We often come across this issue when our working server and source server have different bits 32 or 64.&lt;br /&gt;
&lt;br /&gt;
You might have created System DSN in your system, but when try to create connection manager, the DSN will be missing in ODBC list. To overcome this you need to create DSN connection in appropriate ODBC (32/64).&lt;br /&gt;
&lt;br /&gt;
Perform the followings:&lt;br /&gt;
&lt;br /&gt;
Open command window:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Navigate to C:\Windows\Sysos64\Odbacd32.exe&lt;br /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaWrU1YCL4-7voxeUFAgxJkU306njd_oiH42e_MWFQTC1_mtv-idDmiUC34CbTm_bsaMqDxZeghYP6T6XB9pclcpCSYghMJ1G3AwSTTap3Y9F7O0XwF6BMo1PChCL__lUPL4RIRmAxwnE/s1600/ODBCErr_fix.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaWrU1YCL4-7voxeUFAgxJkU306njd_oiH42e_MWFQTC1_mtv-idDmiUC34CbTm_bsaMqDxZeghYP6T6XB9pclcpCSYghMJ1G3AwSTTap3Y9F7O0XwF6BMo1PChCL__lUPL4RIRmAxwnE/s400/ODBCErr_fix.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. ODBC Connection wizard will appear.&lt;br /&gt;
3. Create a new system DSN there.&lt;br /&gt;
4. Now try creating Connection Manager in SSIS package&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/3355176092731363173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2012/10/odbc-connectivity-issue-missing-system.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/3355176092731363173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/3355176092731363173'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2012/10/odbc-connectivity-issue-missing-system.html' title='ODBC Connectivity Issue -  Missing System DSN connection in SSIS'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaWrU1YCL4-7voxeUFAgxJkU306njd_oiH42e_MWFQTC1_mtv-idDmiUC34CbTm_bsaMqDxZeghYP6T6XB9pclcpCSYghMJ1G3AwSTTap3Y9F7O0XwF6BMo1PChCL__lUPL4RIRmAxwnE/s72-c/ODBCErr_fix.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-7980650935983936945</id><published>2012-09-27T00:15:00.003-07:00</published><updated>2012-09-27T00:15:46.032-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL"/><title type='text'> Attach MDF file to a Database</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Below is the query to attach MDF file to a database:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;DATABASE&lt;/span&gt; AdventureWorks2008DWR2 &lt;span style=&quot;color: blue;&quot;&gt;ON&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;FILENAME&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;N&#39;C:\Users\mvaradhan\Downloads\AdventureWorksDW2008R2.mdf&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;FOR&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;ATTACH&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; line-height: 115%; mso-no-proof: yes;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/7980650935983936945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2012/09/attach-mdf-file-to-database_27.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/7980650935983936945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/7980650935983936945'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2012/09/attach-mdf-file-to-database_27.html' title=' Attach MDF file to a Database'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-1752349320971258969</id><published>2012-09-27T00:12:00.001-07:00</published><updated>2012-09-27T00:12:49.260-07:00</updated><title type='text'>Attaching MDF file to a Database</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Below is the query to attach mdf file to a database:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;DATABASE&lt;/span&gt; AdventureWorks2008DWR2 &lt;span style=&quot;color: blue;&quot;&gt;ON&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;FILENAME&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;N&#39;C:\Users\mvaradhan\Downloads\AdventureWorksDW2008R2.mdf&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;FOR&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;ATTACH&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; line-height: 115%; mso-no-proof: yes;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/1752349320971258969/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2012/09/attaching-mdf-file-to-database_27.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/1752349320971258969'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/1752349320971258969'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2012/09/attaching-mdf-file-to-database_27.html' title='Attaching MDF file to a Database'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-1064113600526406823</id><published>2012-09-26T23:47:00.001-07:00</published><updated>2012-09-27T00:13:17.646-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL"/><title type='text'>Attaching .MDF file to a Database</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Below is the script to attach AdventureWorks.mdf file to a newly created database:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;DATABASE&lt;/span&gt; AdventureWorks2008DWR2 &lt;span style=&quot;color: blue;&quot;&gt;ON&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;FILENAME&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;N&#39;C:\Users\mvaradhan\Downloads\AdventureWorksDW2008R2.mdf&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;FOR&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;ATTACH&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; line-height: 115%; mso-no-proof: yes;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/1064113600526406823/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2012/09/attaching-mdf-file-to-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/1064113600526406823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/1064113600526406823'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2012/09/attaching-mdf-file-to-database.html' title='Attaching .MDF file to a Database'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-3863209251393952583</id><published>2012-06-27T01:31:00.001-07:00</published><updated>2012-06-27T02:19:47.085-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="SSRS"/><title type='text'>Call SSRS Report in ASP .NET with Parameters</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
The below steps help to call an SSRS report in Web Page designed using ASP.NET. The practice the below code we should install AJAX toolkit.&lt;br /&gt;
&lt;br /&gt;
1. Create anew ASP wep page project.&lt;br /&gt;
2. Add a new web form.&lt;br /&gt;
3. Add th ebelow scripts in the WEB for designer:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;SSRS2.aspx.cs&quot; Inherits=&quot;SSRS_WEB.WebForm2&quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;%@ Register assembly=&quot;Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot; namespace=&quot;Microsoft.Reporting.WebForms&quot; tagprefix=&quot;rsweb&quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;%@ Register Assembly=&quot;AjaxControlToolkit&quot; Namespace=&quot;AjaxControlToolkit&quot; TagPrefix=&quot;asp&quot; %&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;&lt;/span&gt;&lt;a href=&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;html xmlns=&quot;&lt;/span&gt;&lt;a href=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;http://www.w3.org/1999/xhtml&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;&amp;gt;&lt;br /&gt;&amp;lt;head runat=&quot;server&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;form id=&quot;form1&quot; runat=&quot;server&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;table&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;Start Date: &amp;lt;/td&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;asp:TextBox Width=&quot;180&quot; runat=&quot;server&quot; ID=&quot;StartDatePr&quot;/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;asp:CalendarExtender runat=&quot;server&quot; TargetControlID=&quot;StartDatePr&quot;/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;End Date: &amp;lt;/td&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;asp:TextBox Width=&quot;180&quot; runat=&quot;server&quot; ID=&quot;EndDatePr&quot;/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;asp:CalendarExtender ID=&quot;CalendarExtender1&quot; runat=&quot;server&quot; TargetControlID=&quot;EndDatePr&quot;/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;&amp;lt;asp:Button Text=&quot;Show Report&quot; ID=&quot;btnSubmit&quot; runat=&quot;server&quot; onclick=&quot;btnSubmit_Click&quot; /&amp;gt;&amp;lt;/td&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/table&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:ToolkitScriptManager ID=&quot;ToolkitScriptManager1&quot; runat=&quot;server&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:ToolkitScriptManager&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;rsweb:ReportViewer ID=&quot;MyReportViewer&quot; runat=&quot;server&quot; Font-Names=&quot;Verdana&quot; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Font-Size=&quot;8pt&quot; InteractiveDeviceInfos=&quot;(Collection)&quot; ProcessingMode=&quot;Remote&quot; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WaitMessageFont-Names=&quot;Verdana&quot; WaitMessageFont-Size=&quot;14pt&quot; Height=&quot;800px&quot; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Width=&quot;1000px&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ServerReport ReportServerUrl=&quot;&quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/rsweb:ReportViewer&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;4. Add below code in respective .CS file:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using Microsoft.Reporting.Common;&lt;br /&gt;using Microsoft.Reporting.WebForms;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;namespace SSRS_WEB&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public partial class WebForm2 : System.Web.UI.Page&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected void Page_Load(object sender, EventArgs e)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected void btnSubmit_Click(object sender, EventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //First &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyReportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyReportViewer.ServerReport.ReportServerUrl = new Uri(&quot;&lt;/span&gt;&lt;a href=&quot;http://localhost/reportserver_Sathya&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;http://localhost/reportserver_Sathya&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;); // Report Server URL&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyReportViewer.ServerReport.ReportPath = &quot;/SQLSSRS/Dashboard&quot;; // Report Name&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyReportViewer.ShowParameterPrompts = false;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyReportViewer.ShowPrintButton = false;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ReportParameter[] parameters = new ReportParameter[2];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parameters[0] = new ReportParameter(&quot;StartDate&quot;, StartDatePr.Text);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parameters[1] = new ReportParameter(&quot;EndDate&quot;, EndDatePr.Text);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyReportViewer.ServerReport.SetParameters(parameters);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyReportViewer.ServerReport.Refresh();&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;On executing the page, you can see SSRS reoport called in Web page.&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/3863209251393952583/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/call-ssrs-report-in-asp-net-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/3863209251393952583'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/3863209251393952583'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/call-ssrs-report-in-asp-net-with.html' title='Call SSRS Report in ASP .NET with Parameters'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-5485111299768161828</id><published>2012-06-18T23:14:00.001-07:00</published><updated>2012-06-18T23:14:13.275-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL"/><title type='text'>SQl query to database backup</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;The below query helps to take a backup of a DB:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
DECLARE @name VARCHAR(50) -- database name &lt;br /&gt;
&lt;br /&gt;
DECLARE @path VARCHAR(256) -- path for backup files &lt;br /&gt;
&lt;br /&gt;
DECLARE @fileName VARCHAR(256) -- filename for backup&lt;br /&gt;
&lt;br /&gt;
DECLARE @fileDate VARCHAR(20) -- used for file name &lt;br /&gt;
&lt;br /&gt;
SET @path = &#39;D:\Backup\&#39; SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112) &lt;br /&gt;
&lt;br /&gt;
DECLARE db_cursor CURSOR FOR SELECT name FROM MASTER.dbo.sysdatabases WHERE name IN (&#39;SalesDW&#39;) &lt;br /&gt;
&lt;br /&gt;
OPEN db_cursor FETCH NEXT FROM db_cursor INTO @name &lt;br /&gt;
&lt;br /&gt;
WHILE @@FETCH_STATUS = 0 &lt;br /&gt;
&lt;br /&gt;
BEGIN&lt;br /&gt;
&lt;br /&gt;
SET @fileName = @path + @name + &#39;_&#39; + @fileDate + &#39;.BAK&#39; &lt;br /&gt;
&lt;br /&gt;
BACKUP DATABASE @name TO DISK = @fileName &lt;br /&gt;
&lt;br /&gt;
FETCH NEXT FROM db_cursor INTO @name &lt;br /&gt;
&lt;br /&gt;
END CLOSE db_cursor &lt;br /&gt;
&lt;br /&gt;
DEALLOCATE db_cursor &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/5485111299768161828/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/sql-query-to-database-backup.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/5485111299768161828'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/5485111299768161828'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/sql-query-to-database-backup.html' title='SQl query to database backup'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-1473194532000827198</id><published>2012-06-18T23:13:00.001-07:00</published><updated>2012-06-18T23:13:41.906-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL"/><title type='text'>SQL Query to drop all constraints in a table</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;DECLARE&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @sql &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;nvarchar&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;255&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @DB &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;nvarchar&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @Table &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;nvarchar&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SET&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @DB &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;source_1&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SET&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @Table &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;Product&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHILE&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;EXISTS(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;INFORMATION_SCHEMA&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;TABLE_CONSTRAINTS&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHERE&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; constraint_catalog &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @DB &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; table_name &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @Table&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;BEGIN&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @sql &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;ALTER TABLE &#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @table &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39; DROP CONSTRAINT &#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; CONSTRAINT_NAME &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;INFORMATION_SCHEMA&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;TABLE_CONSTRAINTS&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WHERE&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; constraint_catalog &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @DB &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; table_name &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; @table&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;EXEC&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;sp_executesql&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;@sql&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;END&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/1473194532000827198/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/sql-query-to-drop-all-constraints-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/1473194532000827198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/1473194532000827198'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/sql-query-to-drop-all-constraints-in.html' title='SQL Query to drop all constraints in a table'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-8483393512310794137</id><published>2012-06-18T23:12:00.002-07:00</published><updated>2012-06-18T23:12:35.063-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL"/><title type='text'>Fastest Performing Rowcount SQL Query</title><content type='html'>Try executing the below queries in a table containing millins of records. Both the queries yields row count of the table, but the performance of Query 1&amp;nbsp;is more.&lt;br /&gt;
&lt;br /&gt;
Query 1:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SELECT SUM(row_count) FROM Sys.dm_db_partition_stats&lt;br /&gt;
WHERE OBJECT_ID = OBJECT_ID(&#39;AccountCommunications&#39;)&lt;br /&gt;
AND (index_id =0 or index_id =1);&lt;br /&gt;
&lt;br /&gt;
Query 2:&lt;br /&gt;
Select COUNT(*) From dbo.AccountCommunications</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/8483393512310794137/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/fastest-performing-rowcount-sql-query.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/8483393512310794137'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/8483393512310794137'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/fastest-performing-rowcount-sql-query.html' title='Fastest Performing Rowcount SQL Query'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-5036803108013850910</id><published>2012-06-18T23:12:00.000-07:00</published><updated>2012-06-18T23:14:30.652-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL"/><title type='text'>Query to Backup and Restore Database</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt; &lt;span style=&quot;color: black; font-size: small;&quot;&gt;Below is the query to backup and restore a database:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
BACKUP &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;DATABASE&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; [Source_1] &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;TO&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;DISK&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;N&#39;E:\Backup\Source_1.bak&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WITH&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;NOFORMAT&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;COMPRESSION&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
.&lt;span style=&quot;color: blue;&quot;&gt;NOINIT&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;,NAME&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;N&#39;Full bakup of Source_1&#39;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SKIP&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;STATS&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 10&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;--2.Optionally, determine the logical and physical names of the files in the backup set that contains the full database backup that you want to restore. &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;RESTORE&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FILELISTONLY&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;DISK&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;N&#39;E:\Backup\Source_1.bak&#39;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;-- 3. Restore &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;RESTORE&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;DATABASE&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; [Source_3]&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;DISK&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;N&#39;E:\Backup\Source_1.bak&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;WITH&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FILE&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;MOVE&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;Source_1&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;TO&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Source_3.mdf&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;MOVE&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;Source_1_log&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;TO&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Source_3_log.ldf&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;NOUNLOAD&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-size: x-small;&quot;&gt;REPLACE&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;STATS&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 10&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/5036803108013850910/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/query-to-backup-and-restore-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/5036803108013850910'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/5036803108013850910'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/query-to-backup-and-restore-database.html' title='Query to Backup and Restore Database'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-4879615749077310074</id><published>2012-06-18T23:11:00.001-07:00</published><updated>2012-06-18T23:14:44.537-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL"/><title type='text'>Active requests in MS SQL Database</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;The below query helps user to determine the active requests in MS SQL Server:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SQL_handle&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;from&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;dm_exec_requests&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;FROM&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;dm_exec_sql_text&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;0x020000009D72DA2080C94ACE2F4DF4A9452887663FF9A16D&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;-- Use SQL_Handle values&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/4879615749077310074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/active-requests-in-ms-sql-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/4879615749077310074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/4879615749077310074'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/active-requests-in-ms-sql-database.html' title='Active requests in MS SQL Database'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-4396449874564299809</id><published>2012-06-18T23:10:00.001-07:00</published><updated>2012-06-18T23:14:56.769-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL"/><title type='text'>Generating XML or Text file from T-SQL Query Output</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;--ENABLE XP_CMDSHELL===========================================================&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;-- To allow advanced options to be changed.&lt;/span&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;EXEC&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;sp_configure&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;show advanced options&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;-- To update the currently configured value for advanced options.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;RECONFIGURE&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt; GO&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;-- To enable the feature.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;EXEC&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;sp_configure&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;xp_cmdshell&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;-- To update the currently configured value for this feature.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;RECONFIGURE&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt; GO&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;--=============================================================================&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt; &lt;br /&gt;
--Create Pipe-Delimited Text file&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;EXEC&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;master&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;..&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;xp_cmdshell&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;bcp &quot;Select * from [Bids].dbo.Employee&quot; queryout &quot;E:\Work Area\FOF\Iteration24\Text.txt&quot; -t&quot;|&quot; -c -T -x&#39;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;--Create Xml file&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;EXEC&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;master&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;..&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;xp_cmdshell&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;bcp &quot;Select * from [Bids].dbo.Employee for XML auto&quot; queryout &quot;E:\Work Area\FOF\Iteration24\Text.xml&quot; -c -T -x&#39;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;--DISABLE XP_CMDSHELL================================================================&lt;br /&gt;
&lt;br /&gt;
-- To allow advanced options to be changed.&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;EXEC&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;sp_configure&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;show advanced options&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;-- To update the currently configured value for advanced options.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;RECONFIGURE&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt; GO&lt;br /&gt;
--&lt;span style=&quot;color: green;&quot;&gt;To enable the feature.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;EXEC&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: maroon; font-size: x-small;&quot;&gt;sp_configure&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: red; font-size: x-small;&quot;&gt;&#39;xp_cmdshell&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; 0&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;--&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;To update the currently configured value for this feature.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;RECONFIGURE&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/4396449874564299809/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/generating-xml-or-text-file-from-t-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/4396449874564299809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/4396449874564299809'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/generating-xml-or-text-file-from-t-sql.html' title='Generating XML or Text file from T-SQL Query Output'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-1302175460296367514</id><published>2012-06-18T23:09:00.001-07:00</published><updated>2012-06-18T23:15:10.702-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL"/><title type='text'>Batch Script to execute SQL command and Save the output as text file</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Follow the below steps to execute SQL command and Save the output as text file through batch file:&lt;br /&gt;
&lt;br /&gt;
Step 1: Prepare an SQL query and save the query as sql file (e.g., Test.sql).&lt;br /&gt;
&lt;br /&gt;
Step 2: Create batch file as shown below:&lt;br /&gt;
--======================================================================&lt;br /&gt;
@ECHO OFF&lt;br /&gt;
SETLOCAL&lt;br /&gt;
&lt;br /&gt;
REM Build an pipe delimited text file&lt;br /&gt;
SET PATH = C:\Documents and Settings\cst_varadhmv\Desktop\Iteration24\Train 3;&lt;br /&gt;
SqlCmd -S DDWSBDB01CS -d EDW20 -s&quot;|&quot; -E -i &quot;C:\Documents and Settings\cst_varadhmv\Desktop\Iteration24\Train 3\Test.sql&quot; -o &quot;C:\Documents and Settings\cst_varadhmv\Desktop\Iteration24\Train 3\Test.Txt&quot;&lt;br /&gt;
ECHO.&lt;br /&gt;
&lt;br /&gt;
echo Completed Successfully at %date% %time%&amp;gt;&amp;gt;_date_.txt &lt;br /&gt;
--====================================================================&lt;br /&gt;
&lt;br /&gt;
Step 3. Run the batch file, you can notice a text file created in the specified path with the SQL query output.&lt;br /&gt;
&lt;br /&gt;
To get quotes delimited output use the following:&lt;br /&gt;
SqlCmd -S 192.2.200.99 -E -s&#39;\t&#39; -i &quot;E:\Work Area\FOF\Iteration24\Employee.sql&quot; -o &quot;E:\Work Area\FOF\Iteration24\OutputQuotes.txt&quot; &lt;br /&gt;
&lt;br /&gt;
To get tab delimited output use the following:&lt;br /&gt;
SqlCmd -S 192.2.200.99&amp;nbsp; -i &quot;E:\Work Area\FOF\Iteration24\Employee.sql&quot; -o &quot;E:\Work Area\FOF\Iteration24\OutputQuotes.txt&quot; &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/1302175460296367514/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/batch-script-to-execute-sql-command-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/1302175460296367514'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/1302175460296367514'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/batch-script-to-execute-sql-command-and.html' title='Batch Script to execute SQL command and Save the output as text file'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-2849097299034391096</id><published>2012-06-18T23:08:00.001-07:00</published><updated>2012-06-18T23:15:24.839-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL"/><title type='text'>How to Identify Foreign Keys Without Index</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;The below query helps you to identify the foreign key column in a Database\Tables without any index. &lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;SCHEMA_NAME&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;schema_id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;SchemaName&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;name&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;TableName&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;fk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;name&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;ConstraintName&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;name&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;AS&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;ColumnName&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;FROM&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;tables&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;JOIN&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;columns&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;object_id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;object_id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;JOIN&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;foreign_keys&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;fk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;fk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;parent_object_id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;object_id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;JOIN&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;foreign_key_columns&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;fkc&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;fkc&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;constraint_object_id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;fk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;object_id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;fkc&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;parent_column_id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;column_id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;LEFT&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;JOIN&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;sys&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;index_columns&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;ic&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;ic&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;object_id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;fkc&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;parent_object_id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;ic&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;column_id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;fkc&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;parent_column_id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;WHERE&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;ic&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: magenta; font-family: Consolas; font-size: x-small;&quot;&gt;object_id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;IS&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;ORDER&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: x-small;&quot;&gt;BY&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: x-small;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;name&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/2849097299034391096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/how-to-identify-foreign-keys-without.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/2849097299034391096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/2849097299034391096'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/how-to-identify-foreign-keys-without.html' title='How to Identify Foreign Keys Without Index'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9205551643478578590.post-794608391400943795</id><published>2012-06-18T23:07:00.002-07:00</published><updated>2012-06-18T23:15:43.025-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL"/><title type='text'>List SQL table hierarchically based on Foreign Key and Primary Key Relationship</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;The below query help us to list the table hierarchically based on Foreign Key and Primary key relationship:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
WITH Fkeys AS (&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT DISTINCT&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OnTable&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = OnTable.name&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,AgainstTable&amp;nbsp; = AgainstTable.name &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SYSFOREIGNKEYS fk&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INNER JOIN SYSOBJECTS onTable &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ON fk.fkeyid = onTable.id&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INNER JOIN SYSOBJECTS againstTable&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ON fk.rkeyid = againstTable.id&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE 1=1&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND AgainstTable.TYPE = &#39;U&#39;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND OnTable.TYPE = &#39;U&#39;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- ignore self joins; they cause an infinite recursion&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND OnTable.Name &amp;lt;&amp;gt; AgainstTable.Name&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;br /&gt;
,MyData AS (&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OnTable = o.name&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,AgainstTable = FKeys.againstTable&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SYS.OBJECTS O&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LEFT JOIN FKeys&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ON&amp;nbsp; o.name = FKeys.onTable&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE 1=1&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND o.type = &#39;U&#39;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND o.name NOT LIKE &#39;sys%&#39;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;br /&gt;
,MyRecursion AS (&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; -- base case&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TableName&amp;nbsp;&amp;nbsp;&amp;nbsp; = OnTable&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,Lvl&amp;nbsp;&amp;nbsp;&amp;nbsp; = 1&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyData&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE 1=1&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND AgainstTable IS NULL&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; -- recursive case&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; UNION ALL SELECT&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TableName&amp;nbsp;&amp;nbsp;&amp;nbsp; = OnTable&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,Lvl&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = r.Lvl + 1&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyData d&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INNER JOIN MyRecursion r&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ON d.AgainstTable = r.TableName&lt;br /&gt;
)&lt;br /&gt;
SELECT &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROW_NUMBER() OVER (ORDER BY MAX(lvl) ASC) AS SNO&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,Lvl = MAX(Lvl)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ,TableName&lt;br /&gt;
&amp;nbsp;FROM &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; MyRecursion&lt;br /&gt;
GROUP BY&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; TableName&lt;br /&gt;
ORDER BY &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 DESC&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ,2 DESC&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://tutorialbi.blogspot.com/feeds/794608391400943795/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/list-sql-table-hierarchically-based-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/794608391400943795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9205551643478578590/posts/default/794608391400943795'/><link rel='alternate' type='text/html' href='http://tutorialbi.blogspot.com/2012/06/list-sql-table-hierarchically-based-on.html' title='List SQL table hierarchically based on Foreign Key and Primary Key Relationship'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05271650530017657109</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>