<?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-6884847128708431770</id><updated>2024-09-20T17:23:20.058-07:00</updated><title type='text'>SQL</title><subtitle type='html'>Programming with SQL - Few frequently used Queries/Commands + Few Common Errors and it&#39;s Resoultion</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mysqllibrary.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6884847128708431770/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://mysqllibrary.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Hitesh Vasoya</name><uri>http://www.blogger.com/profile/03409944103335836357</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>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6884847128708431770.post-214228876205231332</id><published>2011-11-14T01:12:00.000-08:00</published><updated>2011-11-14T01:14:18.463-08:00</updated><title type='text'>Few Useful SQL Commands</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-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-size: 14pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;1.) &lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-size: 14pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;Executing a sql file with SQLCMD command and passing a variable value to file variable.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: 14pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Let&#39;s say restoredb.sql is a file contains following sql.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;RESTORE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;DATABASE&lt;/span&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt; MyDB &lt;span style=&quot;color: blue;&quot;&gt;FROM&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;DISK&lt;/span&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;$(root)\mydb.bak&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;WITH&lt;/span&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt; &lt;span style=&quot;color: magenta;&quot;&gt;REPLACE&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;MOVE&lt;/span&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;mydb_data&#39;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;to&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;$(root)\mydb.mdf&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Now I can execute the content of restoredb.sql file with any value of root variable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;sqlcmd -E -i restoredb.sql -v root=&quot;%CD%&quot;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt; line-height: 115%;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;strong&gt;Site Reference:&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;a href=&quot;http://www.pluralsight-training.net/community/blogs/craig/archive/2005/12/16/17525.aspx&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;http://www.pluralsight-training.net/community/blogs/craig/archive/2005/12/16/17525.aspx&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysqllibrary.blogspot.com/feeds/214228876205231332/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysqllibrary.blogspot.com/2011/11/few-useful-sql-commands.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6884847128708431770/posts/default/214228876205231332'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6884847128708431770/posts/default/214228876205231332'/><link rel='alternate' type='text/html' href='http://mysqllibrary.blogspot.com/2011/11/few-useful-sql-commands.html' title='Few Useful SQL Commands'/><author><name>Hitesh Vasoya</name><uri>http://www.blogger.com/profile/03409944103335836357</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-6884847128708431770.post-4487294320035566305</id><published>2011-10-09T03:35:00.000-07:00</published><updated>2011-11-16T22:56:24.294-08:00</updated><title type='text'>Loading data into SQL database from file/file data</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: maroon;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;
&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;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;color: black; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;1.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;color: black; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-themecolor: text1;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Load
data into SQL database from Excel:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&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 style=&quot;color: black; font-size: small;&quot;&gt;

&lt;/span&gt;
&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;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;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 0.25in;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;
sp_configure &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: red; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&#39;show
advanced options&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt; 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;

&lt;/span&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 0.25in;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;reconfigure&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;

&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 0.25in;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: maroon; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;sp_configure&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&#39;Ad Hoc Distributed Queries&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt; 1 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;

&lt;/span&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 0.25in;&quot;&gt;
&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;reconfigure&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;

&lt;/span&gt;&lt;br /&gt;

&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 0.25in;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;color: grey; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt; INTO Link FROM OPENROWSET&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&#39;Microsoft.Jet.OLEDB.4.0&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&#39;Excel
8.0;Database=E:\data1.xls&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&#39;SELECT
* FROM [categoryLink$]&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;

&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: black; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text1;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-themecolor: text1;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Load
Docx file into SQL db table:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;strong&gt;

&lt;/strong&gt;&lt;/span&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: green; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: small;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 0.25in;&quot;&gt;
&lt;span style=&quot;color: green; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Declare a variable to
store the binary data&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt; @Doc &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;VARBINARY&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;MAX&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;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;

&lt;/span&gt;&lt;br /&gt;

&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 0.25in;&quot;&gt;
&lt;span style=&quot;color: green; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;-- Load the binary data&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt; @doc &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;bulkcolumn
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;VARBINARY&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;MAX&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;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;OPENROWSET&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;BULK&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;C:\Documents\MyDoc.docx&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;SINGLE_BLOB&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; x &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;

&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;span style=&quot;font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;color: black; font-family: Calibri;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;-- Update the Fragment
table &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;

&lt;span style=&quot;color: black; font-size: small;&quot;&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;UPDATE&lt;/span&gt;&lt;span style=&quot;font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Fragments&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt; Document&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;
@doc&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;font-size: 14pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;ID
&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; @ID&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-size: small;&quot;&gt;

&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: black; font-size: 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://mysqllibrary.blogspot.com/feeds/4487294320035566305/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysqllibrary.blogspot.com/2011/10/how-to-load-data-into-sql-database-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6884847128708431770/posts/default/4487294320035566305'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6884847128708431770/posts/default/4487294320035566305'/><link rel='alternate' type='text/html' href='http://mysqllibrary.blogspot.com/2011/10/how-to-load-data-into-sql-database-from.html' title='Loading data into SQL database from file/file data'/><author><name>Hitesh Vasoya</name><uri>http://www.blogger.com/profile/03409944103335836357</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-6884847128708431770.post-6643192571350315773</id><published>2011-08-19T08:23:00.000-07:00</published><updated>2011-08-19T08:23:21.648-07:00</updated><title type='text'>My daily used SQL Syntaxes</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;font-family: Helvetica; font-size: 13.5pt; mso-bidi-font-family: Helvetica;&quot;&gt;1. To find the SQL&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 0.25in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; margin: auto auto auto 0.45in; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 0.75in; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; height: 0.75in; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 279pt;&quot; valign=&quot;top&quot; width=&quot;372&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 9pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;DISTINCT&lt;/span&gt; a&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;name&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; SYSOBJECTS a &lt;span style=&quot;color: grey;&quot;&gt;inner&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;join&lt;/span&gt; SYSCOMMENTS b &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; a&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;id&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;b&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;id &lt;span style=&quot;color: blue;&quot;&gt;WHERE&lt;/span&gt; b&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;text&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;like&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;%Product%&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; text-indent: 0.5in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;font-family: Helvetica; font-size: 13.5pt; mso-bidi-font-family: Helvetica;&quot;&gt;2. Change the User in SQL 2000&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; margin: auto auto auto 0.45in; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 21.1pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; height: 21.1pt; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 207.85pt;&quot; valign=&quot;top&quot; width=&quot;277&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;SETUSER&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;Domain\User&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;Example : &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;SETUSER&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;MyDomain\Hitesh&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; text-indent: 0.5in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;font-family: Helvetica; font-size: 13.5pt; mso-bidi-font-family: Helvetica;&quot;&gt;3. Change the User in SQL 2005/2008&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 0.25in; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; height: 0.25in; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 243pt;&quot; valign=&quot;top&quot; width=&quot;324&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;EXECUTE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;LOGIN&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;Domain\User&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;Example :&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;EXECUTE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;LOGIN&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red; mso-no-proof: yes;&quot;&gt;&#39;MyDomain\Hitesh&#39;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; text-indent: 0.5in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysqllibrary.blogspot.com/feeds/6643192571350315773/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysqllibrary.blogspot.com/2011/08/my-daily-used-sql-syntaxes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6884847128708431770/posts/default/6643192571350315773'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6884847128708431770/posts/default/6643192571350315773'/><link rel='alternate' type='text/html' href='http://mysqllibrary.blogspot.com/2011/08/my-daily-used-sql-syntaxes.html' title='My daily used SQL Syntaxes'/><author><name>Hitesh Vasoya</name><uri>http://www.blogger.com/profile/03409944103335836357</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-6884847128708431770.post-7062924862265271537</id><published>2011-08-14T03:31:00.000-07:00</published><updated>2011-11-30T21:12:51.074-08:00</updated><title type='text'>Most frequently used SQL Syntaxes</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div closure_uid_rflffv=&quot;119&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 0.25in;&quot;&gt;&lt;span style=&quot;font-family: Verdana;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: #0b5394; font-family: Verdana; mso-bidi-font-weight: bold; mso-no-proof: yes;&quot;&gt;Most often I were&amp;nbsp;googling to find the simple enough syntexes while writing the sql query.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: #0b5394; font-family: Verdana; mso-bidi-font-weight: bold; mso-no-proof: yes;&quot;&gt;So I thought to List down all of them in single page and refer to that page while writing a sql query, Stored procedure or functions.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: #0b5394; font-family: Verdana; mso-bidi-font-weight: bold; mso-no-proof: yes;&quot;&gt;This may helpful to you.......&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; closure_uid_hm3o57=&quot;102&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;div closure_uid_6vpbb4=&quot;97&quot;&gt;&lt;span style=&quot;color: #0b5394; font-family: Verdana; mso-bidi-font-weight: bold; mso-no-proof: yes;&quot;&gt;I will used the following table through out this article.&lt;/span&gt;&lt;/div&gt;&lt;div closure_uid_6vpbb4=&quot;97&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; closure_uid_hm3o57=&quot;105&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;div closure_uid_6vpbb4=&quot;98&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;Create&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;table&lt;/span&gt; Product &lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;ProductId &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; Category &lt;span style=&quot;color: blue;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;20&lt;span closure_uid_fi07ci=&quot;130&quot; closure_uid_hm3o57=&quot;104&quot; style=&quot;color: grey;&quot;&gt;) Default&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: 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: black; font-size: x-small;&quot;&gt;0&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&gt; ProductDesc &lt;span style=&quot;color: blue;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;200&lt;span style=&quot;color: grey;&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div closure_uid_6vpbb4=&quot;98&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;132&quot; closure_uid_hm3o57=&quot;106&quot;&gt;&lt;span style=&quot;color: #0b5394; font-family: Verdana; mso-bidi-font-weight: bold; mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; closure_uid_hm3o57=&quot;102&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: #0b5394; font-family: Verdana; mso-bidi-font-weight: bold; mso-no-proof: yes;&quot;&gt;Here is a smart SQL Syntaxes.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;135&quot;&gt;&lt;div closure_uid_y3hlzi=&quot;115&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div closure_uid_rflffv=&quot;123&quot;&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;104&quot; closure_uid_rflffv=&quot;157&quot;&gt;&lt;div closure_uid_fi07ci=&quot;143&quot;&gt;&lt;div closure_uid_hm3o57=&quot;100&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;1. &lt;span closure_uid_fi07ci=&quot;134&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;If table exist, drop it.&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;133&quot; closure_uid_rflffv=&quot;139&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 1in; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 1in; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 5.75in;&quot; valign=&quot;top&quot; width=&quot;552&quot;&gt;&lt;div class=&quot;MsoNormal&quot; closure_uid_fi07ci=&quot;144&quot; style=&quot;margin: 0in 0in 0pt 27pt; mso-layout-grid-align: none;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;Declare&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; @table &lt;span style=&quot;color: blue;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;varchar&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;100&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; @table&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;Product&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: magenta;&quot;&gt;Object_ID&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;@table&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;is&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;Exec&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&#39;Drop table &#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; @table&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; closure_uid_fi07ci=&quot;145&quot; closure_uid_q5kdfj=&quot;91&quot; style=&quot;margin: 0in 0in 0pt 27pt;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div closure_uid_rflffv=&quot;157&quot;&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;div closure_uid_y3hlzi=&quot;114&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;2. &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;Create Index on an existing table.&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div closure_uid_y3hlzi=&quot;114&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div closure_uid_rflffv=&quot;157&quot;&gt;&lt;/div&gt;&lt;div closure_uid_ae95ns=&quot;109&quot; closure_uid_hm3o57=&quot;108&quot; closure_uid_rflffv=&quot;157&quot; closure_uid_y3hlzi=&quot;113&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 480;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 419.4pt;&quot; valign=&quot;top&quot; width=&quot;559&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;UNIQUE&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;CLUSTERED&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;INDEX&lt;/span&gt; &lt;place w:st=&quot;on&quot;&gt;&lt;city w:st=&quot;on&quot;&gt;CUnqIdxProductId&lt;/city&gt; &lt;state w:st=&quot;on&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;ON&lt;/span&gt;&lt;/state&gt;&lt;/place&gt; Product &lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;ProductId&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div closure_uid_ae95ns=&quot;109&quot; closure_uid_hm3o57=&quot;108&quot; closure_uid_rflffv=&quot;157&quot; closure_uid_y3hlzi=&quot;113&quot;&gt;&lt;/div&gt;&lt;div closure_uid_hm3o57=&quot;108&quot; closure_uid_rflffv=&quot;157&quot; closure_uid_y3hlzi=&quot;113&quot;&gt;&lt;/div&gt;&lt;div closure_uid_rflffv=&quot;157&quot; closure_uid_y3hlzi=&quot;113&quot;&gt;&lt;/div&gt;&lt;div closure_uid_rflffv=&quot;157&quot;&gt;&lt;/div&gt;&lt;div closure_uid_rflffv=&quot;157&quot; closure_uid_y3hlzi=&quot;116&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;3. &lt;span closure_uid_fi07ci=&quot;110&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;Drop Index.&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 480;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 18.4pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 18.4pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 419.4pt;&quot; valign=&quot;top&quot; width=&quot;559&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;DROP&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;INDEX&lt;/span&gt; Product&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;CUnqIdxProductId&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div closure_uid_fi07ci=&quot;103&quot; closure_uid_hm3o57=&quot;107&quot; closure_uid_y3hlzi=&quot;117&quot;&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;br /&gt;
&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;4. &lt;span closure_uid_fi07ci=&quot;110&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;Alter Column&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 480;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 16.6pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 16.6pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 419.4pt;&quot; valign=&quot;top&quot; width=&quot;559&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;ALTER&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;TABLE&lt;/span&gt; Product &lt;span style=&quot;color: blue;&quot;&gt;ALTER&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;COLUMN&lt;/span&gt; ProductId &lt;span style=&quot;color: blue;&quot;&gt;longint&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;Not&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div closure_uid_6vpbb4=&quot;100&quot; closure_uid_fi07ci=&quot;103&quot; closure_uid_fyddzj=&quot;113&quot;&gt;&lt;/div&gt;&lt;div closure_uid_ae95ns=&quot;110&quot; closure_uid_fi07ci=&quot;103&quot; closure_uid_fyddzj=&quot;95&quot;&gt;&lt;div closure_uid_ae95ns=&quot;121&quot;&gt;&lt;/div&gt;&lt;div closure_uid_ae95ns=&quot;121&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_ae95ns=&quot;121&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_ae95ns=&quot;120&quot; closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;5. &lt;span closure_uid_fi07ci=&quot;110&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;Create the table with Primary Key (Without constraint Name)&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div closure_uid_ae95ns=&quot;121&quot; closure_uid_fyddzj=&quot;96&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div closure_uid_6vpbb4=&quot;99&quot; closure_uid_ae95ns=&quot;119&quot; closure_uid_fi07ci=&quot;103&quot; closure_uid_hm3o57=&quot;124&quot;&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt; width: 348px;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 98.4pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 98.4pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 261pt;&quot; valign=&quot;top&quot; width=&quot;348&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;TABLE&lt;/span&gt; [dbo]&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;[Product]&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[ProductId] [int] &lt;span style=&quot;color: grey;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[Category] [varchar]&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;20&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[ProductDesc] [varchar]&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;200&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;PRIMARY&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;KEY&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[ProductId] &lt;span style=&quot;color: blue;&quot;&gt;ASC&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[Category] &lt;span style=&quot;color: blue;&quot;&gt;ASC&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 0.25in;&quot;&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;))&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div closure_uid_fyddzj=&quot;97&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_q5kdfj=&quot;92&quot; closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;6.&amp;nbsp;&lt;span closure_uid_fi07ci=&quot;110&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;Create the table with Primary Key (With constraint Name)&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div closure_uid_fyddzj=&quot;97&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 112pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 112pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 369pt;&quot; valign=&quot;top&quot; width=&quot;492&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 27pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;TABLE&lt;/span&gt; [dbo]&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;[Product]&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 27pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp; &lt;/span&gt;[ProductId] [int] &lt;span style=&quot;color: grey;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 27pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp; &lt;/span&gt;[Category] [varchar]&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;20&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 27pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp; &lt;/span&gt;[ProductDesc] [varchar]&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;200&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 27pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;CONSTRAINT&lt;/span&gt; [pk_Product] &lt;span style=&quot;color: blue;&quot;&gt;PRIMARY&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;KEY&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;CLUSTERED&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 27pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 27pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp; &lt;/span&gt;[ProductId] &lt;span style=&quot;color: blue;&quot;&gt;ASC&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 27pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp; &lt;/span&gt;[Category] &lt;span style=&quot;color: blue;&quot;&gt;ASC&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 9pt; text-indent: 0.25in;&quot;&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;7.&amp;nbsp;&lt;span closure_uid_fi07ci=&quot;110&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;Alter statement to add the Primary Key Constraint in an existing table (without Constraint Name).&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 0.25in; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 0.25in; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 5.75in;&quot; valign=&quot;top&quot; width=&quot;552&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;ALTER&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;TABLE&lt;/span&gt; Product &lt;span style=&quot;color: blue;&quot;&gt;ADD&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;PRIMARY&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;KEY&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;ProductId&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; Category&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;8.&amp;nbsp;&lt;span closure_uid_fi07ci=&quot;110&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;Alter statement to add the Primary Key Constraint in an existing table (with Constraint Name).&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 27.85pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 27.85pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 5.75in;&quot; valign=&quot;top&quot; width=&quot;552&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;ALTER&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;TABLE&lt;/span&gt; Product &lt;span style=&quot;color: blue;&quot;&gt;ADD&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;CONSTRAINT&lt;/span&gt; pk_Product &lt;span style=&quot;color: blue;&quot;&gt;PRIMARY&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;KEY&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;ProductId&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; Category&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; closure_uid_y3hlzi=&quot;118&quot; style=&quot;color: #0b5394;&quot;&gt;9.&amp;nbsp;&lt;span closure_uid_fi07ci=&quot;110&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;Drop the Primary Key Constraint when Constraint Name is not Known.&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong closure_uid_fi07ci=&quot;115&quot;&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span closure_uid_fi07ci=&quot;110&quot; style=&quot;color: #0b5394; font-family: Times New Roman; mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 135pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 135pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 387pt;&quot; valign=&quot;top&quot; width=&quot;516&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 0.5in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; @PKConstraintName &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;500&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; @PKConstraintName&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;QUOTENAME&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;constraint_name&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: green;&quot;&gt;INFORMATION_SCHEMA.TABLE_CONSTRAINTS&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; CONSTRAINT_TYPE &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;PRIMARY KEY&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; TABLE_NAME &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;Product&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 0.25in; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: magenta;&quot;&gt;ISNULL&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;@PKConstraintName&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;EXEC&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&#39;ALTER TABLE Product DROP CONSTRAINT &#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; @PKConstraintName&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt;&quot;&gt;&lt;div closure_uid_hm3o57=&quot;96&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; closure_uid_y3hlzi=&quot;119&quot; style=&quot;color: #0b5394;&quot;&gt;10.&amp;nbsp;&lt;span closure_uid_fi07ci=&quot;110&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;Drop the Default Constraint when Constraint Name is not Known.&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div closure_uid_hm3o57=&quot;96&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_hm3o57=&quot;96&quot;&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt; width: 516px;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 204pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 204pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 387pt;&quot; valign=&quot;top&quot; width=&quot;516&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; @table_name &lt;span style=&quot;color: blue;&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;256&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; @col_name &lt;span style=&quot;color: blue;&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;256&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; @Command&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;1000&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; @table_name &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; N&lt;span style=&quot;color: red;&quot;&gt;&#39;Products&#39;&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; @col_name &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; N&lt;span style=&quot;color: red;&quot;&gt;&#39;Category&#39;&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; @Command &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;ALTER TABLE &#39;&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; @table_name &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39; drop constraint &#39;&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; d&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;name&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color: green;&quot;&gt;sys.tables&lt;/span&gt; t&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;sys.default_constraints&lt;/span&gt; d&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;ON&lt;/span&gt; d&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;parent_object_id &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; t&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;object_id&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;sys.columns&lt;/span&gt; c&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;ON&lt;/span&gt; c&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;object_id&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; t&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;object_id&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;AND&lt;/span&gt; c&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;column_id &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; d&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;parent_column_id &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;WHERE&lt;/span&gt; t&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; @table_name &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;AND&lt;/span&gt; c&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; @col_name &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 9pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;EXECUTE&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;@Command&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div closure_uid_hm3o57=&quot;96&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_hm3o57=&quot;96&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_hm3o57=&quot;97&quot; closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;11.&amp;nbsp;&lt;span closure_uid_fi07ci=&quot;110&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;Alter statement to add the&amp;nbsp;Foreign Key Constraint in an existing table (without Constraint Name).&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 32pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 32pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 360.75pt;&quot; valign=&quot;top&quot; width=&quot;481&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;ALTER&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;TABLE&lt;/span&gt; Product &lt;span style=&quot;color: blue;&quot;&gt;ADD&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;FOREIGN&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;KEY&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;CategoryID&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; CATEGORY &lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;CategoryId&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; closure_uid_y3hlzi=&quot;120&quot; style=&quot;color: #0b5394;&quot;&gt;12.&amp;nbsp;&lt;span closure_uid_fi07ci=&quot;110&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;Alter statement to add the Foreign Key Constraint in an existing table (with Constraint Name).&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #0b5394; font-family: Courier New;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 58pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td closure_uid_fi07ci=&quot;158&quot; style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 58pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 369pt;&quot; valign=&quot;top&quot; width=&quot;492&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;ALTER&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;TABLE&lt;/span&gt; PRODUCT&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;ADD&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;CONSTRAINT&lt;/span&gt; FK_CATEGORY_CATEGORYID &lt;span style=&quot;color: blue;&quot;&gt;FOREIGN&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;KEY&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;CategoryID&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; closure_uid_fi07ci=&quot;157&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; CATEGORY &lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;CategoryId&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span closure_uid_fi07ci=&quot;110&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; closure_uid_y3hlzi=&quot;121&quot; style=&quot;color: #0b5394;&quot;&gt;13.&lt;span closure_uid_fi07ci=&quot;110&quot; closure_uid_y3hlzi=&quot;111&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;Create the table with Foreign Key (Without constraint Name)&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot; closure_uid_hm3o57=&quot;109&quot; closure_uid_y3hlzi=&quot;97&quot;&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 1in; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 1in; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 369pt;&quot; valign=&quot;top&quot; width=&quot;492&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 0.25in; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;TABLE&lt;/span&gt; [dbo]&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;[Product]&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 0.25in; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[ProductId] [int] &lt;span style=&quot;color: grey;&quot;&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 0.25in; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[CategoryID] [int] &lt;span style=&quot;color: grey;&quot;&gt;NULL&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;references&lt;/span&gt; Category&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;CategoryId&lt;span style=&quot;color: grey;&quot;&gt;),&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 0.25in; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[ProductDesc] [varchar]&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;200&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 0.5in;&quot;&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;ON&lt;/span&gt; [PRIMARY]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 0.5in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot; closure_uid_y3hlzi=&quot;108&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span closure_uid_fi07ci=&quot;110&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span closure_uid_fi07ci=&quot;110&quot; closure_uid_y3hlzi=&quot;110&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;14.Create the table with Foreign Key (With constraint Name)&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 1in; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 1in; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 369pt;&quot; valign=&quot;top&quot; width=&quot;492&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;TABLE&lt;/span&gt; [dbo]&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;[Product]&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[ProductId] [int] &lt;span style=&quot;color: grey;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[Category] [int] &lt;span style=&quot;color: grey;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[ProductDesc] [varchar]&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;200&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;CONSTRAINT&lt;/span&gt; [fk_Category] &lt;span style=&quot;color: blue;&quot;&gt;Foreign&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;KEY&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;(&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[Category] &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;REFERENCES&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; CATEGORY &lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;CategoryId&lt;span closure_uid_fi07ci=&quot;167&quot; style=&quot;color: grey;&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 0.5in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div closure_uid_fi07ci=&quot;169&quot;&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;103&quot;&gt;&lt;div closure_uid_hm3o57=&quot;98&quot;&gt;&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span closure_uid_fi07ci=&quot;110&quot; closure_uid_hm3o57=&quot;120&quot; closure_uid_y3hlzi=&quot;109&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;15.Drop the&amp;nbsp;Foreign Key constraint when constraint name is known&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div closure_uid_hm3o57=&quot;98&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;169&quot;&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;169&quot;&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 14.35pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 14.35pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 5.5in;&quot; valign=&quot;top&quot; width=&quot;528&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 9pt;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;Alter&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;table&lt;/span&gt; [Product] &lt;span style=&quot;color: blue;&quot;&gt;Drop&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;constraint&lt;/span&gt; FK_CATEGORY_CATEGORYID&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span closure_uid_rflffv=&quot;146&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;strong&gt;&lt;span closure_uid_fi07ci=&quot;105&quot; closure_uid_rflffv=&quot;167&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span closure_uid_fi07ci=&quot;110&quot; closure_uid_y3hlzi=&quot;122&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;16.Drop the&amp;nbsp;Foreign Key constraint when constraint name is known&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div closure_uid_fi07ci=&quot;169&quot;&gt;&lt;/div&gt;&lt;div closure_uid_fi07ci=&quot;169&quot;&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;border-collapse: collapse; border: currentColor; margin: auto auto auto 23.4pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 14.35pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; height: 14.35pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 5.5in;&quot; valign=&quot;top&quot; width=&quot;528&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 0pt 9pt;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt;Alter&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;table&lt;/span&gt; [Product] &lt;span style=&quot;color: blue;&quot;&gt;Drop&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;constraint&lt;/span&gt; FK_CATEGORY_CATEGORYID&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysqllibrary.blogspot.com/feeds/7062924862265271537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysqllibrary.blogspot.com/2011/08/most-frequently-used-sql-syntaxes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6884847128708431770/posts/default/7062924862265271537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6884847128708431770/posts/default/7062924862265271537'/><link rel='alternate' type='text/html' href='http://mysqllibrary.blogspot.com/2011/08/most-frequently-used-sql-syntaxes.html' title='Most frequently used SQL Syntaxes'/><author><name>Hitesh Vasoya</name><uri>http://www.blogger.com/profile/03409944103335836357</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-6884847128708431770.post-1373271550918600495</id><published>2011-07-09T11:41:00.000-07:00</published><updated>2011-08-13T23:53:45.443-07:00</updated><title type='text'>Common error with SSIS/DTSX Package + SSIS Package Execution from T-SQL using xp_cmdshell and dtexec</title><content type='html'>&lt;style type=&quot;text/css&quot;&gt;
         .body{
            font-family: Verdana;
            font-size: small;
            color: navy;
            font-weight:bold;
           }
        .Header
        {
         text-align: Center;
            font-family: Verdana;
            font-size: medium;
            font-weight:bold;
            color:Blue;
        }
       
       
        .CodeDisplay
        {
            font-family: Verdana;
            font-size: Small;
            color: navy;
            font-weight: normal;
            text-align: left;
            background-color: #F7F9F9;
            border: thin #000000 ridge;
            border-bottom-width: 1px;
            border-right-width: 0px;
            border-left-width: 0px;
            border-top-width: 1px;
        }
        .Detail
        {
            font-family: Verdana;
            font-size: Small;
            color: navy;
            font-weight: normal;
        }
        table
        {
            font-family: Verdana;
            font-size: small;
            color: navy;
            border: thin navy solid;
            border-bottom-width: 0px;
            border-left-width: 1px;
            border-right-width: 0px;
            border-top-width: 1px;
             
        }
        td
        {
         border: thin navy solid;
         border-bottom-width: 1px;
            border-left-width: 0px;
            border-right-width: 1px;
            border-top-width: 0px;
        }
        TD.Error
        {
         color:Red;
        }
       
      
    &lt;/style&gt;&lt;br /&gt;
&lt;div class=&quot;Detail&quot;&gt;I had a scenario where I was invoking SSIS/DTSX package from my stored proc using sp_cmdcell.&lt;br /&gt;
&lt;br /&gt;
Here is a command which I was executing.&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;CodeDisplay&quot; &gt;EXEC xp_cmdshell &#39;dtexec /SQ Package1&#39;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;detail&quot;&gt;&lt;table width=&quot;100%&quot; cellpadding=&quot;0px&quot; cellspacing=&quot;0px&quot;&gt;&lt;tr&gt;     &lt;td width=&quot;10%&quot;&gt;First Error:&lt;/td&gt;     &lt;td class=&quot;Error&quot;&gt;Could not load package &quot;Package1&quot; because of error 0xC0014062&lt;/td&gt;    &lt;/tr&gt;
&lt;tr&gt;     &lt;td&gt;Description: &lt;/td&gt;     &lt;td class=&quot;Error&quot;&gt;The LoadFromSQLServer method has encountered OLE DB error code 0x80040E4D&lt;br /&gt;
(Login failed for user &#39;NT AUTHORITY\NETWORK SERVICE&#39;.).  &lt;br /&gt;
The SQL statement that was issued has failed.&lt;br /&gt;
&lt;/td&gt;      &lt;/tr&gt;
&lt;tr&gt;     &lt;td&gt;Issue/Resolution:&lt;/td&gt;     &lt;td&gt;My SQL server and SQL server Agent services was running with this account (NT AUTHORITY\NETWORK SERVICE&#39;). &lt;br /&gt;
And this account was not added into the administrator group of my machine. &lt;br /&gt;
So I added this account into the local administrator group. Another way, &lt;br /&gt;
we can resolve this issue by running My SQL server and SQL server Agent services with other Admin account &lt;br /&gt;
which also have access on MSDB, Master DB and other local DBs.&lt;/td&gt;    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;Detail&quot;&gt;When you faced the same issue (Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’) in ASP.NET site, &lt;br /&gt;
you can refer the following blog.&lt;br /&gt;
&lt;p&gt;&lt;a href=&quot;http://programmers.wordpress.com/2007/10/16/login-failed-for-user-nt-authoritynetwork-service/&quot; &gt;http://programmers.wordpress.com/2007/10/16/login-failed-for-user-nt-authoritynetwork-service/&lt;/a&gt;&lt;br /&gt;
&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;detail&quot;&gt;&lt;table width=&quot;100%&quot; cellpadding=&quot;0px&quot; cellspacing=&quot;0px&quot;&gt;&lt;tr&gt;     &lt;td width=&quot;10%&quot;&gt;Second Error:&lt;/td&gt;     &lt;td class=&quot;Error&quot;&gt;Could not load package &quot;Package1&quot; because of error 0xC001000A.&lt;/td&gt;    &lt;/tr&gt;
&lt;tr&gt;     &lt;td&gt;Description: &lt;/td&gt;     &lt;td class=&quot;Error&quot;&gt;The specified package could not be loaded from the SQL Server database.&lt;br /&gt;
&lt;/td&gt;      &lt;/tr&gt;
&lt;tr&gt;     &lt;td&gt;Issue/Resolution:&lt;/td&gt;     &lt;td&gt;I had not specified the destination server name. I corrected the command and add the /SER attribute with correct server name.&lt;/td&gt;    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;CodeDisplay&quot; &gt;EXEC xp_cmdshell &#39;dtexec /SQ Package1 /SER EDVXGCPSQLCD02\sql2008&#39;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;detail&quot;&gt;&lt;table width=&quot;100%&quot; cellpadding=&quot;0px&quot; cellspacing=&quot;0px&quot;&gt;&lt;tr&gt;     &lt;td width=&quot;10%&quot;&gt;Third Error:&lt;/td&gt;     &lt;td class=&quot;Error&quot;&gt;Could not load package &quot;Package1&quot; because of error 0xC0014062&lt;/td&gt;    &lt;/tr&gt;
&lt;tr&gt;     &lt;td&gt;Description: &lt;/td&gt;     &lt;td class=&quot;Error&quot;&gt;The LoadFromSQLServer method has encountered OLE DB error code 0x80040E14 (Could not find stored procedure &#39;msdb.dbo.sp_dts_getpackage&#39;.).  The SQL statement that was issued has failed.&lt;br /&gt;
&lt;/td&gt;      &lt;/tr&gt;
&lt;tr&gt;     &lt;td&gt;Issue/Resolution:&lt;/td&gt;     &lt;td&gt;Specify the full path for dtexec exe. Final command I could successfully run was :&lt;/td&gt;    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;CodeDisplay&quot; &gt;EXEC xp_cmdshell &#39;C:\&quot;Program Files (x86)\Microsoft SQL Server&quot;\100\DTS\Binn\DTEXEC.exe /SQ Package1 /SER EDVXGCPSQLCD02\sql2008&#39;&lt;br /&gt;
Or &lt;br /&gt;
EXEC xp_cmdshell &#39;C:\&quot;Program Files\Microsoft SQL Server&quot;\100\DTS\Binn\DTEXEC.exe /SQ Package1 /SER EDVXGCPSQLCD02\sql2008&#39;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysqllibrary.blogspot.com/feeds/1373271550918600495/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysqllibrary.blogspot.com/2011/07/ssisdtsx-execution-from-stored.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6884847128708431770/posts/default/1373271550918600495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6884847128708431770/posts/default/1373271550918600495'/><link rel='alternate' type='text/html' href='http://mysqllibrary.blogspot.com/2011/07/ssisdtsx-execution-from-stored.html' title='Common error with SSIS/DTSX Package + SSIS Package Execution from T-SQL using xp_cmdshell and dtexec'/><author><name>Hitesh Vasoya</name><uri>http://www.blogger.com/profile/03409944103335836357</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-6884847128708431770.post-8515731286316672742</id><published>2011-05-24T03:51:00.000-07:00</published><updated>2011-08-14T02:17:57.580-07:00</updated><title type='text'>One intresting fact about SQL</title><content type='html'>Here is an one very intresting thing about SQL.&lt;br /&gt;
Even we don&#39;t specify the column name in where condition of SQL query, till we can filter the record from the table.&lt;br /&gt;
How is that possible ?&lt;br /&gt;
&lt;br /&gt;
Let&#39;s go through this scenario.&lt;br /&gt;
Here is an Products table having two colum CategoryId and ProductId.&lt;br /&gt;
&lt;br /&gt;
create table Products(CategoryId varchar(20),ProductId varchar(20))&lt;br /&gt;
insert into Products values (&#39;C01&#39;,1)&lt;br /&gt;
insert into Products values (&#39;C02&#39;,2)&lt;br /&gt;
insert into Products values (&#39;C03&#39;,3)&lt;br /&gt;
insert into Products values (&#39;C04&#39;,4)&lt;br /&gt;
insert into Products values (&#39;C05&#39;,5)&lt;br /&gt;
&lt;br /&gt;
insert into Products values (&#39;C01&#39;,6)&lt;br /&gt;
insert into Products values (&#39;C02&#39;,7)&lt;br /&gt;
insert into Products values (&#39;C03&#39;,8)&lt;br /&gt;
insert into Products values (&#39;C04&#39;,9)&lt;br /&gt;
insert into Products values (&#39;C05&#39;,2)&lt;br /&gt;
&lt;br /&gt;
insert into Products values (&#39;C01&#39;,11)&lt;br /&gt;
insert into Products values (&#39;C02&#39;,12)&lt;br /&gt;
insert into Products values (&#39;C03&#39;,13)&lt;br /&gt;
insert into Products values (&#39;C04&#39;,14)&lt;br /&gt;
insert into Products values (&#39;C05&#39;,15)&lt;br /&gt;
&lt;br /&gt;
Now I will not specify the CategoryId column in where condition of below query, still I would get the desired result.&lt;br /&gt;
&lt;br /&gt;
declare @CategoryId as varchar(20)&lt;br /&gt;
set @CategoryId = &#39;C04&#39;&lt;br /&gt;
&lt;br /&gt;
select * from Products where @CategoryId=case when ProductId in(&#39;15&#39;,&#39;2&#39;,&#39;5&#39;)&lt;br /&gt;
then &#39;C05&#39;&lt;br /&gt;
When ProductId in(&#39;14&#39;,&#39;9&#39;,&#39;4&#39;)  &lt;br /&gt;
then &#39;C04&#39;&lt;br /&gt;
end 	&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is a result of above query.&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/AVvXsEj6Cfd9XrOwrt4Yoed0tYdKMt8PyysvuoxlPJfXZnw9yIQkAVNKLzXBoqXOyEMY5iFt1TTcKEvOhwLghD-2VZvBYbAs-2UJuVW9fxFoccDl-tuy_1bYieEknuIl6DncFxRtQes3tA2XrMU/s1600/Result.JPG&quot; imageanchor=&quot;1&quot; style=&quot;clear:left; float:left;margin-right:1em; margin-bottom:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;72&quot; width=&quot;153&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6Cfd9XrOwrt4Yoed0tYdKMt8PyysvuoxlPJfXZnw9yIQkAVNKLzXBoqXOyEMY5iFt1TTcKEvOhwLghD-2VZvBYbAs-2UJuVW9fxFoccDl-tuy_1bYieEknuIl6DncFxRtQes3tA2XrMU/s320/Result.JPG&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;
isn&#39;t it intresting ?&lt;br /&gt;
I have recently come across such scenario. so I thought to share it with you.&lt;br /&gt;
&lt;br /&gt;
Send me your feedback on this.&lt;br /&gt;
&lt;br /&gt;
Thank you&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mysqllibrary.blogspot.com/feeds/8515731286316672742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysqllibrary.blogspot.com/2011/05/case-when.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6884847128708431770/posts/default/8515731286316672742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6884847128708431770/posts/default/8515731286316672742'/><link rel='alternate' type='text/html' href='http://mysqllibrary.blogspot.com/2011/05/case-when.html' title='One intresting fact about SQL'/><author><name>Hitesh Vasoya</name><uri>http://www.blogger.com/profile/03409944103335836357</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/AVvXsEj6Cfd9XrOwrt4Yoed0tYdKMt8PyysvuoxlPJfXZnw9yIQkAVNKLzXBoqXOyEMY5iFt1TTcKEvOhwLghD-2VZvBYbAs-2UJuVW9fxFoccDl-tuy_1bYieEknuIl6DncFxRtQes3tA2XrMU/s72-c/Result.JPG" height="72" width="72"/><thr:total>0</thr:total></entry></feed>