<?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-6099378866206239797</id><updated>2024-09-06T02:00:31.846+05:30</updated><title type='text'>Money Talk&#39;s !</title><subtitle type='html'>Stay Hungry ! Stay Foolish !</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>23</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-8872793217904837466</id><published>2016-02-12T10:17:00.002+05:30</published><updated>2016-02-12T10:43:14.350+05:30</updated><title type='text'>ITIL Service Management Life Cycle</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;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhN54nizFsvfLn4fD-oU2PrR-lsnXOOHcBmvKkwrsRwbxMFpnhevfA_p8_zPIt0nHAnMaxP0F7eLs8h6DVLxh9FE33i74rK2c58tGa19IqYLd3uABRtIvH_nrB54Eh3aJhJwsG3nP0Px0Gv/s1600/ITIL-Service-Lifecycle-copy.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;295&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhN54nizFsvfLn4fD-oU2PrR-lsnXOOHcBmvKkwrsRwbxMFpnhevfA_p8_zPIt0nHAnMaxP0F7eLs8h6DVLxh9FE33i74rK2c58tGa19IqYLd3uABRtIvH_nrB54Eh3aJhJwsG3nP0Px0Gv/s400/ITIL-Service-Lifecycle-copy.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/8872793217904837466/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2016/02/itil-service-management-life-cycle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/8872793217904837466'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/8872793217904837466'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2016/02/itil-service-management-life-cycle.html' title='ITIL Service Management Life Cycle'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhN54nizFsvfLn4fD-oU2PrR-lsnXOOHcBmvKkwrsRwbxMFpnhevfA_p8_zPIt0nHAnMaxP0F7eLs8h6DVLxh9FE33i74rK2c58tGa19IqYLd3uABRtIvH_nrB54Eh3aJhJwsG3nP0Px0Gv/s72-c/ITIL-Service-Lifecycle-copy.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-640803135055619885</id><published>2016-02-12T10:13:00.001+05:30</published><updated>2016-02-12T10:13:05.144+05:30</updated><title type='text'>ITIL Process Implementation</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;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuwLakLkfPvlrjBTMMMuDwrFVvEqgCUao0B_9kbN2fdoq6BfnAU2BN1GNIsvgzIPhjdJGTMWPsCBAQKHxCyi4pHL3_X1T2mrZASjykxQFaGzBxLdknKESmsqbaCYWGTieJ28eSptxxErxS/s1600/itilprocessimplementation.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuwLakLkfPvlrjBTMMMuDwrFVvEqgCUao0B_9kbN2fdoq6BfnAU2BN1GNIsvgzIPhjdJGTMWPsCBAQKHxCyi4pHL3_X1T2mrZASjykxQFaGzBxLdknKESmsqbaCYWGTieJ28eSptxxErxS/s640/itilprocessimplementation.png&quot; width=&quot;507&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/640803135055619885/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2016/02/itil-process-implementation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/640803135055619885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/640803135055619885'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2016/02/itil-process-implementation.html' title='ITIL Process Implementation'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuwLakLkfPvlrjBTMMMuDwrFVvEqgCUao0B_9kbN2fdoq6BfnAU2BN1GNIsvgzIPhjdJGTMWPsCBAQKHxCyi4pHL3_X1T2mrZASjykxQFaGzBxLdknKESmsqbaCYWGTieJ28eSptxxErxS/s72-c/itilprocessimplementation.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-6738881620894200484</id><published>2011-08-09T18:25:00.003+05:30</published><updated>2011-08-09T18:25:45.844+05:30</updated><title type='text'>Find Duplicate Records</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;SELECT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tablefield, COUNT(tablefield) AS dup_count &lt;br /&gt;
FROM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table&lt;br /&gt;
GROUP BY tablefield&lt;br /&gt;
HAVING&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (COUNT(tablefield) &amp;gt; 1) &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/6738881620894200484/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/08/find-duplicate-records.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/6738881620894200484'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/6738881620894200484'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/08/find-duplicate-records.html' title='Find Duplicate Records'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-1828440287539139116</id><published>2011-03-10T12:34:00.000+05:30</published><updated>2011-03-10T12:34:16.823+05:30</updated><title type='text'>Difference Between COUNT(DISTINCT) vs COUNT(ALL)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;COUNT&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[FieldName]&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;FROM &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[TableName]&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;GO&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;COUNT&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(ALL &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[FieldName]&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;FROM &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[TableName]&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;GO&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;COUNT&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;DISTINCT &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[FieldName]&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;FROM &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[TableName]&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;code style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;GO&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/1828440287539139116/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/03/difference-between-countdistinct-vs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/1828440287539139116'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/1828440287539139116'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/03/difference-between-countdistinct-vs.html' title='Difference Between COUNT(DISTINCT) vs COUNT(ALL)'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-5401898582183654677</id><published>2011-03-08T17:07:00.001+05:30</published><updated>2011-03-10T12:25:55.091+05:30</updated><title type='text'>Date Conversions with Different Formats.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
select convert (varchar(20),getdate(),20) &lt;br /&gt;
output result&lt;br /&gt;
2011-03-08 16:53:04&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),21)&lt;br /&gt;
output result&lt;br /&gt;
2011-03-08 17:04:09.&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),22)&lt;br /&gt;
output result&lt;br /&gt;
03/08/11&amp;nbsp; 5:04:42 PM&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),23)&lt;br /&gt;
output result&lt;br /&gt;
2011-03-08&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),24)&lt;br /&gt;
output result&lt;br /&gt;
17:05:51&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),25)&lt;br /&gt;
output result&lt;br /&gt;
2011-03-08 17:06:16.&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),100)&lt;br /&gt;
output result&lt;br /&gt;
Mar&amp;nbsp; 8 2011&amp;nbsp; 4:54PM&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),101)&lt;br /&gt;
output result&lt;br /&gt;
03/08/2011&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),102)&lt;br /&gt;
output result&lt;br /&gt;
2011.03.08&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),103)&lt;br /&gt;
output result&lt;br /&gt;
08/03/2011&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),104)&lt;br /&gt;
output result&lt;br /&gt;
08.03.2011&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),105)&lt;br /&gt;
output result&lt;br /&gt;
08-03-2011&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),106)&lt;br /&gt;
output result&lt;br /&gt;
08 Mar 2011&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),107)&lt;br /&gt;
output result&lt;br /&gt;
Mar 08, 2011&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),108)&lt;br /&gt;
output result&lt;br /&gt;
17:00:33&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),109)&lt;br /&gt;
output result&lt;br /&gt;
Mar&amp;nbsp; 8 2011&amp;nbsp; 5:01:09&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),110)&lt;br /&gt;
output result&lt;br /&gt;
03-08-2011&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),111)&lt;br /&gt;
output result&lt;br /&gt;
2011/03/08&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),112)&lt;br /&gt;
output result&lt;br /&gt;
20110308&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),113)&lt;br /&gt;
output result&lt;br /&gt;
08 Mar 2011 17:03:06&lt;br /&gt;
&lt;br /&gt;
select convert (varchar(20),getdate(),114)&lt;br /&gt;
output result&lt;br /&gt;
17:03:31:553&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/5401898582183654677/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/03/select-output-result-2011-03-08-165304.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/5401898582183654677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/5401898582183654677'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/03/select-output-result-2011-03-08-165304.html' title='Date Conversions with Different Formats.'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-3127080016617365119</id><published>2011-02-23T10:53:00.001+05:30</published><updated>2011-02-23T10:55:39.270+05:30</updated><title type='text'>Show Total in SQL</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;SELECT distinct(b.fieldname),CONVERT(varchar,SUM(a.fieldname),1) as total&lt;br /&gt;
&amp;nbsp;from tablename a, tablename b&lt;br /&gt;
&amp;nbsp;where&amp;nbsp; a.fieldname=b.fieldname&lt;br /&gt;
&amp;nbsp;group by b.tablename&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/3127080016617365119/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/02/show-total-in-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/3127080016617365119'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/3127080016617365119'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/02/show-total-in-sql.html' title='Show Total in SQL'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-6688316569333824092</id><published>2011-02-16T11:52:00.000+05:30</published><updated>2011-02-16T11:52:48.079+05:30</updated><title type='text'>Insert Record from Temp Table to Actual Table</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;insert into ActualTableName&lt;br /&gt;
Select&amp;nbsp;FiledName&amp;nbsp;from TempTable$ &lt;br /&gt;
where FieldName NOT IN(select FieldName from ActualTableName) &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/6688316569333824092/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/02/insert-record-from-temp-table-to-actual.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/6688316569333824092'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/6688316569333824092'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/02/insert-record-from-temp-table-to-actual.html' title='Insert Record from Temp Table to Actual Table'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-8285448877543361525</id><published>2011-02-07T17:53:00.001+05:30</published><updated>2011-02-07T17:53:07.347+05:30</updated><title type='text'>Previous Month Count in SP</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;CREATE PROCEDURE [dbo].[SP_NAME]&lt;br /&gt;
&lt;br /&gt;
AS&lt;br /&gt;
BEGIN&lt;br /&gt;
&lt;br /&gt;
select FieldName,count(FieldName)as alias from tablename&lt;br /&gt;
where fielddate&amp;gt;= DATEADD(month, DATEDIFF(month, 0, getdate()) - 1, 0)&lt;br /&gt;
AND dt &amp;lt; DATEADD(month, DATEDIFF(month, 0, getdate()), 0)&lt;br /&gt;
group by FieldName&lt;br /&gt;
&amp;nbsp;HAVING COUNT(FieldName) &amp;gt;= 1&lt;br /&gt;
&amp;nbsp;ORDER BY FieldName ASC&lt;br /&gt;
END&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/8285448877543361525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/02/previous-month-count-in-sp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/8285448877543361525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/8285448877543361525'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/02/previous-month-count-in-sp.html' title='Previous Month Count in SP'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-8171800100183849082</id><published>2011-01-20T15:04:00.000+05:30</published><updated>2011-01-20T15:04:02.229+05:30</updated><title type='text'>Store Procedure with Date Difference and DateTime Conversion</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;@Parameter int,&lt;br /&gt;
@ParameterDateName DateTime,&lt;br /&gt;
@ParameterDateName DateTime&lt;br /&gt;
SELECT FieldName,FieldName,DATEDIFF(day, FieldDateName, GETDATE()) as abc,FieldName from TableName where DATEDIFF(day, FieldDateName, GETDATE()) &amp;gt; @Parameter&lt;br /&gt;
&amp;nbsp;&amp;nbsp;and&lt;br /&gt;
&amp;nbsp;&amp;nbsp;FieldDateName&amp;gt;= convert(datetime, @ParameterDateName, 20)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;and&amp;nbsp; FieldDateName &amp;lt;=&amp;nbsp; convert(datetime, @ParameterDateName, 20)&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;ORDER BY Fieldname&amp;nbsp; desc&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/8171800100183849082/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/store-procedure-with-date-difference.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/8171800100183849082'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/8171800100183849082'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/store-procedure-with-date-difference.html' title='Store Procedure with Date Difference and DateTime Conversion'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-3756621872394199925</id><published>2011-01-19T09:49:00.002+05:30</published><updated>2011-01-19T09:49:59.960+05:30</updated><title type='text'>Store Procedure using Date Difference</title><content type='html'>CREATE&amp;nbsp; Proc dbo.ProcedureName &amp;nbsp;@Parameter datatype&lt;br /&gt;
&lt;br /&gt;
AS&lt;br /&gt;
&amp;nbsp;Begin&lt;br /&gt;
&amp;nbsp;&amp;nbsp;SELECT fieldname,fieldname,DATEDIFF(day, fielddate, GETDATE()) as ABC,fieldname from TableName where DATEDIFF(day, fielddate, GETDATE()) &amp;gt;= @Parameter&lt;br /&gt;
&amp;nbsp;End&lt;br /&gt;
GO</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/3756621872394199925/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/store-procedure-using-date-difference.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/3756621872394199925'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/3756621872394199925'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/store-procedure-using-date-difference.html' title='Store Procedure using Date Difference'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-1156765421805596277</id><published>2011-01-18T11:17:00.002+05:30</published><updated>2011-01-18T11:17:34.027+05:30</updated><title type='text'>SQL CURSOR Example</title><content type='html'>SET ANSI_NULLS ON&lt;br /&gt;
GO&lt;br /&gt;
SET QUOTED_IDENTIFIER ON&lt;br /&gt;
GO&lt;br /&gt;
&lt;br /&gt;
ALTER PROCEDURE [dbo].[Store Procedure Name] &lt;br /&gt;
&lt;br /&gt;
AS&lt;br /&gt;
BEGIN&lt;br /&gt;
&lt;br /&gt;
DECLARE @tmp TABLE&lt;br /&gt;
(&lt;br /&gt;
Fieldname varchar(500),&lt;br /&gt;
Fieldname varchar(500)&lt;br /&gt;
)&lt;br /&gt;
Declare @temp_Fieldname varchar(500)&lt;br /&gt;
declare @temp_Fieldname varchar(500)&lt;br /&gt;
declare @count int&lt;br /&gt;
&lt;br /&gt;
DECLARE PROCEDURE_CURSOR CURSOR FOR&lt;br /&gt;
&amp;nbsp;&amp;nbsp; select Fieldname,Fieldname from Table where DATEDIFF (dd,importdt,GETDATE()) = 0&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;OPEN PROCEDURE_CURSOR&lt;br /&gt;
&amp;nbsp;&amp;nbsp;FETCH NEXT FROM PROCEDURE_CURSOR INTO @temp_Fieldname,@temp_Fieldname&lt;br /&gt;
&amp;nbsp;&amp;nbsp;WHILE @@FETCH_STATUS = 0&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;BEGIN&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;select @count = count(Fieldname) from @tmp where Fieldname = @temp_Fieldname&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (@count = 0)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;begin&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;insert into @tmp values(@temp_Fieldname,@temp_Fieldname)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;begin&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;insert into @tmp (Fieldname) values(@temp_Fieldname)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FETCH NEXT FROM PROCEDURE_CURSOR INTO @temp_Fieldname,@temp_Fieldname&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;CLOSE PROCEDURE_CURSOR&lt;br /&gt;
&amp;nbsp;DEALLOCATE PROCEDURE_CURSOR&lt;br /&gt;
Select * from @tmp&lt;br /&gt;
END</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/1156765421805596277/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/sql-cursor-example.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/1156765421805596277'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/1156765421805596277'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/sql-cursor-example.html' title='SQL CURSOR Example'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-7988677871633485923</id><published>2011-01-16T10:58:00.000+05:30</published><updated>2011-01-16T10:58:43.087+05:30</updated><title type='text'>Biztalk Server Defination</title><content type='html'>&lt;link href=&quot;file:///C:%5CUsers%5Clenovo%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml&quot; rel=&quot;File-List&quot;&gt;&lt;/link&gt;&lt;link href=&quot;file:///C:%5CUsers%5Clenovo%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx&quot; rel=&quot;themeData&quot;&gt;&lt;/link&gt;&lt;link href=&quot;file:///C:%5CUsers%5Clenovo%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml&quot; rel=&quot;colorSchemeMapping&quot;&gt;&lt;/link&gt;    &lt;m:smallfrac m:val=&quot;off&quot;&gt;    &lt;m:dispdef&gt;    &lt;m:lmargin m:val=&quot;0&quot;&gt;    &lt;m:rmargin m:val=&quot;0&quot;&gt;    &lt;m:defjc m:val=&quot;centerGroup&quot;&gt;    &lt;m:wrapindent m:val=&quot;1440&quot;&gt;    &lt;m:intlim m:val=&quot;subSup&quot;&gt;    &lt;m:narylim m:val=&quot;undOvr&quot;&gt;   &lt;/m:narylim&gt;&lt;/m:intlim&gt; &lt;/m:wrapindent&gt;&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
	{font-family:&quot;Cambria Math&quot;;
	panose-1:0 0 0 0 0 0 0 0 0 0;
	mso-font-charset:1;
	mso-generic-font-family:roman;
	mso-font-format:other;
	mso-font-pitch:variable;
	mso-font-signature:0 0 0 0 0 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-parent:&quot;&quot;;
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;
	mso-fareast-font-family:&quot;Times New Roman&quot;;}
h3
	{mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-link:&quot;Heading 3 Char&quot;;
	mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	mso-outline-level:3;
	font-size:13.5pt;
	font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;}
span.Heading3Char
	{mso-style-name:&quot;Heading 3 Char&quot;;
	mso-style-unhide:no;
	mso-style-locked:yes;
	mso-style-link:&quot;Heading 3&quot;;
	mso-ansi-font-size:13.5pt;
	mso-bidi-font-size:13.5pt;
	font-weight:bold;}
.MsoChpDefault
	{mso-style-type:export-only;
	mso-default-props:yes;
	font-size:10.0pt;
	mso-ansi-font-size:10.0pt;
	mso-bidi-font-size:10.0pt;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;
&lt;/style&gt;  &lt;/m:defjc&gt;&lt;/m:rmargin&gt;&lt;/m:lmargin&gt;&lt;/m:dispdef&gt;&lt;/m:smallfrac&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span style=&quot;font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 12pt; font-weight: normal;&quot;&gt;Biztalk is a messaging based integration tool. It consists of several tools like Business Processes (Orchestrations), Business Activity Monitoring (BAM), HAT (Health and Activity Tracking), Rules Engines, BizTalk Server Administrative Console etc. &lt;br /&gt;
&lt;br /&gt;
BizTalk Server 2006 R2 builds upon the Business Process Management and SOA/ESB capabilities and address core challenges found in key vertical industries such as manufacturing and retail. Native capabilities of BTS R2 include support for Electronic Data Interchange (EDI) and AS2 ,Windows Workflow Foundation, WCF as well as RFID. &lt;br /&gt;
&lt;br /&gt;
BizTalk server 2006 R2 application can be created using Visual Studio 2005 provided BizTalk Server SDK is installed into the system. A standard BizTalk Server application consists of Schema, Mapping, and Orchestrations. The heart of the BizTalk Server application is schema that is used to define the message format of source and destination data. &lt;br /&gt;
&lt;br /&gt;
BizTalk Server has capability to talk with any kind of legacy system as it only understand the plain text data (in the form of xml), in order to talk with different systems it has several inbuilt adapter like SQL Adapter, MSMQ Adapter, SMTP Adapter, File Adapter, SOAP Adapter etc.&lt;/span&gt;&lt;/h3&gt;</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/7988677871633485923/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/biztalk-server-defination.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/7988677871633485923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/7988677871633485923'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/biztalk-server-defination.html' title='Biztalk Server Defination'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-8732543105486159813</id><published>2011-01-15T23:01:00.001+05:30</published><updated>2011-01-15T23:01:50.063+05:30</updated><title type='text'>SQL Question Answers</title><content type='html'>&lt;link href=&quot;file:///C:%5CUsers%5Clenovo%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml&quot; rel=&quot;File-List&quot;&gt;&lt;/link&gt;&lt;link href=&quot;file:///C:%5CUsers%5Clenovo%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx&quot; rel=&quot;themeData&quot;&gt;&lt;/link&gt;&lt;link href=&quot;file:///C:%5CUsers%5Clenovo%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml&quot; rel=&quot;colorSchemeMapping&quot;&gt;&lt;/link&gt;    &lt;m:smallfrac m:val=&quot;off&quot;&gt;    &lt;m:dispdef&gt;    &lt;m:lmargin m:val=&quot;0&quot;&gt;    &lt;m:rmargin m:val=&quot;0&quot;&gt;    &lt;m:defjc m:val=&quot;centerGroup&quot;&gt;    &lt;m:wrapindent m:val=&quot;1440&quot;&gt;    &lt;m:intlim m:val=&quot;subSup&quot;&gt;    &lt;m:narylim m:val=&quot;undOvr&quot;&gt;   &lt;/m:narylim&gt;&lt;/m:intlim&gt; &lt;/m:wrapindent&gt;&lt;style&gt;
&lt;!--
 /* Font Definitions */
 @font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;
	mso-font-charset:2;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:0 268435456 0 0 -2147483648 0;}
@font-face
	{font-family:&quot;Cambria Math&quot;;
	panose-1:0 0 0 0 0 0 0 0 0 0;
	mso-font-charset:1;
	mso-generic-font-family:roman;
	mso-font-format:other;
	mso-font-pitch:variable;
	mso-font-signature:0 0 0 0 0 0;}
@font-face
	{font-family:Verdana;
	panose-1:2 11 6 4 3 5 4 4 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:-1593833729 1073750107 16 0 415 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-parent:&quot;&quot;;
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;
	mso-fareast-font-family:&quot;Times New Roman&quot;;}
a:link, span.MsoHyperlink
	{mso-style-noshow:yes;
	mso-style-unhide:no;
	color:#8080FF;
	mso-text-animation:none;
	text-decoration:none;
	text-underline:none;
	text-decoration:none;
	text-line-through:none;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-noshow:yes;
	mso-style-priority:99;
	color:purple;
	mso-themecolor:followedhyperlink;
	text-decoration:underline;
	text-underline:single;}
p
	{mso-style-noshow:yes;
	mso-style-unhide:no;
	mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;
	mso-fareast-font-family:&quot;Times New Roman&quot;;}
.MsoChpDefault
	{mso-style-type:export-only;
	mso-default-props:yes;
	font-size:10.0pt;
	mso-ansi-font-size:10.0pt;
	mso-bidi-font-size:10.0pt;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
 /* List Definitions */
 @list l0
	{mso-list-id:2043167264;
	mso-list-type:hybrid;
	mso-list-template-ids:622131704 1086207856 777307448 -1415440342 1364498308 1305364320 -1109640054 -529874646 154197438 1793331202;}
@list l0:level1
	{mso-level-number-format:bullet;
	mso-level-text:;
	mso-level-tab-stop:.5in;
	mso-level-number-position:left;
	text-indent:-.25in;
	mso-ansi-font-size:10.0pt;
	font-family:Symbol;}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
--&gt;
&lt;/style&gt;  &lt;/m:defjc&gt;&lt;/m:rmargin&gt;&lt;/m:lmargin&gt;&lt;/m:dispdef&gt;&lt;/m:smallfrac&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What is normalization? Explain   different levels of normalization?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Check out the article Q100139 from Microsoft knowledge base and of course, there&#39;s much more information available in the net. It&#39;ll be a good idea to get a hold of any RDBMS fundamentals text book, especially the one by C. J. Date. Most of the times, it will be okay if you can explain till third normal form.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What is denormalization and   when would you go for it?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;As the name indicates, denormalization is the reverse process of normalization. It&#39;s the controlled introduction of redundancy in to the database design. It helps improve the query performance as the number of joins could be reduced.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;How do you implement   one-to-one, one-to-many and many-to-many relationships while designing   tables?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key relationships.&lt;br /&gt;
One-to-Many relationships are implemented by splitting the data into two tables with primary key and foreign key relationships.&lt;br /&gt;
Many-to-Many relationships are implemented using a junction table with the keys from both the tables forming the composite primary key of the junction table.&lt;br /&gt;
&lt;br /&gt;
It will be a good idea to read up a database designing fundamentals text book.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What&#39;s the difference between   a primary key and a unique key?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a non-clustered index by default. Another major difference is that, primary key doesn&#39;t allow Nulls, but unique key allows one NULL only.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What are user defined   datatypes and when you should go for them?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;User defined datatypes let you extend the base SQL Server datatypes by providing a descriptive name, and format to the database. Take for example, in your database, there is a column called Flight_Num which appears in many tables. In all these tables it should be varchar(8). In this case you could create a user defined datatype called Flight_num_type of varchar(8) and use it across all your tables.&lt;br /&gt;
&lt;br /&gt;
See sp_addtype, sp_droptype in books online.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What is bit datatype and   what&#39;s the information that can be stored inside a bit column?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Bit datatype is used to store boolean information like 1 or 0 (true or false). Untill SQL Server 6.5 bit datatype could hold either a 1 or 0 and there was no support for NULL. But from SQL Server 7.0 onwards, bit datatype can represent a third state, which is NULL.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Define candidate key,   alternate key, composite key.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;A candidate key is one that can identify each row of a table uniquely. Generally a candidate key becomes the primary key of the table. If the table has more than one candidate key, one of them will become the primary key, and the rest are called alternate keys.&lt;br /&gt;
&lt;br /&gt;
A key formed by combining at least two or more columns is called composite key.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What are defaults? Is there a   column to which a default can&#39;t be bound?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;A default is a value that will be used by a column, if no value is supplied to that column while inserting data. IDENTITY columns and timestamp columns can&#39;t have defaults bound to them. See CREATE DEFUALT in books online.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What is a transaction and what   are ACID properties?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;A transaction is a logical unit of work in which, all the steps must be performed or none. ACID stands for Atomicity, Consistency, Isolation, Durability. These are the properties of a transaction. For more information and explanation of these properties, see SQL Server books online or any RDBMS fundamentals text book. &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Explain different isolation   levels&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;An isolation level determines the degree of isolation of data between concurrent transactions. The default SQL Server isolation level is Read Committed. Here are the other isolation levels (in the ascending order of isolation): Read Uncommitted, Read Committed, Repeatable Read, Serializable. See SQL Server books online for an explanation of the isolation levels. Be sure to read about SET TRANSACTION ISOLATION LEVEL, which lets you customize the isolation level at the connection level.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;CREATE INDEX myIndex ON   myTable(myColumn)&lt;br /&gt;
What type of Index will get created after executing the above statement?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Non-clustered index. Important thing to note: By default a clustered index gets created on the primary key, unless specified otherwise.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What&#39;s the maximum size of a   row?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;8060 bytes. Don&#39;t be surprised with questions like &#39;what is the maximum number of columns per table&#39;. Check out SQL Server books online for the page titled: &quot;Maximum Capacity Specifications&quot;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Explain Active/Active and   Active/Passive cluster configurations&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Hopefully you have experience setting up cluster servers. But if you don&#39;t, at least be familiar with the way clustering works and the two clusterning configurations Active/Active and Active/Passive. SQL Server books online has enough information on this topic and there is a good white paper available on Microsoft site.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Explain the architecture of   SQL Server&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;This is a very important question and you better be able to answer it if consider yourself a DBA. SQL Server books online is the best place to read about SQL Server architecture. Read up the chapter dedicated to SQL Server Architecture.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What is lock escalation?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Lock escalation is the process of converting a lot of low level locks (like row locks, page locks) into higher level locks (like table locks). Every lock is a memory structure too many locks would mean, more memory being occupied by locks. To prevent this from happening, SQL Server escalates the many fine-grain locks to fewer coarse-grain locks. Lock escalation threshold was definable in SQL Server 6.5, but from SQL Server 7.0 onwards it&#39;s dynamically managed by SQL Server.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What&#39;s the difference between   DELETE TABLE and TRUNCATE TABLE commands?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;DELETE TABLE is a logged operation, so the deletion of each row gets logged in the transaction log, which makes it slow. TRUNCATE TABLE also deletes all the rows in a table, but it won&#39;t log the deletion of each row, instead it logs the deallocation of the data pages of the table, which makes it faster. Of course, TRUNCATE TABLE can be rolled back.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Explain the storage models of   OLAP&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Check out MOLAP, ROLAP and HOLAP in SQL Server books online for more infomation.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What are the new features   introduced in SQL Server 2000 (or the latest release of SQL Server at the time   of your interview)? What changed between the previous version of SQL Server   and the current version?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;This question is generally asked to see how current is your knowledge. Generally there is a section in the beginning of the books online titled &quot;What&#39;s New&quot;, which has all such information. Of course, reading just that is not enough, you should have tried those things to better answer the questions. Also check out the section titled &quot;Backward Compatibility&quot; in books online which talks about the changes that have taken place in the new version.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What are constraints? Explain   different types of constraints.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Constraints enable the RDBMS enforce the integrity of the database automatically, without needing you to create triggers, rule or defaults. &lt;br /&gt;
&lt;br /&gt;
Types of constraints: NOT NULL, CHECK, UNIQUE, PRIMARY KEY, FOREIGN KEY&lt;br /&gt;
&lt;br /&gt;
For an explanation of these constraints see books online for the pages titled: &quot;Constraints&quot; and &quot;CREATE TABLE&quot;, &quot;ALTER TABLE&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What is an index? What are the   types of indexes? How many clustered indexes can be created on a table? I   create a separate index on each column of a table. what are the advantages   and disadvantages of this approach?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Indexes in SQL Server are similar to the indexes in books. They help SQL Server retrieve the data quicker.&lt;br /&gt;
&lt;br /&gt;
Indexes are of two types. Clustered indexes and non-clustered indexes. When you craete a clustered index on a table, all the rows in the table are stored in the order of the clustered index key. So, there can be only one clustered index per table. Non-clustered indexes have their own storage separate from the table data storage. Non-clustered indexes are stored as B-tree structures (so do clustered indexes), with the leaf level nodes having the index key and it&#39;s row locater. The row located could be the RID or the Clustered index key, depending up on the absence or presence of clustered index on the table.&lt;br /&gt;
&lt;br /&gt;
If you create an index on each column of a table, it improves the query performance, as the query optimizer can choose from all the existing indexes to come up with an efficient execution plan. At the same t ime, data modification operations (such as INSERT, UPDATE, DELETE) will become slow, as every time data changes in the table, all the indexes need to be updated. Another disadvantage is that, indexes need disk space, the more indexes you have, more disk space is used.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What is RAID and what are   different types of RAID configurations?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;RAID stands for Redundant Array of Inexpensive Disks, used to provide fault tolerance to database servers. There are six RAID levels 0 through 5 offering different levels of performance, fault tolerance. MSDN has some information about RAID levels and for detailed information, check out the &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;a href=&quot;http://www.raid-advisory.com/&quot; target=&quot;_new&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;RAID advisory board&#39;s homepage&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What are the steps you will   take to improve performance of a poor performing query?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;This is a very open ended question and there could be a lot of reasons behind the poor performance of a query. But some general issues that you could talk about would be: No indexes, table scans, missing or out of date statistics, blocking, excess recompilations of stored procedures, procedures and triggers without SET NOCOUNT ON, poorly written query with unnecessarily complicated joins, too much normalization, excess usage of cursors and temporary tables.&lt;br /&gt;
&lt;br /&gt;
Some of the tools/ways that help you troubleshooting performance problems are: SET SHOWPLAN_ALL ON, SET SHOWPLAN_TEXT ON, SET STATISTICS IO ON, SQL Server Profiler, Windows NT /2000 Performance monitor, Graphical execution plan in Query Analyzer.&lt;br /&gt;
&lt;br /&gt;
Download the white paper on performance tuning SQL Server from Microsoft web site. Don&#39;t forget to check out &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;a href=&quot;http://www.sql-server-performance.com/&quot; target=&quot;_new&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;sql-server-performance.com&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What are the steps you will   take, if you are tasked with securing an SQL Server?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Again this is another open ended question. Here are some things you could talk about: Preferring NT authentication, using server, databse and application roles to control access to the data, securing the physical database files using NTFS permissions, using an unguessable SA password, restricting physical access to the SQL Server, renaming the Administrator account on the SQL Server computer, disabling the Guest account, enabling auditing, using multiprotocol encryption, setting up SSL, setting up firewalls, isolating SQL Server from the web server etc.&lt;br /&gt;
&lt;br /&gt;
Read the white paper on SQL Server security from Microsoft website. Also check out &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;a href=&quot;http://vyaskn.tripod.com/sql_server_security_best_practices.htm&quot; target=&quot;_new&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;My SQL Server security best practices&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What is a deadlock and what is   a live lock? How will you go about resolving deadlocks?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Deadlock is a situation when two processes, each having a lock on one piece of data, attempt to acquire a lock on the other&#39;s piece. Each process&amp;nbsp; would wait indefinitely for the other to release the lock, unless one of the user processes is terminated. SQL Server detects deadlocks and terminates one user&#39;s process.&lt;br /&gt;
&lt;br /&gt;
A livelock is one, where a&amp;nbsp; request for an exclusive lock is repeatedly denied because a series of overlapping shared locks keeps interfering. SQL Server detects the situation after four denials and refuses further shared locks. A livelock also occurs when read transactions monopolize a table or page, forcing a write transaction to wait indefinitely.&lt;br /&gt;
&lt;br /&gt;
Check out SET DEADLOCK_PRIORITY and &quot;Minimizing Deadlocks&quot;&amp;nbsp; in SQL Server books online. Also check out the article Q169960 from Microsoft knowledge base.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What is blocking and how would   you troubleshoot it?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Blocking happens when one connection from an application holds a lock and a second connection requires a conflicting lock type. This forces the second connection to wait, blocked on the first.&lt;br /&gt;
&lt;br /&gt;
Read up the following topics in SQL Server books online: Understanding and avoiding blocking, Coding efficient transactions.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Explain CREATE DATABASE syntax&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Many of us are used to craeting databases from the Enterprise Manager or by just issuing the command: CREATE DATABAE MyDB. But what if you have to create a database with two filegroups, one on drive C and the other on drive D with log on drive E with an initial size of 600 MB and with a growth factor of 15%? That&#39;s why being a DBA you should be familiar with the CREATE DATABASE syntax. Check out SQL Server books online for more information.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;How to restart SQL Server in   single user mode? How to start SQL Server in minimal configuration mode?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;SQL Server can be started from command line, using the SQLSERVR.EXE. This EXE has some very important parameters with which a DBA should be familiar with. -m is used for starting SQL Server in single user mode and -f is used to start the SQL Server in minimal confuguration mode. Check out SQL Server books online for more parameters and their explanations.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;As a part of your job, what   are the DBCC commands that you commonly use for database maintenance?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;DBCC CHECKDB, DBCC CHECKTABLE, DBCC CHECKCATALOG, DBCC CHECKALLOC, DBCC SHOWCONTIG, DBCC SHRINKDATABASE, DBCC SHRINKFILE etc. But there are a whole load of DBCC commands which are very useful for DBAs. Check out SQL Server books online for more information.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What are statistics, under   what circumstances they go out of date, how do you update them?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Statistics determine the selectivity of the indexes. If an indexed column has unique values then the selectivity of that index is more, as opposed to an index with non-unique values. Query optimizer uses these indexes in determining whether to choose an index or not while executing a query.&lt;br /&gt;
&lt;br /&gt;
Some situations under which you should update statistics:&lt;br /&gt;
1) If there is significant change in the key values in the index&lt;br /&gt;
2) If a large amount of data in an indexed column has been added, changed, or removed (that is, if the distribution of key values has changed), or the table has been truncated using the TRUNCATE TABLE statement and then repopulated&lt;br /&gt;
3) Database is upgraded from a previous version&lt;br /&gt;
&lt;br /&gt;
Look up SQL Server books online for the following commands: UPDATE STATISTICS, STATS_DATE, DBCC SHOW_STATISTICS, CREATE STATISTICS, DROP STATISTICS, sp_autostats, sp_createstats, sp_updatestats&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What are the different ways of   moving data/databases between servers and databases in SQL Server?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;There are lots of options available, you have to choose your option depending upon your requirements. Some of the options you have are: BACKUP/RESTORE, dettaching and attaching databases, replication, DTS, BCP, logshipping, INSERT...SELECT, SELECT...INTO, creating INSERT scripts to generate data.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Explian different types of   BACKUPs avaialabe in SQL Server? Given a particular scenario, how would you   go about choosing a backup plan?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Types of backups you can create in SQL Sever 7.0+ are Full database backup, differential database backup, transaction log backup, filegroup backup. Check out the BACKUP and RESTORE commands in SQL Server books online. Be prepared to write the commands in your interview. Books online also has information on detailed backup/restore architecture and when one should go for a particular kind of backup.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What is database replicaion?   What are the different types of replication you can set up in SQL Server?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Replication is the process of copying/moving data between databases on the same or different servers. SQL Server supports the following types of replication scenarios:&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ul type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Snapshot      replication&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Transactional      replication (with immediate updating subscribers, with queued updating      subscribers)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Merge      replication&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;See SQL Server books online for indepth coverage on replication. Be prepared to explain how different replication agents function, what are the main system tables used in replication etc.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;How to determine the service   pack currently installed on SQL Server?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;The global variable @@Version stores the build number of the sqlservr.exe, which is used to determine the service pack installed. To know more about this process visit &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;a href=&quot;http://vyaskn.tripod.com/sqlsps.htm&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;SQL Server service packs and versions.&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What are cursors? Explain   different types of cursors. What are the disadvantages of cursors? How can   you avoid cursors?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Cursors allow row-by-row prcessing of the resultsets.&lt;br /&gt;
&lt;br /&gt;
Types of cursors: Static, Dynamic, Forward-only, Keyset-driven. See books online for more information.&lt;br /&gt;
&lt;br /&gt;
Disadvantages of cursors: Each time you fetch a row from the cursor, it results in a network roundtrip, where as a normal SELECT query makes only one rowundtrip, however large the resultset is. Cursors are also costly because they require more resources and temporary storage (results in more IO operations). Furthere, there are restrictions on the SELECT statements that can be used with some types of cursors.&lt;br /&gt;
&lt;br /&gt;
Most of the times, set based operations can be used instead of cursors. Here is an example:&lt;br /&gt;
&lt;br /&gt;
If you have to give a flat hike to your employees using the following criteria:&lt;br /&gt;
&lt;br /&gt;
Salary between 30000 and 40000 -- 5000 hike&lt;br /&gt;
Salary between 40000 and 55000 -- 7000 hike&lt;br /&gt;
Salary between 55000 and 65000 -- 9000 hike&lt;br /&gt;
&lt;br /&gt;
In this situation many developers tend to use a cursor, determine each employee&#39;s salary and update his salary according to the above formula. But the same can be achieved by multiple update statements or can be combined in a single UPDATE statement as shown below:&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;UPDATE tbl_emp SET salary = &lt;br /&gt;
CASE WHEN salary BETWEEN 30000 AND 40000 THEN salary + 5000&lt;br /&gt;
WHEN salary BETWEEN 40000 AND 55000 THEN salary + 7000&lt;br /&gt;
WHEN salary BETWEEN 55000 AND 65000 THEN salary + 10000&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Another situation in which developers tend to use cursors: You need to call a stored procedure when a column in a particular row meets certain condition. You don&#39;t have to use cursors for this. This can be achieved using WHILE loop, as long as there is a unique key to identify each row. For examples of using WHILE loop for row by row processing, check out the &#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;a href=&quot;http://vyaskn.tripod.com/code.htm&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;My code library&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&#39; section of my site or &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;a href=&quot;http://vyaskn.tripod.com/search.htm&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;search&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt; for WHILE.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Write down the general syntax   for a SELECT statements covering all the options.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Here&#39;s the basic syntax: (Also checkout SELECT in books online for advanced syntax).&lt;br /&gt;
&lt;br /&gt;
SELECT select_list&lt;br /&gt;
[INTO new_table_]&lt;br /&gt;
FROM table_source&lt;br /&gt;
[WHERE search_condition]&lt;br /&gt;
[GROUP BY group_by_expression]&lt;br /&gt;
[HAVING search_condition]&lt;br /&gt;
[ORDER BY order_expression [ASC | DESC] ]&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What is a join and explain   different types of joins.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Joins are used in queries to explain how different tables are related. Joins also let you select data from a table depending upon data from another table. &lt;br /&gt;
&lt;br /&gt;
Types of joins: INNER JOINs, OUTER JOINs, CROSS JOINs. OUTER JOINs are further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.&lt;br /&gt;
&lt;br /&gt;
For more information see pages from books online titled: &quot;Join Fundamentals&quot; and &quot;Using Joins&quot;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Can you have a nested   transaction?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Yes, very much. Check out BEGIN TRAN, COMMIT, ROLLBACK, SAVE TRAN and @@TRANCOUNT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What is an extended stored   procedure? Can you instantiate a COM object by using T-SQL?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;An extended stored procedure is a function within a DLL (written in a programming language like C, C++ using Open Data Services (ODS) API) that can be called from T-SQL, just the way we call normal stored procedures using the EXEC statement. See books online to learn how to create extended stored procedures and how to add them to SQL Server. &lt;br /&gt;
&lt;br /&gt;
Yes, you can instantiate a COM (written in languages like VB, VC++) object from T-SQL by using sp_OACreate stored procedure. Also see books online for sp_OAMethod, sp_OAGetProperty, sp_OASetProperty, sp_OADestroy. For an example of creating a COM object in VB and calling it from T-SQL, see &#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;a href=&quot;http://vyaskn.tripod.com/code.htm&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;My code library&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&#39; section of this site. &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What is the system function to   get the current user&#39;s user id?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;USER_ID(). Also check out other system functions like USER_NAME(), SYSTEM_USER, SESSION_USER, CURRENT_USER, USER, SUSER_SID(), HOST_NAME(). &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What are triggers? How many   triggers you can have on a table? How to invoke a trigger on demand?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Triggers are special kind of stored procedures that get executed automatically when an INSERT, UPDATE or DELETE operation takes place on a table.&lt;br /&gt;
&lt;br /&gt;
In SQL Server 6.5 you could define only 3 triggers per table, one for INSERT, one for UPDATE and one for DELETE. From SQL Server 7.0 onwards, this restriction is gone, and you could create multiple triggers per each action. But in 7.0 there&#39;s no way to control the order in which the triggers fire. In SQL Server 2000 you could specify which trigger fires first or fires last using sp_settriggerorder&lt;br /&gt;
&lt;br /&gt;
Triggers can&#39;t be invoked on demand. They get triggered only when an associated action (INSERT, UPDATE, DELETE) happens on the table on which they are defined.&lt;br /&gt;
&lt;br /&gt;
Triggers are generally used to implement business rules, auditing. Triggers can also be used to extend the referential integrity checks, but wherever possible, use constraints for this purpose, instead of triggers, as constraints are much faster.&lt;br /&gt;
&lt;br /&gt;
Till SQL Server 7.0, triggers fire only after the data modification operation happens. So in a way, they are called post triggers. But in SQL Server 2000 you could create pre triggers also. Search SQL Server 2000 books online for INSTEAD OF triggers.&lt;br /&gt;
&lt;br /&gt;
Also check out books online for &#39;inserted table&#39;, &#39;deleted table&#39; and COLUMNS_UPDATED()&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;There is a trigger defined for   INSERT operations on a table, in an OLTP system. The trigger is written to   instantiate a COM object and pass the newly insterted rows to it for some   custom processing. What do you think of this implementation? Can this be   implemented better?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Instantiating COM objects is a time consuming process and since you are doing it from within a trigger, it slows down the data insertion process. Same is the case with sending emails from triggers. This scenario can be better implemented by logging all the necessary data into a separate table, and have a job which periodically checks this table and does the needful.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;What is a self join? Explain   it with an example.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Self join is just like any other join, except that two instances of the same table will be joined in the query. Here is an example: Employees table which contains rows for normal employees as well as managers. So, to find out the managers of all the employees, you need a self join.&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;br /&gt;
CREATE TABLE emp&lt;br /&gt;
(&lt;br /&gt;
empid int,&lt;br /&gt;
mgrid int,&lt;br /&gt;
empname char(10)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
INSERT emp SELECT 1,2,&#39;Vyas&#39;&lt;br /&gt;
INSERT emp SELECT 2,3,&#39;Mohan&#39;&lt;br /&gt;
INSERT emp SELECT 3,NULL,&#39;Shobha&#39;&lt;br /&gt;
INSERT emp SELECT 4,2,&#39;Shridhar&#39;&lt;br /&gt;
INSERT emp SELECT 5,2,&#39;Sourabh&#39;&lt;br /&gt;
&lt;br /&gt;
SELECT t1.empname [Employee], t2.empname [Manager]&lt;br /&gt;
FROM emp t1, emp t2&lt;br /&gt;
WHERE t1.mgrid = t2.empid&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Here&#39;s an advanced query using a LEFT OUTER JOIN that even returns the employees without managers (super bosses)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;SELECT t1.empname [Employee], COALESCE(t2.empname, &#39;No manager&#39;) [Manager]&lt;br /&gt;
FROM emp t1 &lt;br /&gt;
LEFT OUTER JOIN&lt;br /&gt;
emp t2&lt;br /&gt;
ON &lt;br /&gt;
t1.mgrid = t2.empid&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;-moz-background-clip: -moz-initial; -moz-background-inline-policy: -moz-initial; -moz-background-origin: -moz-initial; background: rgb(219, 248, 201) none repeat scroll 0% 0%; width: 100%;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;   &lt;td style=&quot;padding: 0.75pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;Given an employee table, how   would you find out the second highest salary?&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/8732543105486159813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/sql-question-answers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/8732543105486159813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/8732543105486159813'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/sql-question-answers.html' title='SQL Question Answers'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-1859785071911136321</id><published>2011-01-15T23:00:00.001+05:30</published><updated>2011-01-15T23:00:30.022+05:30</updated><title type='text'>How to Send EMAIL in VB 6.0</title><content type='html'>=============== FORM ==============================&lt;br /&gt;
Private Sub Command1_Click()&lt;br /&gt;
Dim RetVal As Boolean&lt;br /&gt;
Dim i As Long&lt;br /&gt;
&lt;br /&gt;
&#39; In a real application we&#39;d check the return values to ensure all was well&lt;br /&gt;
&#39; Start a session&lt;br /&gt;
RetVal = AlterMailSession(Me, StartSession)&lt;br /&gt;
&lt;br /&gt;
&#39; Send a message with multiple addresses and attachments&lt;br /&gt;
RetVal = CreateMailMessage(Me, &quot;Test Message 1&quot;, &quot; &quot; &amp;amp; Chr(13) &amp;amp; &quot;Test Contents&quot; &amp;amp; Chr(13) &amp;amp; &quot;More stuff&quot;)&lt;br /&gt;
RetVal = MailMessageTo(Me, &quot;elliot spencer&quot;, Primary)&lt;br /&gt;
RetVal = MailMessageTo(Me, &quot;elliot spencer&quot;, CC)&lt;br /&gt;
RetVal = MailMessageTo(Me, &quot;elliot spencer&quot;, Primary)&lt;br /&gt;
RetVal = MailMessageTo(Me, &quot;elliot spencer&quot;, CC)&lt;br /&gt;
RetVal = MailMessageTo(Me, &quot;elliot spencer&quot;, BlindCC)&lt;br /&gt;
RetVal = AddAttachment(Me, &quot;pq.doc&quot;, &quot;c:\pq.doc&quot;, DataFile)&lt;br /&gt;
RetVal = AddAttachment(Me, &quot;pq.doc&quot;, &quot;c:\pq.doc&quot;, OLEStatic)&lt;br /&gt;
RetVal = SendMailMessage(Me)&lt;br /&gt;
&lt;br /&gt;
&#39; Abort this message&lt;br /&gt;
RetVal = CreateMailMessage(Me, &quot;Test Message 2&quot;, &quot;Test Contents&quot; &amp;amp; Chr(13) &amp;amp; &quot;More stuff&quot;)&lt;br /&gt;
RetVal = MailMessageTo(Me, &quot;elliot spencer&quot;, CC)&lt;br /&gt;
RetVal = AbortMailMessage(Me)&lt;br /&gt;
&lt;br /&gt;
&#39; Save this message&lt;br /&gt;
RetVal = CreateMailMessage(Me, &quot;Test Message 3&quot;, &quot;Test Contents&quot; &amp;amp; Chr(13) &amp;amp; &quot;More stuff&quot;)&lt;br /&gt;
RetVal = MailMessageTo(Me, &quot;elliot spencer&quot;, Primary)&lt;br /&gt;
RetVal = SaveMailMessage(Me)&lt;br /&gt;
&lt;br /&gt;
&#39; Stop the current session&lt;br /&gt;
RetVal = AlterMailSession(Me, StopSession)&lt;br /&gt;
End Sub&lt;br /&gt;
================== MODULE ==========================================&lt;br /&gt;
&lt;br /&gt;
&#39;&lt;br /&gt;
&#39; Created by E.Spencer - This code is public domain.&lt;br /&gt;
&#39;&lt;br /&gt;
Private Declare Function RegOpenKey Lib &quot;AdvAPI32.dll&quot; Alias &quot;RegOpenKeyA&quot; (ByVal hKey As Long, _&lt;br /&gt;
ByVal lpSubKey As String, phkResult As Long) As Long&lt;br /&gt;
Private Declare Function RegQueryValueEx Lib &quot;AdvAPI32.dll&quot; Alias &quot;RegQueryValueExA&quot; (ByVal hKey As Long, _&lt;br /&gt;
ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, _&lt;br /&gt;
lpcbData As Long) As Long&lt;br /&gt;
Private Declare Function RegCloseKey Lib &quot;AdvAPI32.dll&quot; (ByVal hKey As Long) As Long&lt;br /&gt;
Private Const HKEY_CURRENT_USER = &amp;amp;H80000001&lt;br /&gt;
Public Enum SessMode&lt;br /&gt;
&amp;nbsp;&amp;nbsp; StartSession&lt;br /&gt;
&amp;nbsp;&amp;nbsp; StopSession&lt;br /&gt;
End Enum&lt;br /&gt;
Public Enum AddrType&lt;br /&gt;
&amp;nbsp;&amp;nbsp; Primary&lt;br /&gt;
&amp;nbsp;&amp;nbsp; CC&lt;br /&gt;
&amp;nbsp;&amp;nbsp; BlindCC&lt;br /&gt;
End Enum&lt;br /&gt;
Public Enum AttachType&lt;br /&gt;
&amp;nbsp;&amp;nbsp; DataFile&lt;br /&gt;
&amp;nbsp;&amp;nbsp; OLEEmbedded&lt;br /&gt;
&amp;nbsp;&amp;nbsp; OLEStatic&lt;br /&gt;
End Enum&lt;br /&gt;
Public SStatus, MStatus As String&lt;br /&gt;
&lt;br /&gt;
&#39; Call this function to start and stop MAPI sessions&lt;br /&gt;
&#39; Example :- MyBool = AlterMailSession(Me, StartSession)&lt;br /&gt;
&#39; MyBool = AlterMailSession(Me, StopSession)&lt;br /&gt;
&#39; MyBool will be true if operation succeeded&lt;br /&gt;
&#39; First parameter is reference to form that contains MAPI message / session controls&lt;br /&gt;
&#39; Second parameter is the required session mode - stop or start.&lt;br /&gt;
Public Function AlterMailSession(ByRef FName As Form, Mode As SessMode) As Boolean&lt;br /&gt;
AlterMailSession = True&lt;br /&gt;
On Error GoTo SessError&lt;br /&gt;
If Mode = StartSession Then&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &#39; Get the default exchange profile name&lt;br /&gt;
&amp;nbsp;&amp;nbsp; FName.MAPISession1.UserName = ReadRegistry(HKEY_CURRENT_USER, _&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\&quot;, &quot;DefaultProfile&quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &#39; If session is already open return immediately&lt;br /&gt;
&amp;nbsp;&amp;nbsp; If SStatus = &quot;Open&quot; Then Exit Function&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &#39; Set up profile - Default for exchange&lt;br /&gt;
&amp;nbsp;&amp;nbsp; FName.MAPISession1.UserName = &quot;MS Exchange Settings&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; FName.MAPISession1.SignOn &#39; Start mail session&lt;br /&gt;
&amp;nbsp;&amp;nbsp; FName.MAPIMessages1.SessionID = FName.MAPISession1.SessionID &#39; Allocate session ID to Mail holder&lt;br /&gt;
&amp;nbsp;&amp;nbsp; SStatus = &quot;Open&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; MStatus = &quot;Ready&quot;&lt;br /&gt;
ElseIf Mode = StopSession Then&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &#39; If session is already closed return immediately&lt;br /&gt;
&amp;nbsp;&amp;nbsp; If SStatus = &quot;Closed&quot; Then Exit Function&lt;br /&gt;
&amp;nbsp;&amp;nbsp; FName.MAPISession1.SignOff &#39; End mail session&lt;br /&gt;
&amp;nbsp;&amp;nbsp; FName.MAPIMessages1.SessionID = 0&lt;br /&gt;
&amp;nbsp;&amp;nbsp; SStatus = &quot;Closed&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; MStatus = &quot;NotReady&quot;&lt;br /&gt;
End If&lt;br /&gt;
Exit Function&lt;br /&gt;
SessError:&lt;br /&gt;
SStatus = &quot;Closed&quot;&lt;br /&gt;
MStatus = &quot;NotReady&quot;&lt;br /&gt;
AlterMailSession = False&lt;br /&gt;
End Function&lt;br /&gt;
&lt;br /&gt;
&#39; Call this function to start a new mail message&lt;br /&gt;
&#39; Example :- MyBool = CreateMailMessage(Me, &quot;Test Message&quot;, &quot;Test Contents&quot;)&lt;br /&gt;
&#39; MyBool will be true if operation succeeded&lt;br /&gt;
&#39; First parameter is reference to form that contains MAPI message / session controls&lt;br /&gt;
&#39; The second parameter is the message subject line.&lt;br /&gt;
&#39; The third parameter is the message content text (embed Chr(13) for newlines)&lt;br /&gt;
Public Function&lt;br /&gt;
CreateMailMessage(ByRef FName As Form, Subject As String, Contents As String) As Boolean&lt;br /&gt;
CreateMailMessage = False&lt;br /&gt;
&#39; If session is not open return immediately&lt;br /&gt;
If SStatus &amp;lt;&amp;gt; &quot;Open&quot; Then Exit Function&lt;br /&gt;
CreateMailMessage = True&lt;br /&gt;
On Error GoTo MessError&lt;br /&gt;
FName.MAPIMessages1.Compose &#39; Start new message composition&lt;br /&gt;
FName.MAPIMessages1.MsgSubject = Subject &#39; Insert message subject line&lt;br /&gt;
FName.MAPIMessages1.MsgNoteText = Contents &amp;amp; Chr(13) &amp;amp; &quot; &quot; &#39; Insert message text&lt;br /&gt;
MStatus = &quot;Open&quot;&lt;br /&gt;
Exit Function&lt;br /&gt;
MessError:&lt;br /&gt;
MStatus = &quot;NotReady&quot;&lt;br /&gt;
CreateMailMessage = False&lt;br /&gt;
End Function&lt;br /&gt;
&lt;br /&gt;
&#39; Call this function to abort a mail message&lt;br /&gt;
&#39; Example :- MyBool = AbortMailMessage(Me)&lt;br /&gt;
&#39; MyBool will be true if operation succeeded&lt;br /&gt;
&#39; First parameter is reference to form that contains MAPI message / session controls&lt;br /&gt;
Public Function AbortMailMessage(ByRef FName As Form) As Boolean&lt;br /&gt;
AbortMailMessage = False&lt;br /&gt;
&#39; If session is not open return immediately&lt;br /&gt;
If SStatus &amp;lt;&amp;gt; &quot;Open&quot; Then Exit Function&lt;br /&gt;
&#39; If no current mail message then return immediately&lt;br /&gt;
If MStatus &amp;lt;&amp;gt; &quot;Open&quot; Then Exit Function&lt;br /&gt;
AbortMailMessage = True&lt;br /&gt;
On Error GoTo MessError&lt;br /&gt;
FName.MAPIMessages1.Delete (mapMessageDelete)&lt;br /&gt;
MStatus = &quot;Ready&quot;&lt;br /&gt;
Exit Function&lt;br /&gt;
MessError:&lt;br /&gt;
AbortMailMessage = False&lt;br /&gt;
End Function&lt;br /&gt;
&lt;br /&gt;
&#39; Call this function to send a complete mail message&lt;br /&gt;
&#39; Example :- MyBool = SendMailMessage(Me) &lt;br /&gt;
&#39; MyBool will be true if operation succeeded&lt;br /&gt;
&#39; First parameter is reference to form that contains MAPI message / session controls&lt;br /&gt;
Public Function SendMailMessage(ByRef FName As Form) As Boolean&lt;br /&gt;
Dim Tries As Integer&lt;br /&gt;
SendMailMessage = False&lt;br /&gt;
&#39; If session is not open return immediately&lt;br /&gt;
If SStatus &amp;lt;&amp;gt; &quot;Open&quot; Then Exit Function&lt;br /&gt;
&#39; If no current mail message then return immediately&lt;br /&gt;
If MStatus &amp;lt;&amp;gt; &quot;Open&quot; Then Exit Function&lt;br /&gt;
SendMailMessage = True&lt;br /&gt;
On Error GoTo MessError&lt;br /&gt;
Retry:&lt;br /&gt;
FName.MAPIMessages1.Send&lt;br /&gt;
MStatus = &quot;Ready&quot;&lt;br /&gt;
Exit Function&lt;br /&gt;
MessError:&lt;br /&gt;
Tries = Tries + 1&lt;br /&gt;
If Tries &amp;lt; 10 Then GoTo Retry&lt;br /&gt;
SendMailMessage = False&lt;br /&gt;
End Function&lt;br /&gt;
&lt;br /&gt;
&#39; Call this function to save a complete mail message without sending it&lt;br /&gt;
&#39; Example :- MyBool = SaveMailMessage(Me)&lt;br /&gt;
&#39; MyBool will be true if operation succeeded&lt;br /&gt;
&#39; First parameter is reference to form that contains MAPI message / session controls&lt;br /&gt;
Public Function SaveMailMessage(ByRef FName As Form) As Boolean&lt;br /&gt;
SaveMailMessage = False&lt;br /&gt;
&#39; If session is not open return immediately&lt;br /&gt;
If SStatus &amp;lt;&amp;gt; &quot;Open&quot; Then Exit Function&lt;br /&gt;
&#39; If no current mail message then return immediately&lt;br /&gt;
If MStatus &amp;lt;&amp;gt; &quot;Open&quot; Then Exit Function&lt;br /&gt;
SaveMailMessage = True&lt;br /&gt;
On Error GoTo MessError&lt;br /&gt;
FName.MAPIMessages1.Save&lt;br /&gt;
MStatus = &quot;Ready&quot;&lt;br /&gt;
Exit Function&lt;br /&gt;
MessError:&lt;br /&gt;
SaveMailMessage = False&lt;br /&gt;
End Function&lt;br /&gt;
&lt;br /&gt;
&#39; Call this function to address a mail message to a recipient&lt;br /&gt;
&#39; Example :- MyBool = MailMessageTo(Me, &quot;elliot spencer&quot;, Primary)&lt;br /&gt;
&#39; MyBool will be true if operation succeeded. Supply display names from address book&lt;br /&gt;
&#39; list - names will be resolved to addresses in the address book before being added to&lt;br /&gt;
&#39; recipient list.&lt;br /&gt;
&#39; First parameter is reference to form that contains MAPI message / session controls&lt;br /&gt;
&#39; Second parameter is name of recipient (as displayed in address list)&lt;br /&gt;
&#39; Third parameter is type of recipient&lt;br /&gt;
Public Function MailMessageTo(ByRef FName As Form, ToName As String, AddrMode As AddrType) As Boolean&lt;br /&gt;
MailMessageTo = False&lt;br /&gt;
&#39; If session is not open return immediately&lt;br /&gt;
If SStatus &amp;lt;&amp;gt; &quot;Open&quot; Then Exit Function&lt;br /&gt;
&#39; If no current mail message then return immediately&lt;br /&gt;
If MStatus &amp;lt;&amp;gt; &quot;Open&quot; Then Exit Function&lt;br /&gt;
MailMessageTo = True&lt;br /&gt;
On Error GoTo MessError&lt;br /&gt;
FName.MAPIMessages1.RecipIndex = FName.MAPIMessages1.RecipCount &#39; Update count of recipients&lt;br /&gt;
If AddrMode = Primary Then FName.MAPIMessages1.RecipType = 1 &#39; Set to primary recipient type&lt;br /&gt;
If AddrMode = CC Then FName.MAPIMessages1.RecipType = 2 &#39; Set to carbon copy type&lt;br /&gt;
If AddrMode = BlindCC Then FName.MAPIMessages1.RecipType = 3 &#39; Set to blind carbon copy type&lt;br /&gt;
FName.MAPIMessages1.RecipDisplayName = ToName &#39; Display name as provided&lt;br /&gt;
FName.MAPIMessages1.ResolveName &#39; Resolve display name to real address via address book&lt;br /&gt;
Exit Function&lt;br /&gt;
MessError:&lt;br /&gt;
MailMessageTo = False&lt;br /&gt;
End Function&lt;br /&gt;
&lt;br /&gt;
&#39; Call this function to address a mail message to a recipient&lt;br /&gt;
&#39; Example :- MyBool = AddAttachment(Me, &quot;Test File&quot;, &quot;c:\test.txt&quot;, DataFile)&lt;br /&gt;
&#39; MyBool will be true if operation succeeded.&lt;br /&gt;
&#39; First parameter is reference to form that contains MAPI message / session controls&lt;br /&gt;
&#39; Second parameter is name of recipient (as displayed in address list)&lt;br /&gt;
&#39; Third parameter is type of recipient&lt;br /&gt;
Public Function AddAttachment(ByRef FName As Form, AName As String, APath As String, AttMode As AttachType) As Boolean&lt;br /&gt;
AddAttachment = False&lt;br /&gt;
&#39; If session is not open return immediately&lt;br /&gt;
If SStatus &amp;lt;&amp;gt; &quot;Open&quot; Then Exit Function&lt;br /&gt;
&#39; If no current mail message then return immediately&lt;br /&gt;
If MStatus &amp;lt;&amp;gt; &quot;Open&quot; Then Exit Function&lt;br /&gt;
AddAttachment = True &lt;br /&gt;
On Error GoTo MessError&lt;br /&gt;
FName.MAPIMessages1.AttachmentIndex = FName.MAPIMessages1.AttachmentCount &#39; Update count of attachments&lt;br /&gt;
If AttMode = DataFile Then FName.MAPIMessages1.AttachmentType = 0&lt;br /&gt;
If AttMode = OLEEmbedded Then FName.MAPIMessages1.AttachmentType = 1&lt;br /&gt;
If AttMode = OLEStatic Then FName.MAPIMessages1.AttachmentType = 2&lt;br /&gt;
FName.MAPIMessages1.AttachmentPosition = FName.MAPIMessages1.AttachmentIndex&lt;br /&gt;
FName.MAPIMessages1.AttachmentPathName = APath &#39; File or object path as provided&lt;br /&gt;
FName.MAPIMessages1.AttachmentName = AName &#39; File or object name as provided&lt;br /&gt;
Exit Function&lt;br /&gt;
MessError:&lt;br /&gt;
AddAttachment = False&lt;br /&gt;
End Function&lt;br /&gt;
&lt;br /&gt;
&#39; From my registry read module - just to get the default&lt;br /&gt;
&#39; exchange user name (profile name)&lt;br /&gt;
&#39;&lt;br /&gt;
Public Function ReadRegistry(ByVal Group As Long, ByVal Section As String, ByVal Key As String) As String&lt;br /&gt;
Dim lResult As Long, lKeyValue As Long, lDataTypeValue As Long, lValueLength As Long, sValue As String&lt;br /&gt;
On Error Resume Next&lt;br /&gt;
lResult = RegOpenKey(Group, Section, lKeyValue)&lt;br /&gt;
sValue = Space$(2048)&lt;br /&gt;
lValueLength = Len(sValue)&lt;br /&gt;
lResult = RegQueryValueEx(lKeyValue, Key, 0&amp;amp;, lDataTypeValue, sValue, lValueLength)&lt;br /&gt;
If (lResult = 0) And (Err.Number = 0) Then&lt;br /&gt;
&amp;nbsp;&amp;nbsp; sValue = Left$(sValue, lValueLength - 1)&lt;br /&gt;
Else&lt;br /&gt;
&amp;nbsp;&amp;nbsp; sValue = &quot;Not Found&quot;&lt;br /&gt;
End If&lt;br /&gt;
lResult = RegCloseKey(lKeyValue)&lt;br /&gt;
ReadRegistry = sValue&lt;br /&gt;
End Function</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/1859785071911136321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/how-to-send-email-in-vb-60.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/1859785071911136321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/1859785071911136321'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/how-to-send-email-in-vb-60.html' title='How to Send EMAIL in VB 6.0'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-4520741190315272253</id><published>2011-01-15T22:58:00.001+05:30</published><updated>2011-01-15T22:58:52.783+05:30</updated><title type='text'>Crystal Report Questions</title><content type='html'>1 Is it possible to join more than one universe in Business Objects BOE XI? If its so Please explain how is that possible? &lt;br /&gt;
Yes, we can join more than one universe in BO we can join 2 master or kernel universes to one derived universe. To Link the universes go to universe parameters-&amp;gt;links tab-&amp;gt;add link.&lt;br /&gt;
2 How many .rpt files are be there in a main report having 2 &lt;br /&gt;
sub reports? We can keep, one .rpt file for both or we can individually &lt;br /&gt;
create .rpt files and made them as single with sub report.[there are 3 .rpt files including the main and 2 sub report. but when the sub reports are inserted into main it will behave like one only.]&lt;br /&gt;
3 How to Filter the Crystal reports?&lt;br /&gt;
To filter the reports we have to use ?Formulas?.We can prepare the formulas with &lt;br /&gt;
(1) Field Explorer (Window) or (2) Writing the code&lt;br /&gt;
Syntax for preparing the formulas:&lt;br /&gt;
{classname.FieldName}&lt;operator&gt; &amp;amp; value. For Ex:&lt;br /&gt;
?{Employee.Emp_id}=? + value&lt;br /&gt;
?{Employee.Emp_name}=? + value + ??? (Strings to be in single quotes)&lt;br /&gt;
4 How to present data from Crystal Reports on to form?&lt;br /&gt;
Drag Crystal Report viewer control from toolbox to form.Properties:Crystal Report Name: CRV1&lt;br /&gt;
Report Source= &lt;path file=&quot;&quot; of=&quot;&quot; rpt=&quot;&quot; the=&quot;&quot;&gt; or &lt;an file=&quot;&quot; object=&quot;&quot; of=&quot;&quot; rpt=&quot;&quot;&gt;&lt;br /&gt;
And call show () method&lt;br /&gt;
DOCK=Fill (The control resizes while form is resized [Using Crystalviewer]&lt;br /&gt;
5 Is there any feature like summing total in crystal report?&lt;br /&gt;
Yes, we can add any database field afterwards also. Select &lt;br /&gt;
‘Database Field’ in Insert menu item. &lt;br /&gt;
6 Can we use stored procedure for creating the report?&lt;br /&gt;
Can. By Adding Command in Crystal Report XI.&lt;br /&gt;
7 Does Crystal Report support all the functions that we have &lt;br /&gt;
in Oracle?&lt;br /&gt;
No, Crystal report does not support all the functions. Like Decode function is there in SQL but not there is crystal report. You need to convert that in crystal report format (in if and else etc.). &lt;br /&gt;
8 Can we add any database field once we have chosen ?Close? &lt;br /&gt;
button?&lt;br /&gt;
Yes, we can add any database field afterwards also. Select &lt;br /&gt;
Database Field in Insert menu item. &lt;br /&gt;
9 What are the sections that we have in Crystal reports?&lt;br /&gt;
1. report header 2. report footer 3. page header 4. page footer 5. details&lt;br /&gt;
10 Are there any limitations in crystal reports?&lt;br /&gt;
1. In export- While exporting data formatting is lost. &lt;br /&gt;
2. If database is having field whose length is more than 255 characters, then you cannot make formula using that field.&lt;br /&gt;
3.When you browse data just by right clicking on the field then it displays that is there in the database not the data selected by the query. &lt;br /&gt;
[Yes , 1)It will not recognize the HTML tag  .This is giving a problem in order to get a bullet indent for some text display in PDF reports.&lt;br /&gt;
2) Its not possible to customize the length and width of the legend of a chart. &lt;br /&gt;
3) Table object is not given in crystal report. Because of this if we cannot have a table auto grow option as we find it in the MS word table.]&lt;br /&gt;
[Limit of tables I have near about 13000+ tables which are created at runtime. I cannot select these tables I think there is a limit near about 8500]&lt;br /&gt;
[Crystal doesn&#39;t support an LDAP connection.]&lt;br /&gt;
[1) You cannot change the format of the date field used in parameter&lt;br /&gt;
2) You cannot insert sub report into another sub report&lt;br /&gt;
3) You cannot export the report to PDF with group ( it is introduced in Crystal Reports 11 R2)&lt;br /&gt;
4) There is no option to save the report in previous versions] &lt;br /&gt;
11 Can we use our own SQL for creating a report?&lt;br /&gt;
We can also make our own query using Crystal SQL Designer tool provided by SQL. Here you can insert your SQL statement as such. It will save this file as query . And when you create a report instead of using Database button &lt;br /&gt;
use Crystal SQL Statement button. [Yes, Using Crystal SQL writer]&lt;br /&gt;
12 Can we export data of reports into other format like in world doc etc? yes ..u can,  not only in word but also in several formats like pdf, excel. .etc. .u can go to file in the menu in that u have this option&lt;br /&gt;
[Reports can be exported to a number of formats, such as spreadsheet, word processor, HTML, ODBC, and common data interchange formats.&lt;br /&gt;
Go to File-&amp;gt;Export. There are two sub menus, Export Report, Report Export Options. This can be achievable through coding.&lt;br /&gt;
ExportDestinationType eExportDestinationType  =            &lt;br /&gt;
ExportDestinationType.DiskFile;&lt;br /&gt;
ExportFormatType eExportFormatType =           &lt;br /&gt;
ExportFormatType.PortableDocFormat;&lt;br /&gt;
ExportOptions eExportOptions =&lt;br /&gt;
ExportOptions.CreateDiskFileDestinationOptions;]&lt;br /&gt;
[Sure.We can save the crystal report as many formats.There  are Doc ,xsl, .pdf and etc. The sample code i used in my project is given below.&lt;br /&gt;
case &quot;pdf&quot;: {&lt;br /&gt;
//setting disk file name &lt;br /&gt;
crDiskFileDestinationOptions.DiskFileName = &lt;br /&gt;
ExportPath + filename;&lt;br /&gt;
//setting destination type in our case &lt;br /&gt;
disk file&lt;br /&gt;
crExportOptions.DestinationOptions = &lt;br /&gt;
crDiskFileDestinationOptions;&lt;br /&gt;
//setting export format type&lt;br /&gt;
crExportOptions.ExportDestinationType = &lt;br /&gt;
ExportDestinationType.DiskFile;&lt;br /&gt;
//setting previously defined &lt;br /&gt;
destination opions to our input report document&lt;br /&gt;
crExportOptions.ExportFormatType = &lt;br /&gt;
ExportFormatType.PortableDocFormat;&lt;br /&gt;
break; }&lt;br /&gt;
case &quot;xls&quot;: {&lt;br /&gt;
//setting disk file name &lt;br /&gt;
crDiskFileDestinationOptions.DiskFileName = &lt;br /&gt;
ExportPath + filename;&lt;br /&gt;
//setting destination type in our case &lt;br /&gt;
disk file&lt;br /&gt;
crExportOptions.ExportDestinationType = &lt;br /&gt;
ExportDestinationType.DiskFile;&lt;br /&gt;
//setting export format type&lt;br /&gt;
crExportOptions.ExportFormatType = &lt;br /&gt;
ExportFormatType.Excel;&lt;br /&gt;
//setting previously defined &lt;br /&gt;
destination opions to our input report document&lt;br /&gt;
crExportOptions.DestinationOptions = &lt;br /&gt;
crDiskFileDestinationOptions;&lt;br /&gt;
break; }]&lt;br /&gt;
13 Can we create report using more than one database?&lt;br /&gt;
Yes. We can create report using more than one database like Oracle, Access. Create data source name for both the databases. Select tables from them and create the report. Only restriction is if you use two databases then you cannot see the SQL generated by crystal reports. &lt;br /&gt;
14 How do we format field?&lt;br /&gt;
Right click on that field and choose format field.&lt;br /&gt;
15 How do we connect to the database?&lt;br /&gt;
1. Use crystal report built in query. &lt;br /&gt;
2. Use the tool  Crystal SQL Designer provided by crystal report. &lt;br /&gt;
[Most data sources can be chosen through the Database Expert dialog box. The Database Expert appears when you create a report from scratch using Blank Report, or when you choose Database Expert from the Database menu. Note:    You also select a data source in the Report Creation Wizards. The Data screen in all of the Report Creation Wizards, except the OLAP Report Creation Wizard, is much like the Database Expert dialog box.&lt;br /&gt;
To select a data source Choose Database Expert from the Database menu. &lt;br /&gt;
The Database Expert dialog box appears. Use the tree view in the Available Data Sources list of the Data screen to select your data source: Current Connections Favorites History Create New Connection Repository Some popular choices in the Create New Connection folder are described here:&lt;br /&gt;
Access/Excel (DAO), Database Files, ODBC (RDO), OLAP OLE DB (ADO)&lt;br /&gt;
Note:    The data source options available in the Create New Connections folder depend on the data access components selected during installation.]&lt;br /&gt;
16 Can we use Crystal report as a stand-alone application?&lt;br /&gt;
We can make crystal report stand-alone application also. But for that limitation is for viewing the report user should have crystal reports installed &lt;br /&gt;
17 How to &quot;Print&quot; in Crystal Reports while using ASP DOT NET &lt;br /&gt;
Platform?&lt;br /&gt;
using Crystal Decisions. Shared&lt;br /&gt;
CrystalReport1 cr= new CrystalReport1;&lt;br /&gt;
&#39;here crystalreport1 is crystal report which we design.&lt;br /&gt;
CrystalViewer1.ReportSource = cr;&lt;br /&gt;
OR we can directly print the report without showing report&lt;br /&gt;
CrystalReport1 cr= new CrystalReport1;&lt;br /&gt;
cr.PrintToPrinter(1,False,1,1);&lt;br /&gt;
18 What are the advantages or disadvantages of using Crystal &lt;br /&gt;
Reports in a Windows Forms application as opposed to say rolling our own reports as HTML and displaying them in the Internet Explorer control?&lt;br /&gt;
Advantages (1) Secure as End user cannot modify the data which is appear in the report if we use crystal report to show the report but in HTML, user can modify the report data (2) Report layout is not transparent, so that end user will not know about how we design the report. But in HTML, anybody can study the report layout and can copy the technology (3) Can export into different format like PDF, HTML, XML, etc, and many more...&lt;br /&gt;
Disadvantages (1) End user need to have the crystal report viewer in his PC in order to see the crystal report output. But this can be overcome if you export the report as PDF/HTML (2) You need to buy Crystal Report license for each pc you are used to design the crystal report.(3) Must buy the version which allows you to install run time components in end user PC (4) Crystal Report is slow as compare to Active Reports (5) If we have 100 pages report then crystal will need to process all pages and then it shows the output. and many more...&lt;br /&gt;
19 What are Crystal Reports and Crystal Reports Explorer?&lt;br /&gt;
With Crystal reports explorer one can quickly create and modify reports on the web, and since its built on the trusted Business object enterprise platform, it can easily manage massive user loads, individual access, and application customization.&lt;br /&gt;
20 How to conditionally suppress a field based on whether a page number is odd or even?&lt;br /&gt;
Select the fieldClick FORMATClick FORMAT FIELDSelect the COMMON tabClick the FORMULA BUTTON to the right of SUPPRESS&lt;br /&gt;
(Don&#39;t click the suppress check box)&lt;br /&gt;
To suppress a field on odd numbered pages&lt;br /&gt;
PageNumber MOD 2 = 1&lt;br /&gt;
To suppress a field on even numebred pages&lt;br /&gt;
PageNumber MOD 2 = 0 Click SAVE IconClose the formula editorClick OK on the FORMAT screen&lt;br /&gt;
21 How to pass stored Procedure Parameters to the report?&lt;br /&gt;
Choose FileOptions menu. In the Options dialog box Click the Database tab and ensure that Stored Procedures is selected. Selecting &quot;Stored Procedures&quot; automatically displays any available stored procedures when you log on to an SQL database.Click OK to exit the Options dialog box. On the Start Page, click Blank Report.Locate and select the SQL Server data source that contains the stored procedure you want to use.Click Next to go to the Connection Information dialog boxEnter the required information to log in.Click FinishHighlight an SQL stored procedure in the Stored Procedures folder, and click thearrow to add it to the Selected Tables list.&lt;br /&gt;
The Enter Parameter Values dialog box appears.Highlight a parameter in the Parameter Fields listAssign a value by typing into the Discrete Value box and then click OKYou are returned to the Database ExpertClick OK and create your report using the fields in the stored procedure.&lt;br /&gt;
22 What is the &quot;refresh&quot; button suppose to do on the crystal &lt;br /&gt;
Report viewer?&lt;br /&gt;
(1). When you use? Refresh? Button in crystal report viewer, it refreshes the report data. (2).When you refresh data from the Preview tab, the Refresh Report Data dialog box appearsSelect the &quot;Use current parameter values&quot; option to use the current parameter value, Select the &quot;Prompt for new parameter values&quot; optionto enter a new parameter value. When you select this option and click OK, the Enter Prompt Values dialog box appears. The program now runs the report using the new value(s) you specified.&lt;br /&gt;
23 Is there a way to export a report definition without writing code?&lt;br /&gt;
Yes. The following steps work assuming you have Crystal Reports on the machine and the appropriate export dlls loaded.&lt;br /&gt;
Open the reportPreview itClick the EXPORT envelopeSelect REPORT DEFINITION for the formatSelect DISK FILEClick OKEnter a file name or accept the defaultClick SAVE. The file is a text file and can be viewed with NOTEPAD.&lt;br /&gt;
24 Where is the &quot;save data with report&quot; option?&lt;br /&gt;
You can find File menu.&lt;br /&gt;
25 Is there a way to export the report formulas, like totals to excel?&lt;br /&gt;
Yeah we can do that using crystal report&lt;br /&gt;
26 What does it mean when we get the error message &quot;Invalid report version&quot; when try to open a Crystal Report? &lt;br /&gt;
Crystal in its evolution has changed the report file format several times. In most cases the file format is FORWARD-compatible. By this I mean a file created in Crystal 6 can be opened in Crystal 6 or higher. When the file format changes were major the format is not BACKWARD compatible. By this I mean a file created in CR 9 cannot be opened in CR 8 or before. Crystal changed the report file format with CR 8 and CR 9. The CR 9 change was because of the introduction of Unicode support. CR 8 has the ability to save a file in CR 7 format. Because of the support for Unicode CR 9, 10, and XI cannot save the file in previous formats.&lt;br /&gt;
27 How to write a formula to change a font based upon data?&lt;br /&gt;
Select the fieldClick FORMATClick FORMAT FIELDSelect the FONT tabClick the FORMULA BUTTON to the right of FONT&lt;br /&gt;
if ({YourField} = Value) then&lt;br /&gt;
&quot;Arial&quot;&lt;br /&gt;
else&lt;br /&gt;
&quot;Times New Roman&quot;&lt;br /&gt;
Click SAVE IconClose the formula editorClick OK on the FORMAT screen&lt;br /&gt;
28 How to refresh the crystal report from the application?&lt;br /&gt;
calling crystalreportcontrolname.reset (by selecting Report menu under Refresh the report menu item at design time) will refresh the report&lt;br /&gt;
[crystalreport1.DiscardSavedData=True]&lt;br /&gt;
29 How many sub-reports can report can have? 0-256&lt;br /&gt;
30 How many sections are there in the report&lt;br /&gt;
Header, Detail, Footer and Page Header, Report Header, Page Footer, Report Footer [There are several sections. 1)Report header, 2)Page header, 3)Group header, 4)Detail section, 5)Report footer, 6)Page footer And also we can create our own sections if necessary.]&lt;br /&gt;
(collected from http://www.sourcecodesworld.com/faqs/crystal-reports-faq.asp)&lt;br /&gt;
31. What is Crystal Report? &lt;br /&gt;
Ans: Crystal report is a report generation tool. Generally have interface with VB6. Crystal report basically generates dynamic data. You can format the data in whichever way you feel like. &lt;br /&gt;
32. Can we use Crystal report as a stand-alone application? &lt;br /&gt;
Ans: Generally we use Crystal Reports with VB6. However we can make crystal report stand-alone application also. But for that limitation is for viewing the report user should have crystal reports installed on his/her PC. &lt;br /&gt;
33. How do we connect to the database?  &lt;br /&gt;
Ans: There are two ways of creating the report: - &lt;br /&gt;
1. Use crystal report built in query. &lt;br /&gt;
2. Use the tool ‘ Crystal SQL Designer’ provided by crystal report. &lt;br /&gt;
When you create report using crystal report built in query then it asks for the data source name that you have created. When you run the report, then for the first time it will ask for the user id and password. After that it will store the same. &lt;br /&gt;
When you create ‘.qry’ using ‘Crystal SQL’ Designer then at that time it will ask for the user id and password. When you run the report for the first time instead of asking for the user id and password it will ask for the ‘.qry’ file location. You can change the query location also. For that open the report, select ‘Set Location’ option in Database menu item, and set the location. &lt;br /&gt;
34. How do we format field? &lt;br /&gt;
Ans: For formatting any field just right click on it and you will get many options like ‘Format Field.’ ‘Browse field data’ etc. Click on ‘Format Field.’ You can align data, suppress, make it multiline, change the font size, style, and type, make it hyperlink etc. &lt;br /&gt;
If it is an amount field then you can display currency symbol also. Right click on the field select ‘Format Field’. &lt;br /&gt;
35. Can we give parameters to the report? &lt;br /&gt;
Ans: We can very well give parameters to the report. For creating parameters select ‘Parameter Field’ in Insert menu item. ‘Create Parameter Field’ dialog box will popped up, it will ask for the name of parameter, prompting text and datatype. Now when you run the report it will prompt for these parameters. &lt;br /&gt;
36.Can we create our own formulas in reports? &lt;br /&gt;
Ans: We can create our own formulas in reports. Select ‘Formula Field’ in Insert menu item. Write the formula in ‘Formula Editor’. Here you will get ‘Field Tree’, ‘Function Tree’, and ‘Operator Tree’, which will display the report fields, functions that are supported by crystal reports (like CDATE () etc.), operators (arithmetic, strings etc.) respectively. &lt;br /&gt;
37. Can we create report using more than one database? &lt;br /&gt;
Ans: We can create report using more than one database like Oracle, Access. Create data source name for both the databases. Select tables from them and create the report. &lt;br /&gt;
Only restriction is if you use two databases then you cannot see the SQL generated by crystal reports. &lt;br /&gt;
38. Can we export data of reports into other format like in world doc etc? &lt;br /&gt;
Ans: Generated data can be exported to word doc, or in rich text format. Just click on ‘Export’ icon in the menu. Export dialog box will be popped up. It will ask for the ‘Format’ like comma-separated value (csv) etc and the ‘Destination’ like disk, application etc. After that it will ask for the file name and save the data. &lt;br /&gt;
Only restriction is formatting of data will be lost, but crystal report will try to maintain as much formatting as it can. &lt;br /&gt;
39. Can we use our own SQL for creating a report? &lt;br /&gt;
Ans: We can also make our own query using ‘Crystal SQL Designer’ tool provided by SQL. Here you can insert your SQL statement as such. It will save this file as ‘.qry’ . And when you create a report instead of using ‘Database’ button use ‘Crystal SQL Statement’ button. &lt;br /&gt;
40. Can we edit SQL made by Crystal reports? &lt;br /&gt;
Ans: We cannot edit the SQL made by crystal reports. However we can view the SQL. For that select ‘Show SQL Query’ in Database menu item. Limitation is if you are using only one database. If you use two databases then you can’t even view the SQL prepared by crystal report. &lt;br /&gt;
41. Are there any limitations in crystal reports? &lt;br /&gt;
Ans: There are certain limitations in crystal reports. They are: - &lt;br /&gt;
1. If database is having field whose length is more than 255 characters, then you cannot make formula using that field. &lt;br /&gt;
2. While exporting data formatting is lost. &lt;br /&gt;
3. When you browse data just by right clicking on the field then it displays that is there in the database not the data selected by the query. &lt;br /&gt;
42. Can we suppress printing in crystal reports if 0 records are fetched? &lt;br /&gt;
Ans: Yes, we can suppress printing if no records are fetched. Select ‘Report Options’ in File menu item. ‘Report Options’ dialog box will pop up. In that there is one option ‘ Suppress printing if no records’ Check this option. If no records are found then nothing will be printed on the report. &lt;br /&gt;
43. What are the sections that we have in Crystal reports? &lt;br /&gt;
Ans: Report has got standard sections like ‘Page Header’, ‘Page Footer’, ‘Report Header’, ‘Report Footer’, and ‘Details’. &lt;br /&gt;
However you can add other sections also. Select ‘Sections’ in the Insert menu item. You can insert group sections also. &lt;br /&gt;
If you don’t want to show any section just right click on that section and suppress that. &lt;br /&gt;
44. Can we add any database field once we have chosen ‘Close’ button? &lt;br /&gt;
Ans: Yes, we can add any database field afterwards also. Select ‘Database Field’ in Insert menu item. &lt;br /&gt;
If you are using crystal report built in query then it will display the tables that you have selected. And you can select whichever field you want to display on the report. &lt;br /&gt;
But if you are using ‘.qry’ file then it will display Query and you can select only those field, which are there in the query. &lt;br /&gt;
45. Does Crystal Report support all the functions that we have in Oracle? &lt;br /&gt;
Ans: No, Crystal report does not support all the functions. Like Decode function is there in SQL but not there is crystal report. You need to convert that in crystal report format (in if and else etc.). &lt;br /&gt;
However if you use ‘.qry’ files then it take the SQL as such. There is no need of changing any syntax. &lt;br /&gt;
46. Can we use stored procedure for creating the report? &lt;br /&gt;
Ans: Yes, we can use stored procedure. &lt;br /&gt;
47. Is there any feature like summing total in crystal report? &lt;br /&gt;
Ans: Crystal reports provide features like grand total, sub-total, running total etc. You can select any of these features in Insert menu item. &lt;br /&gt;
You can sum up records on the basis of each record or on change of group using ‘Running Total ‘ option in Insert menu item. &lt;br /&gt;
48. I am using two tables one is of access database and other is of oracle database, I am getting an error saying that ‘SQL odbc error’ what should I do? &lt;br /&gt;
Ans: If you are getting such an error then click the icon for ‘Report Expert’. It will give a warning saying that formatting will be lost. Ignore this you will get ‘Standard Report Expert’ dialog box. Reverse the links of access database table and it will work. &lt;br /&gt;
49 What versions of Crystal Reports have you used?&lt;br /&gt;
Please indicate both release version (9, 10, XI) and type of version (.NET or standalone boxed exition, for example). A)  I was willing to consider individuals who were primarily programming version users, if they were able to adequately answer questions about Crystal Reports functionality.  It has been my experience, however, that &quot;programmer&quot; Crystal Reports writers have vastly different skill sets and opinions about solutions that &quot;report writer&quot; or &quot;business user&quot; Crystal Reports writers.&lt;br /&gt;
50 What is &#39;Set Location&#39;&lt;br /&gt;
A)  This is very basic Crystal Reports functionality.  If the candidate doesn&#39;t know what this is, then that&#39;s a red flag.&lt;br /&gt;
51 Please describe, in plain English, the most complex report you&#39;ve ever written.  What made it complex and how did you resolve the issues that presented themselves?&lt;br /&gt;
A)  This question helps me to understand their level of understanding of functionality, their ability to potentially address complex requirements and their creativity.&lt;br /&gt;
52 Have you ever written a repot against a View or Stored Procedure?&lt;br /&gt;
A)  No?  They might be skilled in Crystal Reports, but may not understand the relationship between Crystal and the database.  They may also not be skilled in SQL. &lt;br /&gt;
53 Is it better to build a report against a View or a Stored Procedure and why?  Please explain...&lt;br /&gt;
A)  This is a very good question, in my opinion.  First, the right answer is neither.  It really depends on the situation.  That being said, there is a contingent of report writers out there that have been brainwashed into saying a &#39;stored procedure is always better, because its pre-compiled&#39;.  In my opinion, this is bunk and here&#39;s&lt;br /&gt;
why: A stored procedure is absolutely great to use if you&#39;re going to manipulate a lot of data or crunch a lot of numbers to return aggregates.  If you&#39;re simply creating a SELECT/FROM/WHERE query, it&#39;s a complete waste.  Furthermore, using a Stored Procedure (or a SQL Command Object, for that matter) can severely limit the functionality you would otherwise have in Crystal Reports.  For example, a common report requirement is to have a parameter that allows the user to select one, multiple or all items in the parameter list.  Crystal Reports allows this functionality through multi-value parameter selection.   Stored procedures do not allow this functionality...&lt;br /&gt;
** A View can be written to contain all of the necessary fields, joins, subqueries, etc..., but still be open enough to be used by a variety of reports.  For example, I have a client who needed 15 reports, all of which were to be written against a particular module of their application.  All of the reports had very similar fields, they were mostly just different in display and in the selection criteria.  As such, I created a single view with both a SELECT and FROM clause, but no WHERE clause.  I then built the 15 different reports all against the same view, but added selection criteria to each report.  By doing so, they all used a single, easily maintainable database object, but were each unique and efficient.&lt;br /&gt;
55  What is a SQL Expression field in Crystal Reports? (collected from the site http://www.allinterview.com/Interview-Questions/Crystal-Reports/page3.html)&lt;br /&gt;
&lt;br /&gt;
56 what is the difference between crystal reports and normal reports?&lt;br /&gt;
in crystal reports we can genarate reports with any type of charts (bar charts,pie charts) it is automatically genarated when we give values vto it,but that is not possible with genaral reports we manually should caluculate every thing&lt;br /&gt;
57 What is FSG and its use ? Financial Statement Generator is a powerful report building tool for Oracle GL. Uses of FSG :1. Generate financial reports such as income statements an&lt;br /&gt;
58 What is Reporting Services Microsoft SQL Server Reporting Services is server-based reporting platform similar to Crystal reports, Brio which allow you to create tabular, matrix,&lt;br /&gt;
59 what is different the vb.net and XML?&lt;br /&gt;
vb.net is product of micro soft corporation.it is for developing appication programs.&lt;br /&gt;
xml is an open standerd one.it is for representing data.xml is not restricted to &lt;br /&gt;
the particular language.we can use to represent data of any type of application.XML is common one.for bussiness to bussiness communication XML is Best one. &lt;br /&gt;
&lt;br /&gt;
&lt;/an&gt;&lt;/path&gt;&lt;/operator&gt;</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/4520741190315272253/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/crystal-report-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/4520741190315272253'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/4520741190315272253'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/crystal-report-questions.html' title='Crystal Report Questions'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-1627669231081817688</id><published>2011-01-15T22:57:00.000+05:30</published><updated>2011-01-15T22:57:00.252+05:30</updated><title type='text'>How to access serial and parallel ports by using Visual Basic .NET</title><content type='html'>How to access serial and parallel ports by using Visual Basic .NET&lt;br /&gt;
View products that this article applies to.&lt;br /&gt;
 For a Microsoft Visual Studio 2005 version of this article, see 904795  (http://support.microsoft.com/kb/904795/ ) . &lt;br /&gt;
On This Page&lt;br /&gt;
•  SUMMARY&lt;br /&gt;
o  Requirements&lt;br /&gt;
o  Use the MSComm control in Visual Basic .NET to access serial ports&lt;br /&gt;
o  Use platform invoke services to call Win32 API functions in Visual Basic .NET to access serial and parallel ports&lt;br /&gt;
o  Sample code listing (Module1.vb)&lt;br /&gt;
o  Troubleshoot&lt;br /&gt;
•  REFERENCES&lt;br /&gt;
 Expand all | Collapse all &lt;br /&gt;
SUMMARY&lt;br /&gt;
This step-by-step article describes how to access serial ports and how to acces...&lt;br /&gt;
 This step-by-step article describes how to access serial ports and how to access parallel ports by using Microsoft Visual Basic .NET. This article also contains sample code that illustrates the concepts that are discussed in this article.&lt;br /&gt;
 Back to the top&lt;br /&gt;
Requirements&lt;br /&gt;
 The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:&lt;br /&gt;
• Microsoft Windows Server 2003, Microsoft Windows XP, or Microsoft Windows 2000&lt;br /&gt;
• Visual Basic .NET&lt;br /&gt;
This article assumes that you are familiar with the following topics: &lt;br /&gt;
• Programming in Visual Basic .NET&lt;br /&gt;
• Platform invoke services in Visual Basic .NET&lt;br /&gt;
 Back to the top&lt;br /&gt;
Use the MSComm control in Visual Basic .NET to access serial ports&lt;br /&gt;
 Because no Microsoft .NET Framework classes exist to access the communications resources that connected to your computer, you can use the MSComm control in Microsoft Visual Basic 6.0. The MSComm control provides serial communications for your application by enabling the transmission and reception of data through a serial port. To implement basic serial communications by using a modem, follow these steps: &lt;br /&gt;
1. Start Microsoft Visual Studio .NET.&lt;br /&gt;
2. On the File menu, point to New, and then click Project.&lt;br /&gt;
3. Under Project Types, click Visual Basic Projects.&lt;br /&gt;
4. Under Templates, click Console Application.&lt;br /&gt;
5. In the Name box, type MyConsoleApplication, and then click OK. &lt;br /&gt;
&lt;br /&gt;
By default, Module1.vb is created.&lt;br /&gt;
6. Right-click the MyConsoleApplication project, and then click Add Reference.&lt;br /&gt;
7. Click the COM tab, click Microsoft Comm Control 6.0 under Component Name, click Select, and then click OK.&lt;br /&gt;
&lt;br /&gt;
Note To use the MSComm control, you must install the related COM components of Microsoft Visual Basic 6.0 on the same computer that has Microsoft Visual Studio .NET installed.&lt;br /&gt;
&lt;br /&gt;
For more information about license issues when you use Visual Basic 6.0 controls in Visual Studio .NET, click the following article number to view the article in the Microsoft Knowledge Base: &lt;br /&gt;
318597  (http://support.microsoft.com/kb/318597/ ) Errors when you use Visual Basic 6.0 controls in Visual Studio .NET &lt;br /&gt;
8. Replace the code in Module1.vb with the following code example.&lt;br /&gt;
9. Imports MSCommLib&lt;br /&gt;
10. &lt;br /&gt;
11. Module Module1&lt;br /&gt;
12. &lt;br /&gt;
13.     Sub Main()&lt;br /&gt;
14.         &#39;New a MSComm control&lt;br /&gt;
15.         Dim MSComm1 As MSComm&lt;br /&gt;
16.         MSComm1 = New MSComm&lt;br /&gt;
17.         &#39; Buffer to hold input string.&lt;br /&gt;
18.         Dim Buffer As String&lt;br /&gt;
19.         &#39; Use the COM1 serial port.&lt;br /&gt;
20.         MSComm1.CommPort = 1&lt;br /&gt;
21.         &#39; 9600 baud, no parity, 8 data, and 1 stop bit.&lt;br /&gt;
22.         MSComm1.Settings = &quot;9600,N,8,1&quot;&lt;br /&gt;
23.         &#39; Tell the control to read the whole buffer when Input is used.&lt;br /&gt;
24.         MSComm1.InputLen = 0&lt;br /&gt;
25.         &#39; Open the serial port.&lt;br /&gt;
26.         MSComm1.PortOpen = True&lt;br /&gt;
27.         Console.WriteLine(&quot;Open the serial port.&quot;)&lt;br /&gt;
28.         &#39; Tell the control to make the Input property return text data.&lt;br /&gt;
29.         MSComm1.InputMode() = InputModeConstants.comInputModeText&lt;br /&gt;
30.         &#39;Clear the receive buffer.&lt;br /&gt;
31.         MSComm1.InBufferCount() = 0&lt;br /&gt;
32.         &#39; Send the attention command to the modem.&lt;br /&gt;
33.         MSComm1.Output = &quot;ATV1Q0&quot; &amp; Chr(13)&lt;br /&gt;
34.         Console.WriteLine(&quot;Send the attention command to the modem.&quot;)&lt;br /&gt;
35.         Console.WriteLine(&quot;Wait for the data to come back to the serial port...&quot;)&lt;br /&gt;
36.         &#39; Make sure that the modem responds with &quot;OK&quot;.&lt;br /&gt;
37.         &#39; Wait for the data to come back to the serial port.&lt;br /&gt;
38.         Do&lt;br /&gt;
39.             Buffer = Buffer &amp; MSComm1.Input&lt;br /&gt;
40.         Loop Until InStr(Buffer, &quot;OK&quot; &amp; vbCrLf)&lt;br /&gt;
41.         &#39; Read the &quot;OK&quot; response data in the serial port.&lt;br /&gt;
42.         &#39; Close the serial port.&lt;br /&gt;
43.         Console.WriteLine(&quot;Read the OK response data in the serial port.&quot;)&lt;br /&gt;
44.         MSComm1.PortOpen = False&lt;br /&gt;
45.         Console.WriteLine(&quot;Close the serial port.&quot;)&lt;br /&gt;
46.     End Sub&lt;br /&gt;
47. &lt;br /&gt;
End Module&lt;br /&gt;
48. Press CRTL+F5 to build and run this project. You will receive the following output messages: &lt;br /&gt;
Open the serial port.&lt;br /&gt;
Send the attention command to the modem.&lt;br /&gt;
Wait for data to come back to the serial port...&lt;br /&gt;
Read the OK response data in the serial port.&lt;br /&gt;
Close the serial port. &lt;br /&gt;
 Back to the top&lt;br /&gt;
Use platform invoke services to call Win32 API functions in Visual Basic .NET to access serial and parallel ports&lt;br /&gt;
 To do this, follow these steps: &lt;br /&gt;
1. Start Microsoft Visual Studio .NET.&lt;br /&gt;
2. On the File menu, point to New, and then click Project.&lt;br /&gt;
3. Under Project Types, click Visual Basic Projects.&lt;br /&gt;
4. Under Templates, click Console Application.&lt;br /&gt;
5. In the Name text box, type MyConsoleApplication, and then click OK.&lt;br /&gt;
&lt;br /&gt;
By default, Module1.vb is created.&lt;br /&gt;
6. Add the following code to Module1.vb before the Module Module1 statement:&lt;br /&gt;
7. Option Strict On&lt;br /&gt;
8. &lt;br /&gt;
9. &#39; Define a CommException class that inherits from the ApplicationException class, &lt;br /&gt;
10. &#39; and then throw an object of type CommException when you receive an error message.&lt;br /&gt;
11. Class CommException&lt;br /&gt;
12.    Inherits ApplicationException&lt;br /&gt;
13.    Sub New(ByVal Reason As String)&lt;br /&gt;
14.       MyBase.New(Reason)&lt;br /&gt;
15.    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
16. Declare structures, constants, and references to external functions that are in Kernel32.dll&lt;br /&gt;
&lt;br /&gt;
To call unmanaged functions from your managed Visual Basic .NET application, you must declare references to the structures that you pass as parameters to the unmanaged functions, and you must declare the constants that you pass as parameters to the unmanaged functions. To do this, add the following code to Module1.vb after the Module Module1 statement:&lt;br /&gt;
17. &#39;Declare structures.&lt;br /&gt;
18.    Public Structure DCB&lt;br /&gt;
19.    Public DCBlength As Int32&lt;br /&gt;
20.    Public BaudRate As Int32&lt;br /&gt;
21.    Public fBitFields As Int32 &#39;See Comments in Win32API.Txt&lt;br /&gt;
22.    Public wReserved As Int16&lt;br /&gt;
23.    Public XonLim As Int16&lt;br /&gt;
24.    Public XoffLim As Int16&lt;br /&gt;
25.    Public ByteSize As Byte&lt;br /&gt;
26.    Public Parity As Byte&lt;br /&gt;
27.    Public StopBits As Byte&lt;br /&gt;
28.    Public XonChar As Byte&lt;br /&gt;
29.    Public XoffChar As Byte&lt;br /&gt;
30.    Public ErrorChar As Byte&lt;br /&gt;
31.    Public EofChar As Byte&lt;br /&gt;
32.    Public EvtChar As Byte&lt;br /&gt;
33.    Public wReserved1 As Int16 &#39;Reserved; Do Not Use&lt;br /&gt;
34. End Structure&lt;br /&gt;
35. &lt;br /&gt;
36. Public Structure COMMTIMEOUTS&lt;br /&gt;
37.    Public ReadIntervalTimeout As Int32&lt;br /&gt;
38.    Public ReadTotalTimeoutMultiplier As Int32&lt;br /&gt;
39.    Public ReadTotalTimeoutConstant As Int32&lt;br /&gt;
40.    Public WriteTotalTimeoutMultiplier As Int32&lt;br /&gt;
41.    Public WriteTotalTimeoutConstant As Int32&lt;br /&gt;
42. End Structure&lt;br /&gt;
43. &lt;br /&gt;
44. &#39;Declare constants.&lt;br /&gt;
45. Public Const GENERIC_READ As Int32 = &amp;H80000000&lt;br /&gt;
46. Public Const GENERIC_WRITE As Int32 = &amp;H40000000&lt;br /&gt;
47. Public Const OPEN_EXISTING As Int32 = 3&lt;br /&gt;
48. Public Const FILE_ATTRIBUTE_NORMAL As Int32 = &amp;H80&lt;br /&gt;
49. Public Const NOPARITY As Int32 = 0&lt;br /&gt;
50. Public Const ONESTOPBIT As Int32 = 0&lt;br /&gt;
51. &lt;br /&gt;
52. &#39;Declare references to external functions.&lt;br /&gt;
53. Public Declare Auto Function CreateFile Lib &quot;kernel32.dll&quot; _&lt;br /&gt;
54.    (ByVal lpFileName As String, ByVal dwDesiredAccess As Int32, _&lt;br /&gt;
55.       ByVal dwShareMode As Int32, ByVal lpSecurityAttributes As IntPtr, _&lt;br /&gt;
56.          ByVal dwCreationDisposition As Int32, ByVal dwFlagsAndAttributes As Int32, _&lt;br /&gt;
57.             ByVal hTemplateFile As IntPtr) As IntPtr&lt;br /&gt;
58. &lt;br /&gt;
59. Public Declare Auto Function GetCommState Lib &quot;kernel32.dll&quot; (ByVal nCid As IntPtr, _&lt;br /&gt;
60.    ByRef lpDCB As DCB) As Boolean&lt;br /&gt;
61. &lt;br /&gt;
62. Public Declare Auto Function SetCommState Lib &quot;kernel32.dll&quot; (ByVal nCid As IntPtr, _&lt;br /&gt;
63.    ByRef lpDCB As DCB) As Boolean&lt;br /&gt;
64. &lt;br /&gt;
65. Public Declare Auto Function GetCommTimeouts Lib &quot;kernel32.dll&quot; (ByVal hFile As IntPtr, _&lt;br /&gt;
66.    ByRef lpCommTimeouts As COMMTIMEOUTS) As Boolean&lt;br /&gt;
67. &lt;br /&gt;
68. Public Declare Auto Function SetCommTimeouts Lib &quot;kernel32.dll&quot; (ByVal hFile As IntPtr, _&lt;br /&gt;
69.    ByRef lpCommTimeouts As COMMTIMEOUTS) As Boolean&lt;br /&gt;
70. &lt;br /&gt;
71. Public Declare Auto Function WriteFile Lib &quot;kernel32.dll&quot; (ByVal hFile As IntPtr, _&lt;br /&gt;
72.    ByVal lpBuffer As Byte(), ByVal nNumberOfBytesToWrite As Int32, _&lt;br /&gt;
73.       ByRef lpNumberOfBytesWritten As Int32, ByVal lpOverlapped As IntPtr) As Boolean&lt;br /&gt;
74. &lt;br /&gt;
75. Public Declare Auto Function ReadFile Lib &quot;kernel32.dll&quot; (ByVal hFile As IntPtr, _&lt;br /&gt;
76.    ByVal lpBuffer As Byte(), ByVal nNumberOfBytesToRead As Int32, _&lt;br /&gt;
77.       ByRef lpNumberOfBytesRead As Int32, ByVal lpOverlapped As IntPtr) As Boolean&lt;br /&gt;
78. &lt;br /&gt;
Public Declare Auto Function CloseHandle Lib &quot;kernel32.dll&quot; (ByVal hObject As IntPtr) As Boolean&lt;br /&gt;
79. Before you can access a serial port or a parallel port, you must obtain a handle to the appropriate port and then configure the port communications. To do this, add the following initialization code to Module1.vb after the Sub Main statement.&lt;br /&gt;
&lt;br /&gt;
Note To establish communication with the LPTx port, you must stop the Print Spooler service. To do this, use the Services tool in Administrative Tools.&lt;br /&gt;
80. &#39; Declare the local variables that you will use in the code.&lt;br /&gt;
81. Dim hSerialPort, hParallelPort As IntPtr&lt;br /&gt;
82. Dim Success As Boolean&lt;br /&gt;
83. Dim MyDCB As DCB&lt;br /&gt;
84. Dim MyCommTimeouts As COMMTIMEOUTS&lt;br /&gt;
85. Dim BytesWritten, BytesRead As Int32&lt;br /&gt;
86. Dim Buffer() As Byte&lt;br /&gt;
87. &lt;br /&gt;
88. &#39; Declare the variables to use for encoding.&lt;br /&gt;
89. Dim oEncoder As New System.Text.ASCIIEncoding&lt;br /&gt;
90. Dim oEnc As System.Text.Encoding = oEncoder.GetEncoding(1252)&lt;br /&gt;
91. &lt;br /&gt;
92. &#39; Convert String to Byte().&lt;br /&gt;
93. Buffer = oEnc.GetBytes(&quot;Test&quot;)&lt;br /&gt;
94.      Try&lt;br /&gt;
95.          &#39; Access the serial port.&lt;br /&gt;
96.          Console.WriteLine(&quot;Accessing the COM1 serial port&quot;)&lt;br /&gt;
97.          &#39; Obtain a handle to the COM1 serial port.&lt;br /&gt;
98.          hSerialPort = CreateFile(&quot;COM1&quot;, GENERIC_READ Or GENERIC_WRITE, 0, IntPtr.Zero, _&lt;br /&gt;
99.             OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, IntPtr.Zero)&lt;br /&gt;
100.          &#39; Verify that the obtained handle is valid.&lt;br /&gt;
101.          If hSerialPort.ToInt32 = -1 Then&lt;br /&gt;
102.             Throw New CommException(&quot;Unable to obtain a handle to the COM1 port&quot;)&lt;br /&gt;
103.          End If&lt;br /&gt;
104.          &#39; Retrieve the current control settings.&lt;br /&gt;
105.          Success = GetCommState(hSerialPort, MyDCB)&lt;br /&gt;
106.          If Success = False Then&lt;br /&gt;
107.             Throw New CommException(&quot;Unable to retrieve the current control settings&quot;)&lt;br /&gt;
108.          End If&lt;br /&gt;
109.          &#39; Modify the properties of the retrieved DCB structure as appropriate.&lt;br /&gt;
110.          &#39; WARNING: Make sure to modify the properties according to their supported values.&lt;br /&gt;
111.          MyDCB.BaudRate = 9600&lt;br /&gt;
112.          MyDCB.ByteSize = 8&lt;br /&gt;
113.          MyDCB.Parity = NOPARITY&lt;br /&gt;
114.          MyDCB.StopBits = ONESTOPBIT&lt;br /&gt;
115.          &#39; Reconfigure COM1 based on the properties of the modified DCB structure.&lt;br /&gt;
116.          Success = SetCommState(hSerialPort, MyDCB)&lt;br /&gt;
117.          If Success = False Then&lt;br /&gt;
118.             Throw New CommException(&quot;Unable to reconfigure COM1&quot;)&lt;br /&gt;
119.          End If&lt;br /&gt;
120.          &#39; Retrieve the current time-out settings.&lt;br /&gt;
121.          Success = GetCommTimeouts(hSerialPort, MyCommTimeouts)&lt;br /&gt;
122.          If Success = False Then&lt;br /&gt;
123.             Throw New CommException(&quot;Unable to retrieve current time-out settings&quot;)&lt;br /&gt;
124.          End If&lt;br /&gt;
125.          &#39; Modify the properties of the retrieved COMMTIMEOUTS structure as appropriate.&lt;br /&gt;
126.          &#39; WARNING: Make sure to modify the properties according to their supported values.&lt;br /&gt;
127.          MyCommTimeouts.ReadIntervalTimeout = 0&lt;br /&gt;
128.          MyCommTimeouts.ReadTotalTimeoutConstant = 0&lt;br /&gt;
129.          MyCommTimeouts.ReadTotalTimeoutMultiplier = 0&lt;br /&gt;
130.          MyCommTimeouts.WriteTotalTimeoutConstant = 0&lt;br /&gt;
131.          MyCommTimeouts.WriteTotalTimeoutMultiplier = 0&lt;br /&gt;
132.          &#39; Reconfigure the time-out settings, based on the properties of the modified COMMTIMEOUTS structure.&lt;br /&gt;
133.          Success = SetCommTimeouts(hSerialPort, MyCommTimeouts)&lt;br /&gt;
134.          If Success = False Then&lt;br /&gt;
135.             Throw New CommException(&quot;Unable to reconfigure the time-out settings&quot;)&lt;br /&gt;
136.          End If&lt;br /&gt;
137.          &#39; Write data to COM1.&lt;br /&gt;
138.          Console.WriteLine(&quot;Writing the following data to COM1: Test&quot;)&lt;br /&gt;
139.          Success = WriteFile(hSerialPort, Buffer, Buffer.Length, BytesWritten, IntPtr.Zero)&lt;br /&gt;
140.          If Success = False Then&lt;br /&gt;
141.             Throw New CommException(&quot;Unable to write to COM1&quot;)&lt;br /&gt;
142.          End If&lt;br /&gt;
143.          &#39; Read data from COM1.&lt;br /&gt;
144.          Success = ReadFile(hSerialPort, Buffer, BytesWritten, BytesRead, IntPtr.Zero)&lt;br /&gt;
145.          If Success = False Then&lt;br /&gt;
146.             Throw New CommException(&quot;Unable to read from COM1&quot;)&lt;br /&gt;
147.          End If&lt;br /&gt;
148.       Catch ex As Exception&lt;br /&gt;
149.          Console.WriteLine(Ex.Message)&lt;br /&gt;
150.       Finally&lt;br /&gt;
151.          &#39; Release the handle to COM1.&lt;br /&gt;
152.          Success = CloseHandle(hSerialPort)&lt;br /&gt;
153.          If Success = False Then&lt;br /&gt;
154.             Console.WriteLine(&quot;Unable to release handle to COM1&quot;)&lt;br /&gt;
155.          End If&lt;br /&gt;
156.       End Try&lt;br /&gt;
157. &lt;br /&gt;
158.       Try&lt;br /&gt;
159.          &#39; Parallel port.&lt;br /&gt;
160.          Console.WriteLine(&quot;Accessing the LPT1 parallel port&quot;)&lt;br /&gt;
161.          &#39; Obtain a handle to the LPT1 parallel port.&lt;br /&gt;
162.          hParallelPort = CreateFile(&quot;LPT1&quot;, GENERIC_READ Or GENERIC_WRITE, 0, IntPtr.Zero, _&lt;br /&gt;
163.             OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, IntPtr.Zero)&lt;br /&gt;
164.          &#39; Verify that the obtained handle is valid.&lt;br /&gt;
165.          If hParallelPort.ToInt32 = -1 Then&lt;br /&gt;
166.             Throw New CommException(&quot;Unable to obtain a handle to the LPT1 port&quot;)&lt;br /&gt;
167.          End If&lt;br /&gt;
168.          &#39; Retrieve the current control settings.&lt;br /&gt;
169.          Success = GetCommState(hParallelPort, MyDCB)&lt;br /&gt;
170.          If Success = False Then&lt;br /&gt;
171.             Throw New CommException(&quot;Unable to retrieve the current control settings&quot;)&lt;br /&gt;
172.          End If&lt;br /&gt;
173.          &#39; Modify the properties of the retrieved DCB structure as appropriate.&lt;br /&gt;
174.          &#39; WARNING: Make sure to modify the properties according to their supported values.&lt;br /&gt;
175.          MyDCB.BaudRate = 9600&lt;br /&gt;
176.          MyDCB.ByteSize = 8&lt;br /&gt;
177.          MyDCB.Parity = NOPARITY&lt;br /&gt;
178.          MyDCB.StopBits = ONESTOPBIT&lt;br /&gt;
179.          &#39; Reconfigure LPT1 based on the properties of the modified DCB structure.&lt;br /&gt;
180.          Success = SetCommState(hParallelPort, MyDCB)&lt;br /&gt;
181.          If Success = False Then&lt;br /&gt;
182.             Throw New CommException(&quot;Unable to reconfigure LPT1&quot;)&lt;br /&gt;
183.          End If&lt;br /&gt;
184.          &#39; Retrieve the current time-out settings.&lt;br /&gt;
185.          Success = GetCommTimeouts(hParallelPort, MyCommTimeouts)&lt;br /&gt;
186.          If Success = False Then&lt;br /&gt;
187.             Throw New CommException(&quot;Unable to retrieve current time-out settings&quot;)&lt;br /&gt;
188.          End If&lt;br /&gt;
189.          &#39; Modify the properties of the retrieved COMMTIMEOUTS structure as appropriate. &lt;br /&gt;
190.          &#39; WARNING: Make sure to modify the properties according to their supported values.&lt;br /&gt;
191.          MyCommTimeouts.ReadIntervalTimeout = 0&lt;br /&gt;
192.          MyCommTimeouts.ReadTotalTimeoutConstant = 0&lt;br /&gt;
193.          MyCommTimeouts.ReadTotalTimeoutMultiplier = 0&lt;br /&gt;
194.          MyCommTimeouts.WriteTotalTimeoutConstant = 0&lt;br /&gt;
195.          MyCommTimeouts.WriteTotalTimeoutMultiplier = 0&lt;br /&gt;
196.          &#39; Reconfigure the time-out settings, based on the properties of the modified COMMTIMEOUTS structure.&lt;br /&gt;
197.          Success = SetCommTimeouts(hParallelPort, MyCommTimeouts)&lt;br /&gt;
198.          If Success = False Then&lt;br /&gt;
199.             Throw New CommException(&quot;Unable to reconfigure the time-out settings&quot;)&lt;br /&gt;
200.          End If&lt;br /&gt;
201.          &#39; Write data to LPT1.&lt;br /&gt;
202.          &#39; Note: You cannot read data from a parallel port by calling the ReadFile function.&lt;br /&gt;
203.          Console.WriteLine(&quot;Writing the following data to LPT1: Test&quot;)&lt;br /&gt;
204.          Success = WriteFile(hParallelPort, Buffer, Buffer.Length, BytesWritten, IntPtr.Zero)&lt;br /&gt;
205.          If Success = False Then&lt;br /&gt;
206.             Throw New CommException(&quot;Unable to write to LPT1&quot;)&lt;br /&gt;
207.          End If&lt;br /&gt;
208.       Catch ex As Exception&lt;br /&gt;
209.          Console.WriteLine(Ex.Message)&lt;br /&gt;
210.       Finally&lt;br /&gt;
211.          &#39; Release the handle to LPT1.&lt;br /&gt;
212.          Success = CloseHandle(hParallelPort)&lt;br /&gt;
213.          If Success = False Then&lt;br /&gt;
214.             Console.WriteLine(&quot;Unable to release handle to LPT1&quot;)&lt;br /&gt;
215.          End If&lt;br /&gt;
216.       End Try&lt;br /&gt;
217. &lt;br /&gt;
218.       Console.WriteLine(&quot;Press ENTER to quit&quot;)&lt;br /&gt;
219.       Console.ReadLine()&lt;br /&gt;
220. On the Build menu, click Build Solution.&lt;br /&gt;
221. On the Debug menu, click Start to run the application.&lt;br /&gt;
&lt;br /&gt;
You may receive the following text in the console: &lt;br /&gt;
Accessing the COM1 serial port&lt;br /&gt;
Writing the following data to COM1: Test &lt;br /&gt;
&lt;br /&gt;
Read the following data from COM1: Serial Data&lt;br /&gt;
Accessing the LPT1 parallel port &lt;br /&gt;
&lt;br /&gt;
Writing the following data to LPT1: Test &lt;br /&gt;
&lt;br /&gt;
Press ENTER to quit&lt;br /&gt;
Note Serial Data represents the data that you read from the serial port.&lt;br /&gt;
222. To close the application, press the ENTER key in the console.&lt;br /&gt;
 Back to the top&lt;br /&gt;
Sample code listing (Module1.vb)&lt;br /&gt;
 Before you use the following code example, replace COM1 with the name of your serial port, and replace LPT1 with the name of your parallel port.&lt;br /&gt;
&lt;br /&gt;
Note The following code works only when serial devices and parallel devices are connected to the corresponding ports on the computer. If you do not connect these devices and you run the program, the program waits indefinitely.&lt;br /&gt;
Option Strict On&lt;br /&gt;
&lt;br /&gt;
&#39; Define a CommException class that inherits from the ApplicationException class.&lt;br /&gt;
&#39; Then throw an object of type CommException when you receive an error message.&lt;br /&gt;
Class CommException&lt;br /&gt;
   Inherits ApplicationException&lt;br /&gt;
   Sub New(ByVal Reason As String)&lt;br /&gt;
      MyBase.New(Reason)&lt;br /&gt;
   End Sub&lt;br /&gt;
End Class&lt;br /&gt;
&lt;br /&gt;
Module Module1&lt;br /&gt;
      &#39;Declare structures&lt;br /&gt;
      Public Structure DCB&lt;br /&gt;
      Public DCBlength As Int32&lt;br /&gt;
      Public BaudRate As Int32&lt;br /&gt;
      Public fBitFields As Int32&lt;br /&gt;
      Public wReserved As Int16&lt;br /&gt;
      Public XonLim As Int16&lt;br /&gt;
      Public XoffLim As Int16&lt;br /&gt;
      Public ByteSize As Byte&lt;br /&gt;
      Public Parity As Byte&lt;br /&gt;
      Public StopBits As Byte&lt;br /&gt;
      Public XonChar As Byte&lt;br /&gt;
      Public XoffChar As Byte&lt;br /&gt;
      Public ErrorChar As Byte&lt;br /&gt;
      Public EofChar As Byte&lt;br /&gt;
      Public EvtChar As Byte&lt;br /&gt;
      Public wReserved1 As Int16 &#39;Reserved; Do Not Use&lt;br /&gt;
   End Structure&lt;br /&gt;
&lt;br /&gt;
   Public Structure COMMTIMEOUTS&lt;br /&gt;
      Public ReadIntervalTimeout As Int32&lt;br /&gt;
      Public ReadTotalTimeoutMultiplier As Int32&lt;br /&gt;
      Public ReadTotalTimeoutConstant As Int32&lt;br /&gt;
      Public WriteTotalTimeoutMultiplier As Int32&lt;br /&gt;
      Public WriteTotalTimeoutConstant As Int32&lt;br /&gt;
   End Structure&lt;br /&gt;
&lt;br /&gt;
   &#39;Declare constants.&lt;br /&gt;
   Public Const GENERIC_READ As Int32 = &amp;H80000000&lt;br /&gt;
   Public Const GENERIC_WRITE As Int32 = &amp;H40000000&lt;br /&gt;
   Public Const OPEN_EXISTING As Int32 = 3&lt;br /&gt;
   Public Const FILE_ATTRIBUTE_NORMAL As Int32 = &amp;H80&lt;br /&gt;
   Public Const NOPARITY As Int32 = 0&lt;br /&gt;
   Public Const ONESTOPBIT As Int32 = 0&lt;br /&gt;
&lt;br /&gt;
   &#39;Declare references to external functions.&lt;br /&gt;
   Public Declare Auto Function CreateFile Lib &quot;kernel32.dll&quot; _&lt;br /&gt;
      (ByVal lpFileName As String, ByVal dwDesiredAccess As Int32, _&lt;br /&gt;
         ByVal dwShareMode As Int32, ByVal lpSecurityAttributes As IntPtr, _&lt;br /&gt;
            ByVal dwCreationDisposition As Int32, ByVal dwFlagsAndAttributes As Int32, _&lt;br /&gt;
               ByVal hTemplateFile As IntPtr) As IntPtr&lt;br /&gt;
&lt;br /&gt;
   Public Declare Auto Function GetCommState Lib &quot;kernel32.dll&quot; (ByVal nCid As IntPtr, _&lt;br /&gt;
      ByRef lpDCB As DCB) As Boolean&lt;br /&gt;
&lt;br /&gt;
   Public Declare Auto Function SetCommState Lib &quot;kernel32.dll&quot; (ByVal nCid As IntPtr, _&lt;br /&gt;
      ByRef lpDCB As DCB) As Boolean&lt;br /&gt;
&lt;br /&gt;
   Public Declare Auto Function GetCommTimeouts Lib &quot;kernel32.dll&quot; (ByVal hFile As IntPtr, _&lt;br /&gt;
      ByRef lpCommTimeouts As COMMTIMEOUTS) As Boolean&lt;br /&gt;
&lt;br /&gt;
   Public Declare Auto Function SetCommTimeouts Lib &quot;kernel32.dll&quot; (ByVal hFile As IntPtr, _&lt;br /&gt;
      ByRef lpCommTimeouts As COMMTIMEOUTS) As Boolean&lt;br /&gt;
&lt;br /&gt;
   Public Declare Auto Function WriteFile Lib &quot;kernel32.dll&quot; (ByVal hFile As IntPtr, _&lt;br /&gt;
      ByVal lpBuffer As Byte(), ByVal nNumberOfBytesToWrite As Int32, _&lt;br /&gt;
         ByRef lpNumberOfBytesWritten As Int32, ByVal lpOverlapped As IntPtr) As Boolean&lt;br /&gt;
&lt;br /&gt;
   Public Declare Auto Function ReadFile Lib &quot;kernel32.dll&quot; (ByVal hFile As IntPtr, _&lt;br /&gt;
      ByVal lpBuffer As Byte(), ByVal nNumberOfBytesToRead As Int32, _&lt;br /&gt;
         ByRef lpNumberOfBytesRead As Int32, ByVal lpOverlapped As IntPtr) As Boolean&lt;br /&gt;
&lt;br /&gt;
   Public Declare Auto Function CloseHandle Lib &quot;kernel32.dll&quot; (ByVal hObject As IntPtr) As Boolean&lt;br /&gt;
&lt;br /&gt;
   Sub Main()&lt;br /&gt;
&lt;br /&gt;
      &#39; Declare local variables that you will use in the code.&lt;br /&gt;
      Dim hSerialPort, hParallelPort As IntPtr&lt;br /&gt;
      Dim Success As Boolean&lt;br /&gt;
      Dim MyDCB As DCB&lt;br /&gt;
      Dim MyCommTimeouts As COMMTIMEOUTS&lt;br /&gt;
      Dim BytesWritten, BytesRead As Int32&lt;br /&gt;
      Dim Buffer() As Byte&lt;br /&gt;
&lt;br /&gt;
      &#39; Declare variables to use for encoding.&lt;br /&gt;
      Dim oEncoder As New System.Text.ASCIIEncoding&lt;br /&gt;
      Dim oEnc As System.Text.Encoding = oEncoder.GetEncoding(1252)&lt;br /&gt;
&lt;br /&gt;
      &#39; Convert String to Byte().&lt;br /&gt;
      Buffer = oEnc.GetBytes(&quot;Test&quot;)&lt;br /&gt;
&lt;br /&gt;
      Try&lt;br /&gt;
         &#39; Serial port.&lt;br /&gt;
         Console.WriteLine(&quot;Accessing the COM1 serial port&quot;)&lt;br /&gt;
         &#39; Obtain a handle to the COM1 serial port.&lt;br /&gt;
         hSerialPort = CreateFile(&quot;COM1&quot;, GENERIC_READ Or GENERIC_WRITE, 0, IntPtr.Zero, _&lt;br /&gt;
            OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, IntPtr.Zero)&lt;br /&gt;
         &#39; Verify that the obtained handle is valid.&lt;br /&gt;
         If hSerialPort.ToInt32 = -1 Then&lt;br /&gt;
            Throw New CommException(&quot;Unable to obtain a handle to the COM1 port&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
         &#39; Retrieve the current control settings.&lt;br /&gt;
         Success = GetCommState(hSerialPort, MyDCB)&lt;br /&gt;
         If Success = False Then&lt;br /&gt;
            Throw New CommException(&quot;Unable to retrieve the current control settings&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
         &#39; Modify the properties of the retrieved DCB structure as appropriate.&lt;br /&gt;
         &#39; WARNING: Make sure to modify the properties according to their supported values.&lt;br /&gt;
         MyDCB.BaudRate = 9600&lt;br /&gt;
         MyDCB.ByteSize = 8&lt;br /&gt;
         MyDCB.Parity = NOPARITY&lt;br /&gt;
         MyDCB.StopBits = ONESTOPBIT&lt;br /&gt;
         &#39; Reconfigure COM1 based on the properties of the modified DCB structure.&lt;br /&gt;
         Success = SetCommState(hSerialPort, MyDCB)&lt;br /&gt;
         If Success = False Then&lt;br /&gt;
            Throw New CommException(&quot;Unable to reconfigure COM1&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
         &#39; Retrieve the current time-out settings.&lt;br /&gt;
         Success = GetCommTimeouts(hSerialPort, MyCommTimeouts)&lt;br /&gt;
         If Success = False Then&lt;br /&gt;
            Throw New CommException(&quot;Unable to retrieve current time-out settings&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
         &#39; Modify the properties of the retrieved COMMTIMEOUTS structure as appropriate.&lt;br /&gt;
         &#39; WARNING: Make sure to modify the properties according to their supported values.&lt;br /&gt;
         MyCommTimeouts.ReadIntervalTimeout = 0&lt;br /&gt;
         MyCommTimeouts.ReadTotalTimeoutConstant = 0&lt;br /&gt;
         MyCommTimeouts.ReadTotalTimeoutMultiplier = 0&lt;br /&gt;
         MyCommTimeouts.WriteTotalTimeoutConstant = 0&lt;br /&gt;
         MyCommTimeouts.WriteTotalTimeoutMultiplier = 0&lt;br /&gt;
         &#39; Reconfigure the time-out settings, based on the properties of the modified COMMTIMEOUTS structure.&lt;br /&gt;
         Success = SetCommTimeouts(hSerialPort, MyCommTimeouts)&lt;br /&gt;
         If Success = False Then&lt;br /&gt;
            Throw New CommException(&quot;Unable to reconfigure the time-out settings&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
         &#39; Write data to COM1.&lt;br /&gt;
         Console.WriteLine(&quot;Writing the following data to COM1: Test&quot;)&lt;br /&gt;
         Success = WriteFile(hSerialPort, Buffer, Buffer.Length, BytesWritten, IntPtr.Zero)&lt;br /&gt;
         If Success = False Then&lt;br /&gt;
            Throw New CommException(&quot;Unable to write to COM1&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
         &#39; Read data from COM1.&lt;br /&gt;
         Success = ReadFile(hSerialPort, Buffer, BytesWritten, BytesRead, IntPtr.Zero)&lt;br /&gt;
         If Success = False Then&lt;br /&gt;
            Throw New CommException(&quot;Unable to read from COM1&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
      Catch ex As Exception&lt;br /&gt;
         Console.WriteLine(Ex.Message)&lt;br /&gt;
      Finally&lt;br /&gt;
         &#39; Release the handle to COM1.&lt;br /&gt;
         Success = CloseHandle(hSerialPort)&lt;br /&gt;
         If Success = False Then&lt;br /&gt;
            Console.WriteLine(&quot;Unable to release handle to COM1&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
      End Try&lt;br /&gt;
&lt;br /&gt;
      Try&lt;br /&gt;
         &#39; Parallel port.&lt;br /&gt;
         Console.WriteLine(&quot;Accessing the LPT1 parallel port&quot;)&lt;br /&gt;
         &#39; Obtain a handle to the LPT1 parallel port.&lt;br /&gt;
         hParallelPort = CreateFile(&quot;LPT1&quot;, GENERIC_READ Or GENERIC_WRITE, 0, IntPtr.Zero, _&lt;br /&gt;
            OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, IntPtr.Zero)&lt;br /&gt;
         &#39; Verify that the obtained handle is valid.&lt;br /&gt;
         If hParallelPort.ToInt32 = -1 Then&lt;br /&gt;
            Throw New CommException(&quot;Unable to obtain a handle to the LPT1 port&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
         &#39; Retrieve the current control settings.&lt;br /&gt;
         Success = GetCommState(hParallelPort, MyDCB)&lt;br /&gt;
         If Success = False Then&lt;br /&gt;
            Throw New CommException(&quot;Unable to retrieve the current control settings&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
         &#39; Modify the properties of the retrieved DCB structure as appropriate.&lt;br /&gt;
         &#39; WARNING: Make sure to modify the properties according to their supported values.&lt;br /&gt;
         MyDCB.BaudRate = 9600&lt;br /&gt;
         MyDCB.ByteSize = 8&lt;br /&gt;
         MyDCB.Parity = NOPARITY&lt;br /&gt;
         MyDCB.StopBits = ONESTOPBIT&lt;br /&gt;
         &#39; Reconfigure LPT1 based on the properties of MyDCB.&lt;br /&gt;
         Success = SetCommState(hParallelPort, MyDCB)&lt;br /&gt;
         If Success = False Then&lt;br /&gt;
            Throw New CommException(&quot;Unable to reconfigure LPT1&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
         &#39; Reconfigure LPT1 based on the properties of the modified DCB structure.&lt;br /&gt;
         Success = GetCommTimeouts(hParallelPort, MyCommTimeouts)&lt;br /&gt;
         If Success = False Then&lt;br /&gt;
            Throw New CommException(&quot;Unable to retrieve current time-out settings&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
         &#39; Modify the properties of the retrieved COMMTIMEOUTS structure as appropriate.&lt;br /&gt;
         &#39; WARNING: Make sure to modify the properties according to their supported values.&lt;br /&gt;
         MyCommTimeouts.ReadIntervalTimeout = 0&lt;br /&gt;
         MyCommTimeouts.ReadTotalTimeoutConstant = 0&lt;br /&gt;
         MyCommTimeouts.ReadTotalTimeoutMultiplier = 0&lt;br /&gt;
         MyCommTimeouts.WriteTotalTimeoutConstant = 0&lt;br /&gt;
         MyCommTimeouts.WriteTotalTimeoutMultiplier = 0&lt;br /&gt;
         &#39; Reconfigure the time-out settings, based on the properties of the modified COMMTIMEOUTS structure.&lt;br /&gt;
         Success = SetCommTimeouts(hParallelPort, MyCommTimeouts)&lt;br /&gt;
         If Success = False Then&lt;br /&gt;
            Throw New CommException(&quot;Unable to reconfigure the time-out settings&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
         &#39; Write data to LPT1.&lt;br /&gt;
         &#39; Note: You cannot read data from a parallel port by calling the ReadFile function.&lt;br /&gt;
         Console.WriteLine(&quot;Writing the following data to LPT1: Test&quot;)&lt;br /&gt;
         Success = WriteFile(hParallelPort, Buffer, Buffer.Length, BytesWritten, IntPtr.Zero)&lt;br /&gt;
         If Success = False Then&lt;br /&gt;
            Throw New CommException(&quot;Unable to write to LPT1&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
      Catch ex As Exception&lt;br /&gt;
         Console.WriteLine(Ex.Message)&lt;br /&gt;
      Finally&lt;br /&gt;
         &#39; Release the handle to LPT1.&lt;br /&gt;
         Success = CloseHandle(hParallelPort)&lt;br /&gt;
         If Success = False Then&lt;br /&gt;
            Console.WriteLine(&quot;Unable to release handle to LPT1&quot;)&lt;br /&gt;
         End If&lt;br /&gt;
      End Try&lt;br /&gt;
&lt;br /&gt;
      Console.WriteLine(&quot;Press ENTER to quit&quot;)&lt;br /&gt;
      Console.ReadLine()&lt;br /&gt;
&lt;br /&gt;
   End Sub&lt;br /&gt;
&lt;br /&gt;
End Module&lt;br /&gt;
 Back to the top&lt;br /&gt;
Troubleshoot&lt;br /&gt;
•  When you run the application, you may receive the following error message:&lt;br /&gt;
System.NullReferenceException: Object reference not set to an instance of an object.&lt;br /&gt;
You may receive this error message because your function declarations are incorrect. This error message typically occurs when your declarations contain ByVal parameters instead of ByRef parameters.&lt;br /&gt;
• Your application may wait indefinitely when you invoke the ReadFile function. This behavior typically occurs when you set the read time-outs to zero in the retrieved COMMTIMEOUTS structure. To resolve this issue, modify the properties of the COMMTIMEOUTS structure, as appropriate.&lt;br /&gt;
 Back to the top&lt;br /&gt;
REFERENCES&lt;br /&gt;
For more information, visit the following Microsoft Developer Network (MSDN) Web...&lt;br /&gt;
 For more information, visit the following Microsoft Developer Network (MSDN) Web sites:&lt;br /&gt;
Communications resources&lt;br /&gt;
http://msdn2.microsoft.com/en-us/library/aa363196.aspx (http://msdn2.microsoft.com/en-us/library/aa363196.aspx) &lt;br /&gt;
&lt;br /&gt;
Interoperating with unmanaged code&lt;br /&gt;
http://msdn2.microsoft.com/en-us/library/sd10k43k(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/sd10k43k(vs.71).aspx) &lt;br /&gt;
&lt;br /&gt;
System.Runtime.InteropServices namespace&lt;br /&gt;
http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices(vs.71).aspx) &lt;br /&gt;
&lt;br /&gt;
DllImportAttribute class&lt;br /&gt;
http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute(vs.71).aspx) &lt;br /&gt;
&lt;br /&gt;
The Windows API and other dynamic-link libraries&lt;br /&gt;
http://msdn2.microsoft.com/en-us/library/aa141322(office.10).aspx (http://msdn2.microsoft.com/en-us/library/aa141322(office.10).aspx) &lt;br /&gt;
&lt;br /&gt;
Understanding handles&lt;br /&gt;
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/modcore/html/deovrUnderstandingHandles.asp (http://msdn2.microsoft.com/en-us/library/aa141354(office.10).aspx) &lt;br /&gt;
For more information about AT modem commands, click the following article number to view the article in the Microsoft Knowledge Base: &lt;br /&gt;
164660  (http://support.microsoft.com/kb/164660/ ) AT modem command reference &lt;br /&gt;
 Back to the top&lt;br /&gt;
________________________________________&lt;br /&gt;
APPLIES TO&lt;br /&gt;
• Microsoft Visual Basic .NET 2003 Standard Edition&lt;br /&gt;
• Microsoft Visual Basic .NET 2002 Standard Edition&lt;br /&gt;
 Back to the top&lt;br /&gt;
Keywords:   kbvs2005swept kbvs2005doesnotapply kbserial kbsdk kbkern32dll kbdll kbcommport kbapi kb32bitonly kbinterop kbconsole kbconfig kbappdev kbprogramming kbsample kbhowtomaster KB823179</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/1627669231081817688/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/how-to-access-serial-and-parallel-ports.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/1627669231081817688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/1627669231081817688'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/how-to-access-serial-and-parallel-ports.html' title='How to access serial and parallel ports by using Visual Basic .NET'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-1885165020152889476</id><published>2011-01-15T22:54:00.001+05:30</published><updated>2011-01-15T22:54:26.028+05:30</updated><title type='text'>Crystal Report 8.5</title><content type='html'>1. What is Crystal Report? &lt;br /&gt;
Ans: Crystal report is a report generation tool. Generally have interface with VB6. Crystal report basically generates dynamic data. You can format the data in whichever way you feel like. &lt;br /&gt;
2. Can we use Crystal report as a stand-alone application? &lt;br /&gt;
Ans: Generally we use Crystal Reports with VB6. However we can make crystal report stand-alone application&lt;br /&gt;
also. But for that limitation is for viewing the report user should have crystal reports installed on his/her PC. &lt;br /&gt;
3. How do we connect to the database? &lt;br /&gt;
Ans: There are two ways of creating the report: - &lt;br /&gt;
1. Use crystal report built in query. &lt;br /&gt;
2. Use the tool ‘ Crystal SQL Designer’ provided by crystal report. &lt;br /&gt;
When you create report using crystal report built in query then it asks for the data source name that you have created. When you run the report, then for the first time it will ask for the user id and password. After that it will store the same. &lt;br /&gt;
When you create ‘.qry’ using ‘Crystal SQL’ Designer then at that time it will ask for the user id and password. When you run the report for the first time instead of asking for the user id and password it will ask for the ‘.qry’ file location. You can change the query location also. For that open the report, select ‘Set Location’ option in Database menu item, and set the location. &lt;br /&gt;
4. How do we format field? &lt;br /&gt;
Ans: For formatting any field just right click on it and you will get many options like ‘Format Field.’ ‘Browse field data’ etc. Click on ‘Format Field.’ You can align data, suppress, make it multiline, change the font size, style, and type, make it hyperlink etc. &lt;br /&gt;
If it is an amount field then you can display currency symbol also. Right click on the field select ‘Format Field’. &lt;br /&gt;
5. Can we give parameters to the report? &lt;br /&gt;
Ans: We can very well give parameters to the report. For creating parameters select ‘Parameter Field’ in Insert menu item. ‘Create Parameter Field’ dialog box will popped up, it will ask for the name of parameter, prompting text and datatype. Now when you run the report it will prompt for these parameters. &lt;br /&gt;
6.Can we create our own formulas in reports? &lt;br /&gt;
Ans: We can create our own formulas in reports. Select ‘Formula Field’ in Insert menu item. Write the formula in ‘Formula Editor’. Here you will get ‘Field Tree’, ‘Function Tree’, and ‘Operator Tree’, which will display the report fields, functions that are supported by crystal reports (like CDATE () etc.), operators (arithmetic, strings etc.) respectively. &lt;br /&gt;
7. Can we create report using more than one database? &lt;br /&gt;
Ans: We can create report using more than one database like Oracle, Access. Create data source name for both the databases. Select tables from them and create the report. &lt;br /&gt;
Only restriction is if you use two databases then you cannot see the SQL generated by crystal reports. &lt;br /&gt;
8. Can we export data of reports into other format like in world doc etc? &lt;br /&gt;
Ans: Generated data can be exported to word doc, or in rich text format. Just click on ‘Export’ icon in the menu. Export dialog box will be popped up. It will ask for the ‘Format’ like comma-separated value (csv) etc and the ‘Destination’ like disk, application etc. After that it will ask for the file name and save the data. &lt;br /&gt;
Only restriction is formatting of data will be lost, but crystal report will try to maintain as much formatting as it can. &lt;br /&gt;
9. Can we use our own SQL for creating a report? &lt;br /&gt;
Ans: We can also make our own query using ‘Crystal SQL Designer’ tool provided by SQL. Here you can insert your SQL statement as such. It will save this file as ‘.qry’ . And when you create a report instead of using ‘Database’ button use ‘Crystal SQL Statement’ button. &lt;br /&gt;
10. Can we edit SQL made by Crystal reports? &lt;br /&gt;
Ans: We cannot edit the SQL made by crystal reports. However we can view the SQL. For that select ‘Show SQL Query’ in Database menu item. Limitation is if you are using only one database. If you use two databases then you can’t even view the SQL prepared by crystal report. &lt;br /&gt;
11. Are there any limitations in crystal reports? &lt;br /&gt;
Ans: There are certain limitations in crystal reports. They are: - &lt;br /&gt;
1. If database is having field whose length is more than 255 characters, then you cannot make formula using that field. &lt;br /&gt;
2. While exporting data formatting is lost. &lt;br /&gt;
3. When you browse data just by right clicking on the field then it displays that is there in the database not the data selected by the query. &lt;br /&gt;
&lt;br /&gt;
12. Can we suppress printing in crystal reports if 0 records are fetched? &lt;br /&gt;
Ans: Yes, we can suppress printing if no records are fetched. Select ‘Report Options’ in File menu item. ‘Report Options’ dialog box will pop up. In that there is one option ‘ Suppress printing if no records’ Check this option. If no records are found then nothing will be printed on the report. &lt;br /&gt;
13. What are the sections that we have in Crystal reports? &lt;br /&gt;
Ans: Report has got standard sections like ‘Page Header’, ‘Page Footer’, ‘Report Header’, ‘Report Footer’, and ‘Details’. &lt;br /&gt;
However you can add other sections also. Select ‘Sections’ in the Insert menu item. You can insert group sections also. &lt;br /&gt;
If you don’t want to show any section just right click on that section and suppress that. &lt;br /&gt;
14. Can we add any database field once we have chosen ‘Close’ button? &lt;br /&gt;
Ans: Yes, we can add any database field afterwards also. Select ‘Database Field’ in Insert menu item. &lt;br /&gt;
If you are using crystal report built in query then it will display the tables that you have selected. And you can select whichever field you want to display on the report. &lt;br /&gt;
But if you are using ‘.qry’ file then it will display Query and you can select only those field, which are there in the query. &lt;br /&gt;
15. Does Crystal Report support all the functions that we have in Oracle? &lt;br /&gt;
Ans: No, Crystal report does not support all the functions. Like Decode function is there in SQL but not there is crystal report. You need to convert that in crystal report format (in if and else etc.). &lt;br /&gt;
However if you use ‘.qry’ files then it take the SQL as such. There is no need of changing any syntax. &lt;br /&gt;
16. Can we use stored procedure for creating the report? &lt;br /&gt;
Ans: Yes, we can use stored procedure. &lt;br /&gt;
17. Is there any feature like summing total in crystal report? &lt;br /&gt;
Ans: Crystal reports provide features like grand total, sub-total, running total etc. You can select any of these features in Insert menu item. &lt;br /&gt;
You can sum up records on the basis of each record or on change of group using ‘Running Total ‘ option in Insert menu item. &lt;br /&gt;
18. I am using two tables one is of access database and other is of oracle database, I am getting an error saying that ‘SQL odbc error’ what should I do? &lt;br /&gt;
Ans: If you are getting such an error then click the icon for ‘Report Expert’. It will give a warning saying that formatting will be lost. Ignore this you will get ‘Standard Report Expert’ dialog box. Reverse the links of access database table and it will work. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Q)  What versions of Crystal Reports have you used?  Please indicate both release version (9, 10, XI) and type of version (.NET or standalone boxed exition, for example).&lt;br /&gt;
&lt;br /&gt;
A)  I was willing to consider individuals who were primarily programming version users, if they were able to adequately answer questions about Crystal Reports functionality.  It has been my experience, however, that &quot;programmer&quot; Crystal Reports writers have vastly different skill sets and opinions about solutions that &quot;report writer&quot; or &quot;business user&quot; Crystal Reports writers.&lt;br /&gt;
&lt;br /&gt;
Q)  What is &#39;Set Location&#39;&lt;br /&gt;
&lt;br /&gt;
A)  This is very basic Crystal Reports functionality.  If the candidate doesn&#39;t know what this is, then that&#39;s a red flag.&lt;br /&gt;
&lt;br /&gt;
Q)  Please describe, in plain English, the most complex report you&#39;ve ever written.  What made it complex and how did you resolve the issues that presented themselves?&lt;br /&gt;
&lt;br /&gt;
A)  This question helps me to understand their level of understanding of functionality, their ability to potentially address complex requirements and their creativity.&lt;br /&gt;
&lt;br /&gt;
Q)  Have you ever written a repot against a View or Stored Procedure?&lt;br /&gt;
&lt;br /&gt;
A)  No?  They might be skilled in Crystal Reports, but may not understand the relationship between Crystal and the database.  They may also not be skilled in SQL.&lt;br /&gt;
&lt;br /&gt;
Q)  Is it better to build a report against a View or a Stored Procedure and why?  Please explain...&lt;br /&gt;
&lt;br /&gt;
A)  This is a very good question, in my opinion.  First, the right answer is neither.  It really depends on the situation.  That being said, there is a contingent of report writers out there that have been brainwashed into saying a &#39;stored procedure is always better, becuase its pre-compiled&#39;.  In my opinion, this is bunk and here&#39;s why:&lt;br /&gt;
&lt;br /&gt;
A stored procedure is absolutely great to use if you&#39;re going to manipulate a lot of data or crunch a lot of numbers to return aggregates.  If you&#39;re simply creating a SELECT/FROM/WHERE query, it&#39;s a complete waste.  Furthermore, using a Stored Procedure (or a SQL Command Object, for that matter) can severely limit the functionality you would otherwise have in Crystal Reports.  For example, a common report requirement is to have a parameter that allows the user to select one, multiple or all items in the parameter list.  Crystal Reports allows this functionalty through multi-value parameter selection.   Stored procedures do not allow this functionality...&lt;br /&gt;
&lt;br /&gt;
A View can be written to contain all of the necessary fields, joins, subqueries, etc..., but still be open enough to be used by a variety of reports.  For example, I have a client who needed 15 reports, all of which were to be written against a particular module of their application.  All of the reports had very similar fields, they were mostly just different in display and in the selection criteria.  As such, I created a single view with both a SELECT and FROM clause, but no WHERE clause.  I then built the 15 different reports all against the same view, but added selection critieria to each report.  By doing so, they all used a single, easily maintainable database object, but were each unique and efficient...&lt;br /&gt;
&lt;br /&gt;
Q)  What is a SQL Expression field in Crystal Reports?&lt;br /&gt;
&lt;br /&gt;
A)  I honestly don&#39;t expect any candidate to know, much less explain their use.  Almost nobody knows and most of the ones that do don&#39;t know everything you can do with them.  I&#39;m an expert using them and I don&#39;t know everything about them, I&#39;m sure.  If the incumbent knows what they are and how to use them, that&#39;s a bonus and probably indicates that the the candidate is an advanced user.&lt;br /&gt;
&lt;br /&gt;
Of course, there are a ton of other questions I could provide, but this would get very long!  If you&#39;re going to test the candidates, I would check to see if they use the Select Expert or the Record Selection Criteria.  If its the former, its a dead giveaway that they are novices...</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/1885165020152889476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/crystal-report-85.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/1885165020152889476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/1885165020152889476'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/crystal-report-85.html' title='Crystal Report 8.5'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-1169068789810496942</id><published>2011-01-15T22:52:00.005+05:30</published><updated>2011-01-15T22:52:54.370+05:30</updated><title type='text'>Interview Questions</title><content type='html'>1. Introduction&lt;br /&gt;
1.1 What is .NET?&lt;br /&gt;
That&#39;s difficult to sum up in a sentence. According to Microsoft, .NET is a &quot;revolutionary new platform, built on open Internet protocols and standards, with tools and services that meld computing and communications in new ways&quot;.&lt;br /&gt;
A more practical definition would be that .NET is a new environment for developing and running software applications, featuring ease of development of web-based services, rich standard run-time services available to components written in a variety of programming languages, and inter-language and inter-machine interoperability.&lt;br /&gt;
Note that when the term &quot;.NET&quot; is used in this FAQ it refers only to the new .NET runtime and associated technologies. This is sometimes called the &quot;.NET Framework&quot;. This FAQ does NOT cover any of the various other existing and new products/technologies that Microsoft are attaching the .NET name to (e.g. SQL Server.NET).&lt;br /&gt;
1.2 Does .NET only apply to people building web-sites?&lt;br /&gt;
No. If you write any Windows software (using ATL/COM, MFC, VB, or even raw Win32), .NET may offer a viable alternative (or addition) to the way you do things currently. Of course, if you do develop web sites, then .NET has lots to interest you - not least ASP.NET.&lt;br /&gt;
1.3 When was .NET announced?&lt;br /&gt;
Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET &#39;vision&#39;. The July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET.&lt;br /&gt;
1.4 When was the first version of .NET released?&lt;br /&gt;
The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on 15-Jan-2002. At the same time, the final version of Visual Studio.NET was made available to MSDN subscribers.&lt;br /&gt;
1.5 What tools can I use to develop .NET applications?&lt;br /&gt;
There are a number of tools, described here in ascending order of cost: &lt;br /&gt;
•	.NET Framework SDK: The SDK is free and includes command-line compilers for C++, C#, and VB.NET and various other utilities to aid development. &lt;br /&gt;
•	ASP.NET Web Matrix: This is a free ASP.NET development environment from Microsoft. As well as a GUI development environment, the download includes a simple web server that can be used instead of IIS to host ASP.NET apps. This opens up ASP.NET development to users of Windows XP Home Edition, which cannot run IIS. &lt;br /&gt;
•	Microsoft Visual C# .NET Standard 2003: This is a cheap (around $100) version of Visual Studio limited to one language and also with limited wizard support. For example, there&#39;s no wizard support for class libraries or custom UI controls. Useful for beginners to learn with, or for savvy developers who can work around the deficiencies in the supplied wizards. As well as C#, there are VB.NET and C++ versions. &lt;br /&gt;
•	Microsoft Visual Studio.NET Professional 2003: If you have a license for Visual Studio 6.0, you can get the upgrade. You can also upgrade from VS.NET 2002 for a token $30. Visual Studio.NET includes support for all the MS languages (C#, C++, VB.NET) and has extensive wizard support. &lt;br /&gt;
At the top end of the price spectrum are the Visual Studio.NET 2003 Enterprise and Enterprise Architect editions. These offer extra features such as Visual Sourcesafe (version control), and performance and analysis tools. Check out the Visual Studio.NET Feature Comparison at http://msdn.microsoft.com/vstudio/howtobuy/choosing.asp. &lt;br /&gt;
1.6 What platforms does the .NET Framework run on?&lt;br /&gt;
The runtime supports Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on Windows XP and Windows 2000. Windows 98/ME cannot be used for development.&lt;br /&gt;
IIS is not supported on Windows XP Home Edition, and so cannot be used to host ASP.NET. However, the ASP.NET Web Matrix web server does run on XP Home.&lt;br /&gt;
The Mono project is attempting to implement the .NET framework on Linux.&lt;br /&gt;
1.7 What languages does the .NET Framework support?&lt;br /&gt;
MS provides compilers for C#, C++, VB and JScript. Other vendors have announced that they intend to develop .NET compilers for languages such as COBOL, Eiffel, Perl, Smalltalk and Python.&lt;br /&gt;
1.8 Will the .NET Framework go through a standardisation process?&lt;br /&gt;
From http://msdn.microsoft.com/net/ecma/: &quot;On December 13, 2001, the ECMA General Assembly ratified the C# and common language infrastructure (CLI) specifications into international standards. The ECMA standards will be known as ECMA-334 (C#) and ECMA-335 (the CLI).&quot; &lt;br /&gt;
2. Basic terminology&lt;br /&gt;
2.1 What is the CLR?&lt;br /&gt;
CLR = Common Language Runtime. The CLR is a set of standard resources that (in theory) any .NET program can take advantage of, regardless of programming language. Robert Schmidt (Microsoft) lists the following CLR resources in his MSDN PDC# article:&lt;br /&gt;
•	Object-oriented programming model (inheritance, polymorphism, exception handling, garbage collection) &lt;br /&gt;
•	Security model &lt;br /&gt;
•	Type system &lt;br /&gt;
•	All .NET base classes &lt;br /&gt;
•	Many .NET framework classes &lt;br /&gt;
•	Development, debugging, and profiling tools &lt;br /&gt;
•	Execution and code management &lt;br /&gt;
•	IL-to-native translators and optimizers &lt;br /&gt;
What this means is that in the .NET world, different programming languages will be more equal in capability than they have ever been before, although clearly not all languages will support all CLR services.&lt;br /&gt;
2.2 What is the CTS?&lt;br /&gt;
CTS = Common Type System. This is the range of types that the .NET runtime understands, and therefore that .NET applications can use. However note that not all .NET languages will support all the types in the CTS. The CTS is a superset of the CLS.&lt;br /&gt;
2.3 What is the CLS?&lt;br /&gt;
CLS = Common Language Specification. This is a subset of the CTS which all .NET languages are expected to support. The idea is that any program which uses CLS-compliant types can interoperate with any .NET program written in any language.&lt;br /&gt;
In theory this allows very tight interop between different .NET languages - for example allowing a C# class to inherit from a VB class.&lt;br /&gt;
2.4 What is IL?&lt;br /&gt;
IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code (of any language) is compiled to IL. The IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler.&lt;br /&gt;
2.5 What is C#?&lt;br /&gt;
C# is a new language designed by Microsoft to work with the .NET framework. In their &quot;Introduction to C#&quot; whitepaper, Microsoft describe C# as follows:&lt;br /&gt;
&quot;C# is a simple, modern, object oriented, and type-safe programming language derived from C and C++. C# (pronounced “C sharp”) is firmly planted in the C and C++ family tree of languages, and will immediately be familiar to C and C++ programmers. C# aims to combine the high productivity of Visual Basic and the raw power of C++.&quot;&lt;br /&gt;
Substitute &#39;Java&#39; for &#39;C#&#39; in the quote above, and you&#39;ll see that the statement still works pretty well :-).&lt;br /&gt;
If you are a C++ programmer, you might like to check out my C# FAQ.&lt;br /&gt;
2.6 What does &#39;managed&#39; mean in the .NET context?&lt;br /&gt;
The term &#39;managed&#39; is the cause of much confusion. It is used in various places within .NET, meaning slightly different things.&lt;br /&gt;
Managed code: The .NET framework provides several core run-time services to the programs that run within it - for example exception handling and security. For these services to work, the code must provide a minimum level of information to the runtime. Such code is called managed code. All C# and Visual Basic.NET code is managed by default. VS7 C++ code is not managed by default, but the compiler can produce managed code by specifying a command-line switch (/com+).&lt;br /&gt;
Managed data: This is data that is allocated and de-allocated by the .NET runtime&#39;s garbage collector. C# and VB.NET data is always managed. VS7 C++ data is unmanaged by default, even when using the /com+ switch, but it can be marked as managed using the __gc keyword.&lt;br /&gt;
Managed classes: This is usually referred to in the context of Managed Extensions (ME) for C++. When using ME C++, a class can be marked with the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector, but it also means more than that. The class becomes a fully paid-up member of the .NET community with the benefits and restrictions that brings. An example of a benefit is proper interop with classes written in other languages - for example, a managed C++ class can inherit from a VB class. An example of a restriction is that a managed class can only inherit from one base class.&lt;br /&gt;
2.7 What is reflection?&lt;br /&gt;
All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly. &lt;br /&gt;
Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes - e.g. determining data type sizes for marshaling data across context/process/machine boundaries.&lt;br /&gt;
Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember), or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder). &lt;br /&gt;
3. Assemblies&lt;br /&gt;
3.1 What is an assembly?&lt;br /&gt;
An assembly is sometimes described as a logical .EXE or .DLL, and can be an application (with a main entry point) or a library. An assembly consists of one or more files (dlls, exes, html files etc), and represents a group of resources, type definitions, and implementations of those types. An assembly may also contain references to other assemblies. These resources, types and references are described in a block of data called a manifest. The manifest is part of the assembly, thus making the assembly self-describing.&lt;br /&gt;
An important aspect of assemblies is that they are part of the identity of a type. The identity of a type is the assembly that houses it combined with the type name. This means, for example, that if assembly A exports a type called T, and assembly B exports a type called T, the .NET runtime sees these as two completely different types. Furthermore, don&#39;t get confused between assemblies and namespaces - namespaces are merely a hierarchical way of organising type names. To the runtime, type names are type names, regardless of whether namespaces are used to organise the names. It&#39;s the assembly plus the typename (regardless of whether the type name belongs to a namespace) that uniquely indentifies a type to the runtime.&lt;br /&gt;
Assemblies are also important in .NET with respect to security - many of the security restrictions are enforced at the assembly boundary.&lt;br /&gt;
Finally, assemblies are the unit of versioning in .NET - more on this below. &lt;br /&gt;
3.2 How can I produce an assembly?&lt;br /&gt;
The simplest way to produce an assembly is directly from a .NET compiler. For example, the following C# program:&lt;br /&gt;
public class CTest&lt;br /&gt;
{&lt;br /&gt;
public CTest()&lt;br /&gt;
{&lt;br /&gt;
System.Console.WriteLine( &quot;Hello from CTest&quot; );&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
can be compiled into a library assembly (dll) like this:&lt;br /&gt;
csc /t:library ctest.cs&lt;br /&gt;
You can then view the contents of the assembly by running the &quot;IL Disassembler&quot; tool that comes with the .NET SDK.&lt;br /&gt;
Alternatively you can compile your source into modules, and then combine the modules into an assembly using the assembly linker (al.exe). For the C# compiler, the /target:module switch is used to generate a module instead of an assembly.&lt;br /&gt;
3.3 What is the difference between a private assembly and a shared assembly?&lt;br /&gt;
•	Location and visibility: A private assembly is normally used by a single application, and is stored in the application&#39;s directory, or a sub-directory beneath. A shared assembly is normally stored in the global assembly cache, which is a repository of assemblies maintained by the .NET runtime. Shared assemblies are usually libraries of code which many applications will find useful, e.g. the .NET framework classes.&lt;br /&gt;
&lt;br /&gt;
•	Versioning: The runtime enforces versioning constraints only on shared assemblies, not on private assemblies.&lt;br /&gt;
3.4 How do assemblies find each other?&lt;br /&gt;
By searching directory paths. There are several factors which can affect the path (such as the AppDomain host, and application configuration files), but for private assemblies the search path is normally the application&#39;s directory and its sub-directories. For shared assemblies, the search path is normally same as the private assembly path plus the shared assembly cache.&lt;br /&gt;
3.5 How does assembly versioning work?&lt;br /&gt;
Each assembly has a version number called the compatibility version. Also each reference to an assembly (from another assembly) includes both the name and version of the referenced assembly.&lt;br /&gt;
The version number has four numeric parts (e.g. 5.5.2.33). Assemblies with either of the first two parts different are normally viewed as incompatible. If the first two parts are the same, but the third is different, the assemblies are deemed as &#39;maybe compatible&#39;. If only the fourth part is different, the assemblies are deemed compatible. However, this is just the default guideline - it is the version policy that decides to what extent these rules are enforced. The version policy can be specified via the application configuration file.&lt;br /&gt;
Remember: versioning is only applied to shared assemblies, not private assemblies.&lt;br /&gt;
4. Application Domains&lt;br /&gt;
4.1 What is an Application Domain?&lt;br /&gt;
An AppDomain can be thought of as a lightweight process. Multiple AppDomains can exist inside a Win32 process. The primary purpose of the AppDomain is to isolate an application from other applications.&lt;br /&gt;
Win32 processes provide isolation by having distinct memory address spaces. This is effective, but it is expensive and doesn&#39;t scale well. The .NET runtime enforces AppDomain isolation by keeping control over the use of memory - all memory in the AppDomain is managed by the .NET runtime, so the runtime can ensure that AppDomains do not access each other&#39;s memory.&lt;br /&gt;
4.2 How does an AppDomain get created?&lt;br /&gt;
AppDomains are usually created by hosts. Examples of hosts are the Windows Shell, ASP.NET and IE. When you run a .NET application from the command-line, the host is the Shell. The Shell creates a new AppDomain for every application.&lt;br /&gt;
AppDomains can also be explicitly created by .NET applications. Here is a C# sample which creates an AppDomain, creates an instance of an object inside it, and then executes one of the object&#39;s methods. Note that you must name the executable &#39;appdomaintest.exe&#39; for this code to work as-is.&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.Remoting;&lt;br /&gt;
&lt;br /&gt;
public class CAppDomainInfo : MarshalByRefObject&lt;br /&gt;
{&lt;br /&gt;
public string GetAppDomainInfo()&lt;br /&gt;
{&lt;br /&gt;
return &quot;AppDomain = &quot; + AppDomain.CurrentDomain.FriendlyName;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class App&lt;br /&gt;
{&lt;br /&gt;
public static int Main()&lt;br /&gt;
{&lt;br /&gt;
AppDomain ad = AppDomain.CreateDomain( &quot;Andy&#39;s new domain&quot;, null, null );&lt;br /&gt;
ObjectHandle oh = ad.CreateInstance( &quot;appdomaintest&quot;, &quot;CAppDomainInfo&quot; );&lt;br /&gt;
CAppDomainInfo adInfo = (CAppDomainInfo)(oh.Unwrap());&lt;br /&gt;
string info = adInfo.GetAppDomainInfo();&lt;br /&gt;
&lt;br /&gt;
Console.WriteLine( &quot;AppDomain info: &quot; + info );&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
4.3 Can I write my own .NET host?&lt;br /&gt;
Yes. For an example of how to do this, take a look at the source for the dm.net moniker developed by Jason Whittington and Don Box (http://staff.develop.com/jasonw/clr/readme.htm ). There is also a code sample in the .NET SDK called CorHost. &lt;br /&gt;
5. Garbage Collection&lt;br /&gt;
5.1 What is garbage collection?&lt;br /&gt;
Garbage collection is a system whereby a run-time component takes responsibility for managing the lifetime of objects and the heap memory that they occupy. This concept is not new to .NET - Java and many other languages/runtimes have used garbage collection for some time.&lt;br /&gt;
5.2 Is it true that objects don&#39;t always get destroyed immediately when the last reference goes away?&lt;br /&gt;
Yes. The garbage collector offers no guarantees about the time when an object will be destroyed and its memory reclaimed.&lt;br /&gt;
There is an interesting thread in the archives, started by Chris Sells, about the implications of non-deterministic destruction of objects in C#: http://discuss.develop.com/archives/wa.exe?A2=ind0007&amp;amp;L=DOTNET&amp;amp;P=R24819&lt;br /&gt;
In October 2000, Microsoft&#39;s Brian Harry posted a lengthy analysis of the problem: http://discuss.develop.com/archives/wa.exe?A2=ind0010A&amp;amp;L=DOTNET&amp;amp;P=R28572&lt;br /&gt;
Chris Sells&#39; response to Brian&#39;s posting is here: http://discuss.develop.com/archives/wa.exe?A2=ind0010C&amp;amp;L=DOTNET&amp;amp;P=R983&lt;br /&gt;
5.3 Why doesn&#39;t the .NET runtime offer deterministic destruction?&lt;br /&gt;
Because of the garbage collection algorithm. The .NET garbage collector works by periodically running through a list of all the objects that are currently being referenced by an application. All the objects that it doesn&#39;t find during this search are ready to be destroyed and the memory reclaimed. The implication of this algorithm is that the runtime doesn&#39;t get notified immediately when the final reference on an object goes away - it only finds out during the next sweep of the heap.&lt;br /&gt;
Futhermore, this type of algorithm works best by performing the garbage collection sweep as rarely as possible. Normally heap exhaustion is the trigger for a collection sweep.&lt;br /&gt;
5.4 Is the lack of deterministic destruction in .NET a problem?&lt;br /&gt;
It&#39;s certainly an issue that affects component design. If you have objects that maintain expensive or scarce resources (e.g. database locks), you need to provide some way for the client to tell the object to release the resource when it is done. Microsoft recommend that you provide a method called Dispose() for this purpose. However, this causes problems for distributed objects - in a distributed system who calls the Dispose() method? Some form of reference-counting or ownership-management mechanism is needed to handle distributed objects - unfortunately the runtime offers no help with this. &lt;br /&gt;
5.5 Does non-deterministic destruction affect the usage of COM objects from managed code?&lt;br /&gt;
Yes. When using a COM object from managed code, you are effectively relying on the garbage collector to call the final release on your object. If your COM object holds onto an expensive resource which is only cleaned-up after the final release, you may need to provide a new interface on your object which supports an explicit Dispose() method.&lt;br /&gt;
5.6 I&#39;ve heard that Finalize methods should be avoided. Should I implement Finalize on my class?&lt;br /&gt;
An object with a Finalize method is more work for the garbage collector than an object without one. Also there are no guarantees about the order in which objects are Finalized, so there are issues surrounding access to other objects from the Finalize method. Finally, there is no guarantee that a Finalize method will get called on an object, so it should never be relied upon to do clean-up of an object&#39;s resources.&lt;br /&gt;
Microsoft recommend the following pattern:&lt;br /&gt;
public class CTest : IDisposable&lt;br /&gt;
{ &lt;br /&gt;
public void Dispose()&lt;br /&gt;
{&lt;br /&gt;
... // Cleanup activities&lt;br /&gt;
GC.SuppressFinalize(this); &lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
~CTest()	// C# syntax hiding the Finalize() method&lt;br /&gt;
{&lt;br /&gt;
Dispose(); &lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
In the normal case the client calls Dispose(), the object&#39;s resources are freed, and the garbage collector is relieved of its Finalizing duties by the call to SuppressFinalize(). In the worst case, i.e. the client forgets to call Dispose(), there is a reasonable chance that the object&#39;s resources will eventually get freed by the garbage collector calling Finalize(). Given the limitations of the garbage collection algorithm this seems like a pretty reasonable approach.&lt;br /&gt;
5.7 Do I have any control over the garbage collection algorithm? &lt;br /&gt;
A little. For example, the System.GC class exposes a Collect method - this forces the garbage collector to collect all unreferenced objects immediately.&lt;br /&gt;
5.8 How can I find out what the garbage collector is doing?&lt;br /&gt;
Lots of interesting statistics are exported from the .NET runtime via the &#39;.NET CLR xxx&#39; performance counters. Use Performance Monitor to view them.&lt;br /&gt;
6. Serialization&lt;br /&gt;
6.1 What is serialization?&lt;br /&gt;
Serialization is the process of converting an object into a stream of bytes. Deserialization is the opposite process of creating an object from a stream of bytes. Serialization/Deserialization is mostly used to transport objects (e.g. during remoting), or to persist objects (e.g. to a file or database).&lt;br /&gt;
6.2 Does the .NET Framework have in-built support for serialization?&lt;br /&gt;
There are two separate mechanisms provided by the .NET class library - XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and uses SoapFormatter/BinaryFormatter for remoting. Both are available for use in your own code.&lt;br /&gt;
6.3 I want to serialize instances of my class. Should I use XmlSerializer, SoapFormatter or BinaryFormatter?&lt;br /&gt;
It depends. XmlSerializer has severe limitations such as the requirement that the target class has a parameterless constructor, and only public read/write properties and fields can be serialized. However, on the plus side, XmlSerializer has good support for customising the XML document that is produced or consumed. XmlSerializer&#39;s features mean that it is most suitable for cross-platform work, or for constructing objects from existing XML documents.&lt;br /&gt;
SoapFormatter and BinaryFormatter have fewer limitations than XmlSerializer. They can serialize private fields, for example. However they both require that the target class be marked with the [Serializable] attribute, so like XmlSerializer the class needs to be written with serialization in mind. Also there are some quirks to watch out for - for example on deserialization the constructor of the new object is not invoked.&lt;br /&gt;
The choice between SoapFormatter and BinaryFormatter depends on the application. BinaryFormatter makes sense where both serialization and deserialization will be performed on the .NET platform and where performance is important. SoapFormatter generally makes more sense in all other cases, for ease of debugging if nothing else.&lt;br /&gt;
6.4 Can I customise the serialization process?&lt;br /&gt;
Yes. XmlSerializer supports a range of attributes that can be used to configure serialization for a particular class. For example, a field or property can be marked with the [XmlIgnore] attribute to exclude it from serialization. Another example is the [XmlElement] attribute, which can be used to specify the XML element name to be used for a particular property or field.&lt;br /&gt;
Serialization via SoapFormatter/BinaryFormatter can also be controlled to some extent by attributes. For example, the [NonSerialized] attribute is the equivalent of XmlSerializer&#39;s [XmlIgnore] attribute. Ultimate control of the serialization process can be acheived by implementing the the ISerializable interface on the class whose instances are to be serialized.&lt;br /&gt;
6.5 Why is XmlSerializer so slow?&lt;br /&gt;
There is a once-per-process-per-type overhead with XmlSerializer. So the first time you serialize or deserialize an object of a given type in an application, there is a significant delay. This normally doesn&#39;t matter, but it may mean, for example, that XmlSerializer is a poor choice for loading configuration settings during startup of a GUI application.&lt;br /&gt;
6.6 Why do I get errors when I try to serialize a Hashtable?&lt;br /&gt;
XmlSerializer will refuse to serialize instances of any class that implements IDictionary, e.g. Hashtable. SoapFormatter and BinaryFormatter do not have this restriction.&lt;br /&gt;
6.7 XmlSerializer is throwing a generic &quot;There was an error reflecting MyClass&quot; error. How do I find out what the problem is?&lt;br /&gt;
Look at the InnerException property of the exception that is thrown to get a more specific error message.&lt;br /&gt;
7. Attributes&lt;br /&gt;
7.1 What are attributes?&lt;br /&gt;
There are at least two types of .NET attribute. The first type I will refer to as a metadata attribute - it allows some data to be attached to a class or method. This data becomes part of the metadata for the class, and (like other class metadata) can be accessed via reflection. An example of a metadata attribute is [serializable], which can be attached to a class and means that instances of the class can be serialized. &lt;br /&gt;
[serializable] public class CTest {}&lt;br /&gt;
The other type of attribute is a context attribute. Context attributes use a similar syntax to metadata attributes but they are fundamentally different. Context attributes provide an interception mechanism whereby instance activation and method calls can be pre- and/or post-processed. If you&#39;ve come across Keith Brown&#39;s universal delegator you&#39;ll be familiar with this idea. &lt;br /&gt;
7.2 Can I create my own metadata attributes?&lt;br /&gt;
Yes. Simply derive a class from System.Attribute and mark it with the AttributeUsage attribute. For example: &lt;br /&gt;
[AttributeUsage(AttributeTargets.Class)]&lt;br /&gt;
public class InspiredByAttribute : System.Attribute &lt;br /&gt;
{ &lt;br /&gt;
public string InspiredBy;&lt;br /&gt;
&lt;br /&gt;
public InspiredByAttribute( string inspiredBy )&lt;br /&gt;
{&lt;br /&gt;
InspiredBy = inspiredBy;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[InspiredBy(&quot;Andy Mc&#39;s brilliant .NET FAQ&quot;)]&lt;br /&gt;
class CTest&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class CApp&lt;br /&gt;
{&lt;br /&gt;
public static void Main()&lt;br /&gt;
{		&lt;br /&gt;
object[] atts = typeof(CTest).GetCustomAttributes(true);&lt;br /&gt;
&lt;br /&gt;
foreach( object att in atts )&lt;br /&gt;
if( att is InspiredByAttribute )&lt;br /&gt;
Console.WriteLine( &quot;Class CTest was inspired by {0}&quot;, ((InspiredByAttribute)att).InspiredBy  );&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
7.3 Can I create my own context attributes?&lt;br /&gt;
Yes. Take a look at Don Box&#39;s sample (called CallThreshold) at http://www.develop.com/dbox/dotnet/threshold/, and also Peter Drayton&#39;s Tracehook.NET at http://www.razorsoft.net/&lt;br /&gt;
8. Code Access Security&lt;br /&gt;
8.1 What is Code Access Security (CAS)?&lt;br /&gt;
CAS is the part of the .NET security model that determines whether or not a piece of code is allowed to run, and what resources it can use when it is running. For example, it is CAS that will prevent a .NET web applet from formatting your hard disk.&lt;br /&gt;
8.2 How does CAS work?&lt;br /&gt;
The CAS security policy revolves around two key concepts - code groups and permissions. Each .NET assembly is a member of a particular code group, and each code group is granted the permissions specified in a named permission set.&lt;br /&gt;
For example, using the default security policy, a control downloaded from a web site belongs to the &#39;Zone - Internet&#39; code group, which adheres to the permissions defined by the &#39;Internet&#39; named permission set. (Naturally the &#39;Internet&#39; named permission set represents a very restrictive range of permissions.) &lt;br /&gt;
8.3 Who defines the CAS code groups?&lt;br /&gt;
Microsoft defines some default ones, but you can modify these and even create your own. To see the code groups defined on your system, run &#39;caspol -lg&#39; from the command-line. On my system it looks like this:&lt;br /&gt;
Level = Machine&lt;br /&gt;
&lt;br /&gt;
Code Groups:&lt;br /&gt;
&lt;br /&gt;
1.  All code: Nothing&lt;br /&gt;
1.1.  Zone - MyComputer: FullTrust&lt;br /&gt;
1.1.1.  Honor SkipVerification requests: SkipVerification&lt;br /&gt;
1.2.  Zone - Intranet: LocalIntranet&lt;br /&gt;
1.3.  Zone - Internet: Internet&lt;br /&gt;
1.4.  Zone - Untrusted: Nothing&lt;br /&gt;
1.5.  Zone - Trusted: Internet&lt;br /&gt;
1.6.  StrongName - 0024000004800000940000000602000000240000525341310004000003&lt;br /&gt;
000000CFCB3291AA715FE99D40D49040336F9056D7886FED46775BC7BB5430BA4444FEF8348EBD06&lt;br /&gt;
F962F39776AE4DC3B7B04A7FE6F49F25F740423EBF2C0B89698D8D08AC48D69CED0FC8F83B465E08&lt;br /&gt;
07AC11EC1DCC7D054E807A43336DDE408A5393A48556123272CEEEE72F1660B71927D38561AABF5C&lt;br /&gt;
AC1DF1734633C602F8F2D5: Everything&lt;br /&gt;
Note the hierarchy of code groups - the top of the hierarchy is the most general (&#39;All code&#39;), which is then sub-divided into several groups, each of which in turn can be sub-divided. Also note that (somewhat counter-intuitively) a sub-group can be associated with a more permissive permission set than its parent.&lt;br /&gt;
8.4 How do I define my own code group?&lt;br /&gt;
Use caspol. For example, suppose you trust code from www.mydomain.com and you want it have full access to your system, but you want to keep the default restrictions for all other internet sites. To achieve this, you would add a new code group as a sub-group of the &#39;Zone - Internet&#39; group, like this: &lt;br /&gt;
caspol -ag 1.3 -site www.mydomain.com FullTrust &lt;br /&gt;
Now if you run caspol -lg you will see that the new group has been added as group 1.3.1:&lt;br /&gt;
...&lt;br /&gt;
1.3.  Zone - Internet: Internet&lt;br /&gt;
1.3.1.  Site - www.mydomain.com: FullTrust&lt;br /&gt;
...&lt;br /&gt;
Note that the numeric label (1.3.1) is just a caspol invention to make the code groups easy to manipulate from the command-line. The underlying runtime never sees it. &lt;br /&gt;
8.5 How do I change the permission set for a code group?&lt;br /&gt;
Use caspol. If you are the machine administrator, you can operate at the &#39;machine&#39; level - which means not only that the changes you make become the default for the machine, but also that users cannot change the permissions to be more permissive. If you are a normal (non-admin) user you can still modify the permissions, but only to make them more restrictive. For example, to allow intranet code to do what it likes you might do this: &lt;br /&gt;
caspol -cg 1.2 FullTrust&lt;br /&gt;
Note that because this is more permissive than the default policy (on a standard system), you should only do this at the machine level - doing it at the user level will have no effect.&lt;br /&gt;
8.6 Can I create my own permission set?&lt;br /&gt;
Yes. Use caspol -ap, specifying an XML file containing the permissions in the permission set. To save you some time, here is a sample file corresponding to the &#39;Everything&#39; permission set - just edit to suit your needs. When you have edited the sample, add it to the range of available permission sets like this:&lt;br /&gt;
caspol -ap samplepermset.xml&lt;br /&gt;
Then, to apply the permission set to a code group, do something like this:&lt;br /&gt;
caspol -cg 1.3 SamplePermSet&lt;br /&gt;
(By default, 1.3 is the &#39;Internet&#39; code group)&lt;br /&gt;
8.7 I&#39;m having some trouble with CAS. How can I diagnose my problem?&lt;br /&gt;
Caspol has a couple of options that might help. First, you can ask caspol to tell you what code group an assembly belongs to, using caspol -rsg. Similarly, you can ask what permissions are being applied to a particular assembly using caspol -rsp.&lt;br /&gt;
8.8 I can&#39;t be bothered with all this CAS stuff. Can I turn it off?&lt;br /&gt;
Yes, as long as you are an administrator. Just run:&lt;br /&gt;
caspol -s off&lt;br /&gt;
9. Intermediate Language (IL)&lt;br /&gt;
9.1 Can I look at the IL for an assembly?&lt;br /&gt;
Yes. MS supply a tool called Ildasm which can be used to view the metadata and IL for an assembly.&lt;br /&gt;
9.2 Can source code be reverse-engineered from IL?&lt;br /&gt;
Yes, it is often relatively straightforward to regenerate high-level source (e.g. C#) from IL.&lt;br /&gt;
9.3 How can I stop my code being reverse-engineered from IL?&lt;br /&gt;
There is currently no simple way to stop code being reverse-engineered from IL. In future it is likely that IL obfuscation tools will become available, either from MS or from third parties. These tools work by &#39;optimising&#39; the IL in such a way that reverse-engineering becomes much more difficult.&lt;br /&gt;
Of course if you are writing web services then reverse-engineering is not a problem as clients do not have access to your IL.&lt;br /&gt;
9.4 Can I write IL programs directly?&lt;br /&gt;
Yes. Peter Drayton posted this simple example to the DOTNET mailing list:&lt;br /&gt;
.assembly MyAssembly {}&lt;br /&gt;
.class MyApp {&lt;br /&gt;
.method static void Main() {&lt;br /&gt;
.entrypoint&lt;br /&gt;
ldstr      &quot;Hello, IL!&quot;&lt;br /&gt;
call       void System.Console::WriteLine(class System.Object)&lt;br /&gt;
ret&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
Just put this into a file called hello.il, and then run ilasm hello.il. An exe assembly will be generated.&lt;br /&gt;
9.5 Can I do things in IL that I can&#39;t do in C#?&lt;br /&gt;
Yes. A couple of simple examples are that you can throw exceptions that are not derived from System.Exception, and you can have non-zero-based arrays.&lt;br /&gt;
10. Implications for COM&lt;br /&gt;
10.1 Is COM dead?&lt;br /&gt;
This subject causes a lot of controversy, as you&#39;ll see if you read the mailing list archives. Take a look at the following two threads:&lt;br /&gt;
http://discuss.develop.com/archives/wa.exe?A2=ind0007&amp;amp;L=DOTNET&amp;amp;D=0&amp;amp;P=68241 &lt;br /&gt;
http://discuss.develop.com/archives/wa.exe?A2=ind0007&amp;amp;L=DOTNET&amp;amp;P=R60761 &lt;br /&gt;
FWIW my view is as follows: COM is many things, and it&#39;s different things to different people. But to me, COM is fundamentally about how little blobs of code find other little blobs of code, and how they communicate with each other when they find each other. COM specifies precisely how this location and communication takes place. In a &#39;pure&#39; .NET world, consisting entirely of .NET objects, little blobs of code still find each other and talk to each other, but they don&#39;t use COM to do so. They use a model which is similar to COM in some ways - for example, type information is stored in a tabular form packaged with the component, which is quite similar to packaging a type library with a COM component. But it&#39;s not COM.&lt;br /&gt;
So, does this matter? Well, I don&#39;t really care about most of the COM stuff going away - I don&#39;t care that finding components doesn&#39;t involve a trip to the registry, or that I don&#39;t use IDL to define my interfaces. But there is one thing that I wouldn&#39;t like to go away - I wouldn&#39;t like to lose the idea of interface-based development. COM&#39;s greatest strength, in my opinion, is its insistence on a cast-iron separation between interface and implementation. Unfortunately, the .NET framework seems to make no such insistence - it lets you do interface-based development, but it doesn&#39;t insist. Some people would argue that having a choice can never be a bad thing, and maybe they&#39;re right, but I can&#39;t help feeling that maybe it&#39;s a backward step.&lt;br /&gt;
10.2 Is DCOM dead?&lt;br /&gt;
Pretty much, for .NET developers. The .NET Framework has a new remoting model which is not based on DCOM. Of course DCOM will still be used in interop scenarios. &lt;br /&gt;
10.3 Is MTS/COM+ dead?&lt;br /&gt;
No. The approach for the first .NET release is to provide access to the existing COM+ services (through an interop layer) rather than replace the services with native .NET ones. Various tools and attributes are provided to try to make this as painless as possible. The PDC release of the .NET SDK includes interop support for core services (JIT activation, transactions) but not some of the higher level services (e.g. COM+ Events, Queued components). &lt;br /&gt;
Over time it is expected that interop will become more seamless - this may mean that some services become a core part of the CLR, and/or it may mean that some services will be rewritten as managed code which runs on top of the CLR.&lt;br /&gt;
For more on this topic, search for postings by Joe Long in the archives - Joe is the MS group manager for COM+. Start with this message:&lt;br /&gt;
http://discuss.develop.com/archives/wa.exe?A2=ind0007&amp;amp;L=DOTNET&amp;amp;P=R68370 &lt;br /&gt;
10.4 Can I use COM components from .NET programs?&lt;br /&gt;
Yes. COM components are accessed from the .NET runtime via a Runtime Callable Wrapper (RCW). This wrapper turns the COM interfaces exposed by the COM component into .NET-compatible interfaces. For oleautomation interfaces, the RCW can be generated automatically from a type library. For non-oleautomation interfaces, it may be necessary to develop a custom RCW which manually maps the types exposed by the COM interface to .NET-compatible types.&lt;br /&gt;
Here&#39;s a simple example for those familiar with ATL. First, create an ATL component which implements the following IDL:&lt;br /&gt;
import &quot;oaidl.idl&quot;; &lt;br /&gt;
import &quot;ocidl.idl&quot;;&lt;br /&gt;
&lt;br /&gt;
[&lt;br /&gt;
object,&lt;br /&gt;
uuid(EA013F93-487A-4403-86EC-FD9FEE5E6206),&lt;br /&gt;
helpstring(&quot;ICppName Interface&quot;), &lt;br /&gt;
pointer_default(unique), &lt;br /&gt;
oleautomation&lt;br /&gt;
] &lt;br /&gt;
&lt;br /&gt;
interface ICppName : IUnknown&lt;br /&gt;
{ &lt;br /&gt;
[helpstring(&quot;method SetName&quot;)] HRESULT SetName([in] BSTR name); &lt;br /&gt;
[helpstring(&quot;method GetName&quot;)] HRESULT GetName([out,retval] BSTR *pName ); &lt;br /&gt;
}; &lt;br /&gt;
&lt;br /&gt;
[ &lt;br /&gt;
uuid(F5E4C61D-D93A-4295-A4B4-2453D4A4484D), &lt;br /&gt;
version(1.0),&lt;br /&gt;
helpstring(&quot;cppcomserver 1.0 Type Library&quot;)&lt;br /&gt;
] &lt;br /&gt;
library CPPCOMSERVERLib &lt;br /&gt;
{&lt;br /&gt;
importlib(&quot;stdole32.tlb&quot;);&lt;br /&gt;
importlib(&quot;stdole2.tlb&quot;); &lt;br /&gt;
[&lt;br /&gt;
uuid(600CE6D9-5ED7-4B4D-BB49-E8D5D5096F70),  &lt;br /&gt;
helpstring(&quot;CppName Class&quot;) &lt;br /&gt;
]&lt;br /&gt;
coclass CppName&lt;br /&gt;
{ &lt;br /&gt;
[default] interface ICppName; &lt;br /&gt;
};&lt;br /&gt;
};&lt;br /&gt;
When you&#39;ve built the component, you should get a typelibrary. Run the TLBIMP utility on the typelibary, like this:&lt;br /&gt;
tlbimp cppcomserver.tlb&lt;br /&gt;
If successful, you will get a message like this:&lt;br /&gt;
Typelib imported successfully to CPPCOMSERVERLib.dll&lt;br /&gt;
You now need a .NET client - let&#39;s use C#. Create a .cs file containing the following code:&lt;br /&gt;
using System;&lt;br /&gt;
using CPPCOMSERVERLib; &lt;br /&gt;
&lt;br /&gt;
public class MainApp &lt;br /&gt;
{ &lt;br /&gt;
static public void Main() &lt;br /&gt;
{ &lt;br /&gt;
CppName cppname = new CppName();&lt;br /&gt;
cppname.SetName( &quot;bob&quot; ); &lt;br /&gt;
Console.WriteLine( &quot;Name is &quot; + cppname.GetName() ); &lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
Note that we are using the type library name as a namespace, and the COM class name as the class. Alternatively we could have used CPPCOMSERVERLib.CppName for the class name and gone without the using CPPCOMSERVERLib statement.&lt;br /&gt;
Compile the C# code like this:&lt;br /&gt;
csc /r:cppcomserverlib.dll csharpcomclient.cs&lt;br /&gt;
Note that the compiler is being told to reference the DLL we previously generated from the typelibrary using TLBIMP.&lt;br /&gt;
You should now be able to run csharpcomclient.exe, and get the following output on the console:&lt;br /&gt;
Name is bob&lt;br /&gt;
10.5 Can I use .NET components from COM programs?&lt;br /&gt;
Yes. .NET components are accessed from COM via a COM Callable Wrapper (CCW). This is similar to a RCW (see previous question), but works in the opposite direction. Again, if the wrapper cannot be automatically generated by the .NET development tools, or if the automatic behaviour is not desirable, a custom CCW can be developed. Also, for COM to &#39;see&#39; the .NET component, the .NET component must be registered in the registry.&lt;br /&gt;
Here&#39;s a simple example. Create a C# file called testcomserver.cs and put the following in it:&lt;br /&gt;
&lt;br /&gt;
using System; &lt;br /&gt;
&lt;br /&gt;
namespace AndyMc &lt;br /&gt;
{ &lt;br /&gt;
[ClassInterface(ClassInterfaceType.AutoDual)]&lt;br /&gt;
public class CSharpCOMServer&lt;br /&gt;
{ &lt;br /&gt;
public CSharpCOMServer() {} &lt;br /&gt;
public void SetName( string name ) { m_name = name; } &lt;br /&gt;
public string GetName() { return m_name; }  &lt;br /&gt;
private string m_name; &lt;br /&gt;
}          &lt;br /&gt;
}&lt;br /&gt;
Then compile the .cs file as follows:&lt;br /&gt;
csc /target:library testcomserver.cs&lt;br /&gt;
You should get a dll, which you register like this:&lt;br /&gt;
regasm testcomserver.dll /tlb:testcomserver.tlb /codebase&lt;br /&gt;
Now you need to create a client to test your .NET COM component. VBScript will do - put the following in a file called comclient.vbs:&lt;br /&gt;
Dim dotNetObj &lt;br /&gt;
Set dotNetObj = CreateObject(&quot;AndyMc.CSharpCOMServer&quot;) &lt;br /&gt;
dotNetObj.SetName (&quot;bob&quot;) &lt;br /&gt;
MsgBox &quot;Name is &quot; &amp;amp; dotNetObj.GetName()&lt;br /&gt;
and run the script like this:&lt;br /&gt;
wscript comclient.vbs&lt;br /&gt;
And hey presto you should get a message box displayed with the text &quot;Name is bob&quot;.&lt;br /&gt;
An alternative to the approach above it to use the dm.net moniker developed by Jason Whittington and Don Box. Go to http://staff.develop.com/jasonw/clr/readme.htm to check it out.&lt;br /&gt;
10.6 Is ATL redundant in the .NET world?&lt;br /&gt;
Yes, if you are writing applications that live inside the .NET framework. Of course many developers may wish to continue using ATL to write C++ COM components that live outside the framework, but if you are inside you will almost certainly want to use C#. Raw C++ (and therefore ATL which is based on it) doesn&#39;t have much of a place in the .NET world - it&#39;s just too near the metal and provides too much flexibility for the runtime to be able to manage it.&lt;br /&gt;
11. Miscellaneous&lt;br /&gt;
11.1 How does .NET remoting work?&lt;br /&gt;
.NET remoting involves sending messages along channels. Two of the standard channels are HTTP and TCP. TCP is intended for LANs only - HTTP can be used for LANs or WANs (internet).&lt;br /&gt;
Support is provided for multiple message serializarion formats. Examples are SOAP (XML-based) and binary. By default, the HTTP channel uses SOAP (via the .NET runtime Serialization SOAP Formatter), and the TCP channel uses binary (via the .NET runtime Serialization Binary Formatter). But either channel can use either serialization format. &lt;br /&gt;
There are a number of styles of remote access: &lt;br /&gt;
•	SingleCall. Each incoming request from a client is serviced by a new object. The object is thrown away when the request has finished.&lt;br /&gt;
&lt;br /&gt;
•	Singleton. All incoming requests from clients are processed by a single server object. &lt;br /&gt;
&lt;br /&gt;
•	Client-activated object. This is the old stateful (D)COM model whereby the client receives a reference to the remote object and holds that reference (thus keeping the remote object alive) until it is finished with it. &lt;br /&gt;
Distributed garbage collection of objects is managed by a system called &#39;leased based lifetime&#39;. Each object has a lease time, and when that time expires the object is disconnected from the .NET runtime remoting infrastructure. Objects have a default renew time - the lease is renewed when a successful call is made from the client to the object. The client can also explicitly renew the lease.&lt;br /&gt;
If you&#39;re interested in using XML-RPC as an alternative to SOAP, take a look at Charles Cook&#39;s XML-RPC.Net site at http://www.cookcomputing.com/xmlrpc/xmlrpc.shtml.&lt;br /&gt;
11.2 How can I get at the Win32 API from a .NET program?&lt;br /&gt;
Use P/Invoke. This uses similar technology to COM Interop, but is used to access static DLL entry points instead of COM objects. Here is an example of C# calling the Win32 MessageBox function:&lt;br /&gt;
using System; &lt;br /&gt;
using System.Runtime.InteropServices; &lt;br /&gt;
&lt;br /&gt;
class MainApp &lt;br /&gt;
{ &lt;br /&gt;
[DllImport(&quot;user32.dll&quot;, EntryPoint=&quot;MessageBox&quot;, SetLastError=true, CharSet=CharSet.Auto)] 	&lt;br /&gt;
public static extern int MessageBox(int hWnd, String strMessage, String strCaption, uint uiType);&lt;br /&gt;
&lt;br /&gt;
public static void Main() &lt;br /&gt;
{&lt;br /&gt;
MessageBox( 0, &quot;Hello, this is PInvoke in operation!&quot;, &quot;.NET&quot;, 0 ); &lt;br /&gt;
}&lt;br /&gt;
}        &lt;br /&gt;
12. Class Library&lt;br /&gt;
12.1 File I/O&lt;br /&gt;
12.1.1 How do I read from a text file?&lt;br /&gt;
First, use a System.IO.FileStream object to open the file:&lt;br /&gt;
FileStream fs = new FileStream( @&quot;c:\test.txt&quot;, FileMode.Open, FileAccess.Read );&lt;br /&gt;
FileStream inherits from Stream, so you can wrap the FileStream object with a StreamReader object. This provides a nice interface for processing the stream line by line:&lt;br /&gt;
StreamReader sr = new StreamReader( fs );&lt;br /&gt;
string curLine;&lt;br /&gt;
while( (curLine = sr.ReadLine()) != null )&lt;br /&gt;
Console.WriteLine( curLine );&lt;br /&gt;
Finally close the StreamReader object:&lt;br /&gt;
sr.Close();&lt;br /&gt;
Note that this will automatically call Close() on the underlying Stream object, so an explicit fs.Close() is not required.&lt;br /&gt;
12.1.2 How do I write to a text file?&lt;br /&gt;
Similar to the read example, except use StreamWriter instead of StreamReader.&lt;br /&gt;
12.1.3 How do I read/write binary files?&lt;br /&gt;
Similar to text files, except wrap the FileStream object with a BinaryReader/Writer object instead of a StreamReader/Writer object. &lt;br /&gt;
12.2 Text Processing&lt;br /&gt;
12.2.1 Are regular expressions supported?&lt;br /&gt;
Yes. Use the System.Text.RegularExpressions.Regex class. For example, the following code updates the title in an HTML file:&lt;br /&gt;
FileStream fs = new FileStream( &quot;test.htm&quot;, FileMode.Open, FileAccess.Read );&lt;br /&gt;
StreamReader sr = new StreamReader( fs ); &lt;br /&gt;
&lt;br /&gt;
Regex r = new Regex( &quot;&lt;title&gt;(.*)&lt;/title&gt;&quot; ); &lt;br /&gt;
string s; &lt;br /&gt;
while( (s = sr.ReadLine()) != null ) &lt;br /&gt;
{&lt;br /&gt;
if( r.IsMatch( s ) )  &lt;br /&gt;
s = r.Replace( s, &quot;&lt;title&gt;New and improved ${1}&lt;/title&gt;&quot; );&lt;br /&gt;
Console.WriteLine( s ); &lt;br /&gt;
}&lt;br /&gt;
12.3 Internet&lt;br /&gt;
12.3.1 How do I download a web page?&lt;br /&gt;
First use the System.Net.WebRequestFactory class to acquire a WebRequest object:&lt;br /&gt;
WebRequest request = WebRequest.Create( &quot;http://localhost&quot; );&lt;br /&gt;
Then ask for the response from the request:&lt;br /&gt;
WebResponse response = request.GetResponse();&lt;br /&gt;
The GetResponse method blocks until the download is complete. Then you can access the response stream like this:&lt;br /&gt;
Stream s = response.GetResponseStream();&lt;br /&gt;
&lt;br /&gt;
// Output the downloaded stream to the console&lt;br /&gt;
StreamReader sr = new StreamReader( s );&lt;br /&gt;
string line;&lt;br /&gt;
while( (line = sr.ReadLine()) != null )&lt;br /&gt;
Console.WriteLine( line );&lt;br /&gt;
Note that WebRequest and WebReponse objects can be downcast to HttpWebRequest and HttpWebReponse objects respectively, to access http-specific functionality.&lt;br /&gt;
12.3.2 How do I use a proxy?&lt;br /&gt;
Two approaches - to affect all web requests do this:&lt;br /&gt;
System.Net.GlobalProxySelection.Select = new WebProxy( &quot;proxyname&quot;, 80 );&lt;br /&gt;
Alternatively, to set the proxy for a specific web request, do this:&lt;br /&gt;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create( &quot;http://localhost&quot; );&lt;br /&gt;
request.Proxy = new WebProxy( &quot;proxyname&quot;, 80 );&lt;br /&gt;
12.4 XML&lt;br /&gt;
12.4.1 Is DOM supported?&lt;br /&gt;
Yes. Take this example XML document:&lt;br /&gt;
&lt;people&gt;&lt;br /&gt;
&lt;person&gt;Fred&lt;/person&gt;&lt;br /&gt;
&lt;person&gt;Bill&lt;/person&gt;	&lt;br /&gt;
&lt;/people&gt;	&lt;br /&gt;
This document can be parsed as follows:&lt;br /&gt;
XmlDocument doc = new XmlDocument();&lt;br /&gt;
doc.Load( &quot;test.xml&quot; );&lt;br /&gt;
&lt;br /&gt;
XmlNode root = doc.DocumentElement;&lt;br /&gt;
&lt;br /&gt;
foreach( XmlNode personElement in root.ChildNodes )&lt;br /&gt;
Console.WriteLine( personElement.FirstChild.Value.ToString() );&lt;br /&gt;
The output is:&lt;br /&gt;
Fred&lt;br /&gt;
Bill&lt;br /&gt;
12.4.2 Is SAX supported?&lt;br /&gt;
No. Instead, a new XmlReader/XmlWriter API is offered. Like SAX it is stream-based but it uses a &#39;pull&#39; model rather than SAX&#39;s &#39;push&#39; model. Here&#39;s an example:&lt;br /&gt;
XmlTextReader reader = new XmlTextReader( &quot;test.xml&quot; );&lt;br /&gt;
&lt;br /&gt;
while( reader.Read() )&lt;br /&gt;
{&lt;br /&gt;
if( reader.NodeType == XmlNodeType.Element &amp;amp;&amp;amp; reader.Name == &quot;PERSON&quot; )&lt;br /&gt;
{&lt;br /&gt;
reader.Read(); // Skip to the child text&lt;br /&gt;
Console.WriteLine( reader.Value );&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
12.4.3 Is XPath supported?&lt;br /&gt;
Yes, via the XPathXXX classes:&lt;br /&gt;
XPathDocument xpdoc = new XPathDocument(&quot;test.xml&quot;);&lt;br /&gt;
XPathNavigator nav = xpdoc.CreateNavigator();&lt;br /&gt;
XPathExpression expr = nav.Compile(&quot;descendant::PEOPLE/PERSON&quot;);&lt;br /&gt;
&lt;br /&gt;
XPathNodeIterator iterator = nav.Select(expr);&lt;br /&gt;
while (iterator.MoveNext())&lt;br /&gt;
Console.WriteLine(iterator.Current);&lt;br /&gt;
12.5 Threading&lt;br /&gt;
12.5.1 Is multi-threading supported?&lt;br /&gt;
Yes, there is extensive support for multi-threading. New threads can be spawned, and there is a system-provided threadpool which applications can use.&lt;br /&gt;
12.5.2 How do I spawn a thread?&lt;br /&gt;
Create an instance of a System.Threading.Thread object, passing it an instance of a ThreadStart delegate that will be executed on the new thread. For example:&lt;br /&gt;
class MyThread&lt;br /&gt;
{&lt;br /&gt;
public MyThread( string initData )&lt;br /&gt;
{&lt;br /&gt;
m_data = initData;&lt;br /&gt;
m_thread = new Thread( new ThreadStart(ThreadMain) );	&lt;br /&gt;
m_thread.Start();	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// ThreadMain() is executed on the new thread.&lt;br /&gt;
private void ThreadMain()&lt;br /&gt;
{&lt;br /&gt;
Console.WriteLine( m_data );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void WaitUntilFinished()&lt;br /&gt;
{&lt;br /&gt;
m_thread.Join();&lt;br /&gt;
}	&lt;br /&gt;
&lt;br /&gt;
private Thread m_thread;&lt;br /&gt;
private string m_data;&lt;br /&gt;
}&lt;br /&gt;
In this case creating an instance of the MyThread class is sufficient to spawn the thread and execute the MyThread.ThreadMain() method:&lt;br /&gt;
MyThread t = new MyThread( &quot;Hello, world.&quot; );&lt;br /&gt;
t.WaitUntilFinished();&lt;br /&gt;
12.5.3 How do I stop a thread?&lt;br /&gt;
There are several options. First, you can use your own communication mechanism to tell the ThreadStart method to finish. Alternatively the Thread class has in-built support for instructing the thread to stop. The two principle methods are Thread.Interrupt() and Thread.Abort(). The former will cause a ThreadInterruptedException to be thrown on the thread when it next goes into a WaitJoinSleep state. In other words, Thread.Interrupt is a polite way of asking the thread to stop when it is no longer doing any useful work. In contrast, Thread.Abort() throws a ThreadAbortException regardless of what the thread is doing. Furthermore, the ThreadAbortException cannot normally be caught (though the ThreadStart&#39;s finally method will be executed). Thread.Abort() is a heavy-handed mechanism which should not normally be required.&lt;br /&gt;
12.5.4 How do I use the thread pool?&lt;br /&gt;
By passing an instance of a WaitCallback delegate to the ThreadPool.QueueUserWorkItem() method:&lt;br /&gt;
class CApp&lt;br /&gt;
{&lt;br /&gt;
static void Main()&lt;br /&gt;
{&lt;br /&gt;
string s = &quot;Hello, World&quot;;&lt;br /&gt;
ThreadPool.QueueUserWorkItem( new WaitCallback( DoWork ), s );&lt;br /&gt;
&lt;br /&gt;
Thread.Sleep( 1000 );	// Give time for work item to be executed&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// DoWork is executed on a thread from the thread pool.&lt;br /&gt;
static void DoWork( object state )&lt;br /&gt;
{&lt;br /&gt;
Console.WriteLine( state );&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
12.5.5 How do I know when my thread pool work item has completed?&lt;br /&gt;
There is no way to query the thread pool for this information. You must put code into the WaitCallback method to signal that it has completed. Events are useful for this.&lt;br /&gt;
12.5.6 How do I prevent concurrent access to my data?&lt;br /&gt;
Each object has a concurrency lock (critical section) associated with it. The System.Threading.Monitor.Enter/Exit methods are used to acquire and release this lock. For example, instances of the following class only allow one thread at a time to enter method f():&lt;br /&gt;
class C&lt;br /&gt;
{&lt;br /&gt;
public void f()&lt;br /&gt;
{&lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
Monitor.Enter(this);&lt;br /&gt;
...&lt;br /&gt;
}&lt;br /&gt;
finally&lt;br /&gt;
{&lt;br /&gt;
Monitor.Exit(this);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
C# has a &#39;lock&#39; keyword which provides a convenient shorthand for the code above:&lt;br /&gt;
class C&lt;br /&gt;
{&lt;br /&gt;
public void f()&lt;br /&gt;
{&lt;br /&gt;
lock(this)&lt;br /&gt;
{&lt;br /&gt;
...&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
Note that calling Monitor.Enter(myObject) does NOT mean that all access to myObject is serialized. It means that the synchronisation lock associated with myObject has been acquired, and no other thread can acquire that lock until Monitor.Exit(o) is called. In other words, this class is functionally equivalent to the classes above:&lt;br /&gt;
class C&lt;br /&gt;
{&lt;br /&gt;
public void f()&lt;br /&gt;
{&lt;br /&gt;
lock( m_object )&lt;br /&gt;
{&lt;br /&gt;
...&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
private m_object = new object();&lt;br /&gt;
}&lt;br /&gt;
12.6 Tracing&lt;br /&gt;
12.6.1 Is there built-in support for tracing/logging?&lt;br /&gt;
Yes, in the System.Diagnostics namespace. There are two main classes that deal with tracing - Debug and Trace. They both work in a similar way - the difference is that tracing from the Debug class only works in builds that have the DEBUG symbol defined, whereas tracing from the Trace class only works in builds that have the TRACE symbol defined. Typically this means that you should use System.Diagnostics.Trace.WriteLine for tracing that you want to work in debug and release builds, and System.Diagnostics.Debug.WriteLine for tracing that you want to work only in debug builds.&lt;br /&gt;
12.6.2 Can I redirect tracing to a file?&lt;br /&gt;
Yes. The Debug and Trace classes both have a Listeners property, which is a collection of sinks that receive the tracing that you send via Debug.WriteLine and Trace.WriteLine respectively. By default the Listeners collection contains a single sink, which is an instance of the DefaultTraceListener class. This sends output to the Win32 OutputDebugString() function and also the System.Diagnostics.Debugger.Log() method. This is useful when debugging, but if you&#39;re trying to trace a problem at a customer site, redirecting the output to a file is more appropriate. Fortunately, the TextWriterTraceListener class is provided for this purpose.&lt;br /&gt;
Here&#39;s how to use the TextWriterTraceListener class to redirect Trace output to a file:&lt;br /&gt;
Trace.Listeners.Clear();&lt;br /&gt;
FileStream fs = new FileStream( @&quot;c:\log.txt&quot;, FileMode.Create, FileAccess.Write );&lt;br /&gt;
Trace.Listeners.Add( new TextWriterTraceListener( fs ) );&lt;br /&gt;
&lt;br /&gt;
Trace.WriteLine( @&quot;This will be writen to c:\log.txt!&quot; );&lt;br /&gt;
Trace.Flush();&lt;br /&gt;
Note the use of Trace.Listeners.Clear() to remove the default listener. If you don&#39;t do this, the output will go to the file and OutputDebugString(). Typically this is not what you want, because OutputDebugString() imposes a big performance hit.&lt;br /&gt;
12.6.3 Can I customise the trace output?&lt;br /&gt;
Yes. You can write your own TraceListener-derived class, and direct all output through it. Here&#39;s a simple example, which derives from TextWriterTraceListener (and therefore has in-built support for writing to files, as shown above) and adds timing information and the thread ID for each trace line:&lt;br /&gt;
class MyListener : TextWriterTraceListener&lt;br /&gt;
{&lt;br /&gt;
public MyListener( Stream s ) : base(s)&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public override void WriteLine( string s )&lt;br /&gt;
{&lt;br /&gt;
Writer.WriteLine( &quot;{0:D8} [{1:D4}] {2}&quot;, &lt;br /&gt;
Environment.TickCount - m_startTickCount, &lt;br /&gt;
AppDomain.GetCurrentThreadId(),&lt;br /&gt;
s );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
protected int m_startTickCount = Environment.TickCount;&lt;br /&gt;
}&lt;br /&gt;
(Note that this implementation is not complete - the TraceListener.Write method is not overridden for example.)&lt;br /&gt;
The beauty of this approach is that when an instance of MyListener is added to the Trace.Listeners collection, all calls to Trace.WriteLine() go through MyListener, including calls made by referenced assemblies that know nothing about the MyListener class.&lt;br /&gt;
Interview Questions&lt;br /&gt;
.NET Windows Forms&lt;br /&gt;
&lt;br /&gt;
1.	Write a simple Windows Forms MessageBox statement.&lt;br /&gt;
2.	System.Windows.Forms.MessageBox.Show&lt;br /&gt;
&lt;br /&gt;
3.	  (&quot;Hello, Windows Forms&quot;);&lt;br /&gt;
4.	Can you write a class without specifying namespace? Which namespace does it belong to by default??&lt;br /&gt;
Yes, you can, then the class belongs to global namespace which has no name. For commercial products, naturally, you wouldn’t want global namespace. &lt;br /&gt;
5.	You are designing a GUI application with a window and several widgets on it. The user then resizes the app window and sees a lot of grey space, while the widgets stay in place. What’s the problem? One should use anchoring for correct resizing. Otherwise the default property of a widget on a form is top-left, so it stays at the same location when resized. &lt;br /&gt;
6.	How can you save the desired properties of Windows Forms application? .config files in .NET are supported through the API to allow storing and retrieving information. They are nothing more than simple XML files, sort of like what .ini files were before for Win32 apps. &lt;br /&gt;
7.	So how do you retrieve the customized properties of a .NET application from XML .config file? Initialize an instance of AppSettingsReader class. Call the GetValue method of AppSettingsReader class, passing in the name of the property and the type expected. Assign the result to the appropriate variable. &lt;br /&gt;
8.	Can you automate this process? In Visual Studio yes, use Dynamic Properties for automatic .config creation, storage and retrieval. &lt;br /&gt;
9.	My progress bar freezes up and dialog window shows blank, when an intensive background process takes over. Yes, you should’ve multi-threaded your GUI, with taskbar and main form being one thread, and the background process being the other. &lt;br /&gt;
10.	What’s the safest way to deploy a Windows Forms app? Web deployment: the user always downloads the latest version of the code; the program runs within security sandbox, properly written app will not require additional security privileges. &lt;br /&gt;
11.	Why is it not a good idea to insert code into InitializeComponent method when working with Visual Studio? The designer will likely throw it away; most of the code inside InitializeComponent is auto-generated. &lt;br /&gt;
12.	What’s the difference between WindowsDefaultLocation and WindowsDefaultBounds? WindowsDefaultLocation tells the form to start up at a location selected by OS, but with internally specified size. WindowsDefaultBounds delegates both size and starting position choices to the OS. &lt;br /&gt;
13.	What’s the difference between Move and LocationChanged? Resize and SizeChanged? Both methods do the same, Move and Resize are the names adopted from VB to ease migration to C#. &lt;br /&gt;
14.	How would you create a non-rectangular window, let’s say an ellipse? Create a rectangular form, set the TransparencyKey property to the same value as BackColor, which will effectively make the background of the form transparent. Then set the FormBorderStyle to FormBorderStyle.None, which will remove the contour and contents of the form. &lt;br /&gt;
15.	How do you create a separator in the Menu Designer? A hyphen ‘-’ would do it. Also, an ampersand ‘&amp;amp;\’ would underline the next letter. &lt;br /&gt;
16.	How’s anchoring different from docking? Anchoring treats the component as having the absolute size and adjusts its location relative to the parent form. Docking treats the component location as absolute and disregards the component size. So if a status bar must always be at the bottom no matter what, use docking. If a button should be on the top right, but change its position with the form being resized, use anchoring. &lt;br /&gt;
&lt;br /&gt;
Here is a list of some common questions I ask potential candidates when screening for interviews (and no, I don&#39;t expect answers as in depth as I&#39;ve listed here):&lt;br /&gt;
&lt;br /&gt;
What are some of the objects exposed by the .NET framework that lend themselves to asynchronous method invocation, and what are a few ways architecturally to use these objects? What is the name of the interface used primarily as a way to check on an asynchronous method call?&lt;br /&gt;
&lt;br /&gt;
The simplest way to execute a method asynchronously is to start it with BeginInvoke, do some work on the main thread, and then call EndInvoke. EndInvoke does not return until the asynchronous call completes. This is a good technique to use with file or network operations, but because it blocks on EndInvoke, you should not use it from threads that service the user interface. &lt;br /&gt;
&lt;br /&gt;
Waiting on a WaitHandle is a common thread synchronization technique. You can obtain a WaitHandle using the AsyncWaitHandle property of the IAsyncResult returned by BeginInvoke. The WaitHandle is signaled when the asynchronous call completes, and you can wait for it by calling its WaitOne. If you use a WaitHandle, you can perform additional processing after the asynchronous call completes, but before you retrieve the results by calling EndInvoke. Bear in mind that the call to EndInvoke will block the calling thread unless the asnychronous method call has completed. &lt;br /&gt;
&lt;br /&gt;
You can use the boolean IsCompleted property of the IAsyncResult returned by BeginInvoke to discover when the asynchronous call completes. You might do this when making the asynchronous call from a thread that services the user interface. Polling for completion allows the user interface thread to continue processing user input, thus this is the preferred way for a GUI to call an method asynchronously. &lt;br /&gt;
If the thread that initiates the asynchronous call does not need to process the results, you can execute a callback method when the call completes. The callback method is executed on a ThreadPool thread. To use a callback method, you must pass BeginInvoke an AsyncCallback delegate representing the method. You can also pass an object containing information to be used by the callback method. For example, you might pass the delegate that was used to initiate the call, so the callback method can call EndInvoke. If a callback has been specified on the BeginInvoke, it will be called when the target method returns. In the callback, the EndInvoke method is used to obtain the return value and the in/out parameters. If the callback was not specified on the BeginInvoke, then EndInvoke can be used on the original thread that submitted a request.&lt;br /&gt;
Name a design pattern you&#39;ve used on a regular basis, and explain why you&#39;ve used it and how it lent itself to accomplishing the programming task you were trying to accomplish. (there are numerous answers, if they name one and can talk about it for a minute or 2, that should suffice). Common ones will be Singleton, Factory, Observer, Asynchronous, Disposable, and Controller.&lt;br /&gt;
&lt;br /&gt;
What are the similarities/differences between interfaces and abstract classes? When and why would use either one, and name a specific instance when you would use one and not the other?&lt;br /&gt;
&lt;br /&gt;
Interfaces support multiple inheritances, whereas you can only inherit from one abstract class. &lt;br /&gt;
Abstract classes support partial to full implementation, whereas interfaces only define a contract with no implementation. &lt;br /&gt;
If you anticipate creating multiple versions of your component, create an abstract class. Abstract classes provide a simple and easy way to version your components. By updating the base class, all inheriting classes are automatically updated with the change. Interfaces, on the other hand, cannot be changed once created. If a new version of an interface is required, you must create a whole new interface. &lt;br /&gt;
If the functionality you are creating will be useful across a wide range of disparate objects, use an interface. Abstract classes should be used primarily for objects that are closely related, whereas interfaces are best suited for providing common functionality to unrelated classes. &lt;br /&gt;
If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class. &lt;br /&gt;
If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members.&lt;br /&gt;
&lt;br /&gt;
What are 2 ways to facilitate the passing of objects across application domains via reflection? IE, there are 2 seperate programming constructs that can be used to enable objects to passed across application domains, a default class by itself cannot be passed across app domains. HINT: one is an attribute, the other is a base class.&lt;br /&gt;
&lt;br /&gt;
You can mark the object with the Serializable attribute. Bear in mind that this will in turn make each and every member of the class serializable as well. If you need to implement partial serialization, inherit from ISerializable and just serialize the members you need to...or use the NonSerializable attribute on those members. An object that is serialized across application domains is done so as a copy of the object (similar to ByValue), so this can be an expensive proposition with larger objects. &lt;br /&gt;
If you inherit from MarshalByRefObject, you will get the same desired end result, however instead of a copy of the object being transported to the remote application domain, a proxy will be created that facilitates communication between the objects. When an object derives from MarshalByRefObject, an object reference will be passed from one application domain to another, rather than the object itself.&lt;br /&gt;
&lt;br /&gt;
What are the 2 transport protocols that can be used in .NET remoting? What are the 2 transport payload types? What network scenarios are each combination best suited for?&lt;br /&gt;
&lt;br /&gt;
SOAP payload via HTTP protocol. The HTTP channel uses the SOAP formatter by default and hence can be used in scenarios where clients will access the objects over the Internet. Since this approach uses HTTP, accessing .NET objects remotely through a firewall is enabled by this configuration. Objects exposed in this way can easily be configured as Web Services Objects simply by hosting these objects in IIS. Clients can then read the WSDL files of these objects to communicate with the Remote object using SOAP. There is an associated performance hit as SOAP payloads are quite a bit larger than their binary counterparts. &lt;br /&gt;
Binary payload via TCP protocol. The TCP Channel uses the binary formatter by default. This formatter serializes the data in binary form and uses raw sockets to transmit data across the network. This method is ideal if your object is deployed in a closed environment within the confines of a firewall. This approach is more optimized since it uses sockets to communicate binary data between objects. Using the TCP channel to expose your object gives you the advantage of low overhead in closed environments. This approach cannot be used over the Internet because of firewall and configuration issues.&lt;br /&gt;
&lt;br /&gt;
Last one...what are some of the key fundamental differences between C# and VB.NET?&lt;br /&gt;
&lt;br /&gt;
VB.NET doesn&#39;t support operator overloading. &lt;br /&gt;
C# is case sensitive. &lt;br /&gt;
C# instrinsically supports code comment sheets via XML tags. &lt;br /&gt;
You can write unsafe (C/C++ style) code in C# code blocks. &lt;br /&gt;
More explicit casting is necessary when writing in C#. &lt;br /&gt;
VB.NET supports optional parameters. &lt;br /&gt;
In VB.NET, parameters are passed by reference by default, whereas in C# parameters are passed by value. &lt;br /&gt;
Method level vars must be initialized in C# (even if it&#39;s with a null type), whereas in VB.NET there is some leniency with this. &lt;br /&gt;
VB.NET supports the With [typeName] construct, allowing for multiple actions to be performed on a type in one block. &lt;br /&gt;
VB.NET does not support unsigned numeric primitives. &lt;br /&gt;
VB.NET supports re-allocating an array (ReDim).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1.	What do you know about .NET assemblies? Assemblies are the smallest units of versioning and deployment in the .NET application. Assemblies are also the building blocks for programs such as Web services, Windows services, serviced components, and .NET remoting applications. &lt;br /&gt;
2.	What’s the difference between private and shared assembly? Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name. &lt;br /&gt;
3.	What’s a strong name? A strong name includes the name of the assembly, version number, culture identity, and a public key token. &lt;br /&gt;
4.	How can you tell the application to look for assemblies at the locations other than its own install? Use the&lt;br /&gt;
directive in the XML .config file for a given application.&lt;br /&gt;
&lt;probing bin\debug”=&quot;&quot; privatepath=&quot;”c:\mylibs;&quot;&gt;&lt;br /&gt;
should do the trick. Or you can add additional search paths in the Properties box of the deployed application. &lt;br /&gt;
5.	How can you debug failed assembly binds? Use the Assembly Binding Log Viewer (fuslogvw.exe) to find out the paths searched. &lt;br /&gt;
6.	Where are shared assemblies stored? Global assembly cache. &lt;br /&gt;
7.	How can you create a strong name for a .NET assembly? With the help of Strong Name tool (sn.exe). &lt;br /&gt;
8.	Where’s global assembly cache located on the system? Usually C:\winnt\assembly or C:\windows\assembly. &lt;br /&gt;
9.	Can you have two files with the same file name in GAC? Yes, remember that GAC is a very special folder, and while normally you would not be able to place two files with the same name into a Windows folder, GAC differentiates by version number as well, so it’s possible for MyApp.dll and MyApp.dll to co-exist in GAC if the first one is version 1.0.0.0 and the second one is 1.1.0.0. &lt;br /&gt;
10.	So let’s say I have an application that uses MyApp.dll assembly, version 1.0.0.0. There is a security bug in that assembly, and I publish the patch, issuing it under name MyApp.dll 1.1.0.0. How do I tell the client applications that are already installed to start using this new MyApp.dll? Use publisher policy. To configure a publisher policy, use the publisher policy configuration file, which uses a format similar app .config file. But unlike the app .config file, a publisher policy file needs to be compiled into an assembly and placed in the GAC. &lt;br /&gt;
11.	What is delay signing? Delay signing allows you to place a shared assembly in the GAC by signing the assembly with just the public key. This allows the assembly to be signed with the private key at a later stage, when the development process is complete and the component or assembly is ready to be deployed. This process enables developers to work with shared assemblies as if they were strongly named, and it secures the private key of the signature from being accessed at different stages of development. &lt;br /&gt;
&lt;br /&gt;
&lt;/probing&gt;</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/1169068789810496942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/interview-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/1169068789810496942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/1169068789810496942'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/interview-questions.html' title='Interview Questions'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-916428602799105551</id><published>2011-01-15T22:46:00.001+05:30</published><updated>2011-01-15T22:46:48.621+05:30</updated><title type='text'>VB 6.0 Interview Questions</title><content type='html'>VB INTERVIEW QUESTIONS&lt;br /&gt;
&lt;br /&gt;
What are the three main differences between flexgrid control and dbgrid (Data bound Grid) control &lt;br /&gt;
&lt;br /&gt;
Microsoft FlexGrid (MSFlexGrid) Data-bound grid (DBGrid)&lt;br /&gt;
1. MSFlexGrid control displays and operates on tabular data. 1. Dbgrid is a spreadsheet-like bound control that displays a series of rows and columns representing records and fields from a Recordset object.&lt;br /&gt;
2. It allows complete flexibility to sort, merge, and format tables containing strings and pictures. 2. The data grids are bound controls; that is, they require a data source that actually connects to a database and retrieves their data.&lt;br /&gt;
3. When bound to a Data control, MSFlexGrid displays read-only data. 3. When you change a record in DBGrid &amp; move forward to a new record, the recordset is updated, if it is not locked &amp; AllowUpdate property = True.&lt;br /&gt;
&lt;br /&gt;
The Microsoft FlexGrid (MSFlexGrid) control displays and operates on tabular data. It allows complete flexibility to sort, merge, and format tables containing strings and pictures. When bound to a Data control, MSFlexGrid displays read-only data. Adaptation to existing Visual Basic code for the data-bound grid (DBGrid). &lt;br /&gt;
&lt;br /&gt;
Dbgrid is a spreadsheet-like bound control that displays a series of rows and columns representing records and fields from a Recordset object.&lt;br /&gt;
&lt;br /&gt;
The data grids are bound controls; that is, they require a data source that actually connects to a database and retrieves their data. And it seems that the root of the problem with DBGrid is that there&#39;s no data source that can be readily included along with the DBGrid control. &lt;br /&gt;
In Visual Basic, the solution is simply to include the Data Control on the same form as DBGrid. But the Data Control is an intrinsic control; it&#39;s unavailable to anything outside of the Visual Basic environment itself. and VB 6.0 has a new set of data controls (DataGrid, DataList, DataCombo, MSHFlexGrid, and MSFlexGrid) that once again are bound controls. Unlike DBGrid, though, they support OLE DB, and therefore rely on the ADO Data Source (and in particular the ActiveX Data Objects Data Control, or ADO DC) for data access. Unlike the Data Control, the ADO DC is a custom control (that is, an .OCX) that can be added to any project. In short, if you add ADO DC to your project along with the DataGrid control. &lt;br /&gt;
&lt;br /&gt;
What are the ActiveX and Types of ActiveX Components in VB?&lt;br /&gt;
Standard EXE &lt;br /&gt;
ActiveX EXE &lt;br /&gt;
ActiveX DLL &lt;br /&gt;
ActiveX document&lt;br /&gt;
ActiveX Control&lt;br /&gt;
&lt;br /&gt;
What is difference between inprocess and out of process?&lt;br /&gt;
An in-process component is implemented as a DLL, and runs in the same process space as its client app, enabling the most efficient communication between client and component. Each client app that uses the component starts a new instance of it.&lt;br /&gt;
&lt;br /&gt;
An out-of-process component is implemented as an EXE, and unlike a dll, runs in its own process space. As a result, exe&#39;s are slower then dll&#39;s because communications between client and component must be marshalled across process boundaries. A single instance of an out of process component can service many clients. &lt;br /&gt;
&lt;br /&gt;
What are the Advantage of ActiveX Dll over Active Exe?&lt;br /&gt;
&lt;br /&gt;
ACTIVEX DLL: &lt;br /&gt;
=============&lt;br /&gt;
An in-process component, or ActiveX DLL, runs in another application’s process. In-process components are used by applications or other in-process components. this allows you to wrap up common functionality (like an ActiveX Exe).&lt;br /&gt;
&lt;br /&gt;
ACTIVEX EXE: &lt;br /&gt;
=============&lt;br /&gt;
An out-of-process component, or ActiveX EXE, runs in its own address space. The client is usually an application running in another process. The code running in an ActiveX Exe is running in a separate process space. You would usually use this in N-Tier programming.&lt;br /&gt;
&lt;br /&gt;
An ActiveX EXE runs out of process while an ActiveX DLL runs in the same process space as VB app. Also, and ActiveX EXE can be run independent of your application if desired. &lt;br /&gt;
&lt;br /&gt;
Explain single thread and multithread thread apartments?&lt;br /&gt;
All components created with Visual Basic use the apartment model, whether they’re single-threaded or multithreaded. A single-threaded component has only one apartment, which contains all the objects the component provides. &lt;br /&gt;
&lt;br /&gt;
This means that a single-threaded DLL created with Visual Basic is safe to use with a multithreaded client. However, there’s a performance trade-off for this safety. Calls from all client threads except one are marshaled, just as if they were out-of-process calls.&lt;br /&gt;
&lt;br /&gt;
What is a Component?&lt;br /&gt;
If you compile an ActiveX dll, it becomes a component.&lt;br /&gt;
If you compile an ActiveX Control, it becomes both a component and a control. Component is a general term used to describe code that&#39;s grouped by functionality. More specifically, a component in COM terms is a compiled collection of properties/methods and events. &lt;br /&gt;
&lt;br /&gt;
Typically a component is loaded into your project via the References whereas an ActiveX Control is loaded into your project via &quot;components&quot;. &lt;br /&gt;
&lt;br /&gt;
What is meant by &quot;Early Binding&quot; and &quot;Late Binding&quot;? Which is better?&lt;br /&gt;
Early binding and late binding refer to the method used to bind an interface&#39;s properties and methods to an object reference (variable). Early binding uses type library information at design time to reference procedures, while late binding handles this at run time. Late binding handles this by interrogating the reference before each call to insure that it supports a particular method. Since every call to a late bound object actually requires two calls (&quot;Do you do this?&quot; followed by &quot;Okay, do it then&quot;), late binding is much less efficient than early binding. Except where early binding is not supported (ASP, scripting, etc.), late binding should only be used in very special cases. &lt;br /&gt;
&lt;br /&gt;
It is a common misconception that any code using the CreateObject function instead of Set = New is using late binding. This is not the case. The type declaration of the object variable determines whether&lt;br /&gt;
it is late or early bound, as in the following:&lt;br /&gt;
&lt;br /&gt;
Dim A As Foo&lt;br /&gt;
Dim B As Foo&lt;br /&gt;
Dim C As Object&lt;br /&gt;
Dim D As Object&lt;br /&gt;
&lt;br /&gt;
Set A = New Foo &#39;Early Bound&lt;br /&gt;
Set B = CreateObject(&quot;FooLib.Foo&quot;) &#39;Early Bound&lt;br /&gt;
Set C = CreateObject(&quot;FooLib.Foo&quot;) &#39;Late Bound&lt;br /&gt;
Set D = New Foo &#39;Late Bound&lt;br /&gt;
&lt;br /&gt;
What are the Advantages of disconnected recordsets?&lt;br /&gt;
A disconnected Recordset, as its name implies, is a Recordset that lacks a connection. &lt;br /&gt;
&lt;br /&gt;
seen that a Recordset that does not have a database connection can be very useful as a tool in your programming. It can save you time and effort and make your code more scalable. &lt;br /&gt;
&lt;br /&gt;
In order to create a disconnected Recordset two Recordset properties must be set appropriately. &lt;br /&gt;
It is a requirement that the CursorLocation property is set to adUseClient and the LockType property is set to adLockBatchOptimistic. Note that the CursorType will default to adUseStatic if we don&#39;t explicitly state that it should be set to adUseClient.) i.e.&lt;br /&gt;
&lt;br /&gt;
rst.LockType = adLockBatchOptimistic&lt;br /&gt;
rst.CursorLocation = adUseClient&lt;br /&gt;
&lt;br /&gt;
However, we&#39;ve recently discovered that these steps aren&#39;t necessary. VB automatically assigns batch optimistic locking to newly created, connectionless recordsets. And, of course, without a connection, a recordset can&#39;t have any other cursor but a client-side one. To create one of these structures, then, the only thing you need do is create the object variable instance. After that, you can simply begin adding fields to the construct.&lt;br /&gt;
&lt;br /&gt;
To add fields, you use the Fields collection&#39;s Append method. This method requires two parameters, the field name and the field data type. So, to create a connectionless recordset with two fields, you’d use code similar to: &lt;br /&gt;
&lt;br /&gt;
Dim rst As ADODB.Recordset&lt;br /&gt;
Set rst = New ADODB.Recordset&lt;br /&gt;
&lt;br /&gt;
rst.Fields.Append &quot;CustID&quot;, adVarChar&lt;br /&gt;
rst.Fields.Append &quot;CustName&quot;, adVarChar&lt;br /&gt;
&lt;br /&gt;
Additional, optional Append method parameters include DefinedSize and Attrib. The DefinedSize argument takes the size of the field. Fill the Attrib parameter with constants that define additional field characteristics, such as whether it will allow null values or is updatable. &lt;br /&gt;
Since, in our technique, we want the fields to mirror the structure of the original recordset, we&#39;ll simply use existing values for these parameters.&lt;br /&gt;
&lt;br /&gt;
Disconnected Recordsets, first available with ADO 2.0, are the most commonly used mechanism to retrieve a Recordset and open a connection for only the necessary amount of time, thus increasing scalability. They are call disconnected because the connection to the database is closed. &lt;br /&gt;
The collections, properties, and methods of a disconnected Recordset are still available even though the connection is closed. This frees up server resources, given that the number of open connections is limited and database locking is a non-issue. &lt;br /&gt;
&lt;br /&gt;
What are Benefits of wrapping database calls into MTS transactions?&lt;br /&gt;
If database calls are made within the context of a transaction, aborting the transaction will undo and changes that occur within that transaction. This removes the possibility of stranded or partial data. Transaction that uses the Microsoft® Transaction Server (MTS) environment. MSMQ implicitly uses the current MTS transaction if one is available. &lt;br /&gt;
&lt;br /&gt;
BENIFTIS OF USING MTS: &lt;br /&gt;
Database Pooling, Transactional operations, Deployment, Security, and Remote Execution This allows MTS to reuse database connections. Database connections are put to sleep. As opposed to being created and destroyed and are activated upon request.&lt;br /&gt;
&lt;br /&gt;
Can database schema be changed with DAO/ADO/RDO?&lt;br /&gt;
A database schema describes the current structure of the tables and database views in the database. In general, ClassWizard assumes that the schema for the table(s) accessed by a recordset will not change, but the database classes can deal with some schema changes, such as adding, reordering, or deleting unbound columns. If a table changes, you can “refresh” your recordset for the table using ClassWizard’s Update Columns button and then recompile your application.&lt;br /&gt;
&lt;br /&gt;
Can you create a table-type of recordset in Jet connected ODBC database engine?&lt;br /&gt;
You can create a table-type CdbRecordset object from a base table of a Microsoft Jet database, but not from an ODBC or linked table. You can use the table-type CdbRecordset object with ISAM databases (like Microsoft Visual FoxPro, dBASE, or Paradox) when you open them directly.&lt;br /&gt;
&lt;br /&gt;
How to register a component? &lt;br /&gt;
Compiling the component, running REGSVR32 MyDLL.dll&lt;br /&gt;
&lt;br /&gt;
Controls which do not have events?&lt;br /&gt;
Shape and line controls are useful for drawing graphical elements on &lt;br /&gt;
the surface of a form. These controls don&#39;t support any events; they &lt;br /&gt;
are strictly for decorative purposes. &lt;br /&gt;
EXTRA INFO: &lt;br /&gt;
The image, shape and line controls are considered to be lightweight controls; that is, they support only a subset of the properties, methods, and events found in the picture box. Because of this, they typically require less system resources and load faster than the picture box control.&lt;br /&gt;
&lt;br /&gt;
What are the Control Categories&lt;br /&gt;
a)Intrinsic controls:&lt;br /&gt;
such as the command button and frame controls. These controls are contained inside the Visual Basic .exe file. Intrinsic controls are always included in the toolbox&lt;br /&gt;
&lt;br /&gt;
b)ActiveX controls:&lt;br /&gt;
which exist as separate files with a .ocx file name extension. These include controls that are available in all editions of Visual Basic (DataCombo, DataList controls, and so on) and those that are available only in the Professional and Enterprise editions (such as Listview, Toolbar, Animation, and Tabbed Dialog). Many third-party ActiveX controls are also available.&lt;br /&gt;
&lt;br /&gt;
c)Insertable Objects:&lt;br /&gt;
such as a Microsoft Excel Worksheet object containing a list of all your company&#39;s employees, or a Microsoft Project Calendar object containing the scheduling information for a project. Since these can&lt;br /&gt;
be added to the toolbox, they can be considered controls. Some of these objects also support Automation (formerly called OLE Automation),which allows you to program another application&#39;s objects from within a Visual Basic application.&lt;br /&gt;
&lt;br /&gt;
DIFF between Image and Picture box controls?&lt;br /&gt;
The sizing behavior of the image control differs from that of the picture box. Image box has a Stretch property while the picture box has an AutoSize property. Setting the AutoSize property to True causes a picture box to resize to the dimensions of the picture; setting it to False causes the picture to be cropped (only a portion of the picture is visible). When set to False (the default), the Stretch property of the image control causes it to resize to the dimensions of the picture. Setting the Stretch property to True causes the picture to resize to the size of the image control, this may cause the picture to appear distorted. &lt;br /&gt;
&lt;br /&gt;
Default property of datacontrol?&lt;br /&gt;
connect property......&lt;br /&gt;
&lt;br /&gt;
Define the scope of Public, Private, Friend procedures? &lt;br /&gt;
The set of public variables, methods, properties, and events described in a class module define the interface for an object. The interface consists of the object members that are available to a programmer who&#39;s using the object from code.&lt;br /&gt;
&lt;br /&gt;
You can create private variables, methods, properties, and events that are used by other procedures within the class module but are not part of the object&#39;s public interface. Additionally, constants user-defined types, and Declare statements within a class module must always be private.&lt;br /&gt;
&lt;br /&gt;
The Friend keyword makes a procedure private to the project: The procedure is available to any code running within the project, but it is not available to a referencing project. &lt;br /&gt;
&lt;br /&gt;
Describe Database Connection pooling relative to MTS ? &lt;br /&gt;
This allows MTS to reuse database connections. Database connections are put to ?sleep? as opposed to being created and destroyed and are activated upon request.&lt;br /&gt;
&lt;br /&gt;
Object pooling is an important design concept required for high-performance applications. A performance optimization based on using collections of preallocated resources, such as objects or database connections. Pooling results in more efficient resource allocation.&lt;br /&gt;
&lt;br /&gt;
Difference between a function and a subroutine ? &lt;br /&gt;
A function accepts any number of parameters (possibly zero), does something with them, and returns a value.&lt;br /&gt;
A subroutine performs an action, but doesn&#39;t return a value. &lt;br /&gt;
&lt;br /&gt;
There are two differences between a function and a subroutine: &lt;br /&gt;
A)How they are invoked. B)How they are accessed.&lt;br /&gt;
&lt;br /&gt;
A function call has the following syntax ::&lt;br /&gt;
function(arg1, arg2, ...) &lt;br /&gt;
where: function Is the name of the function. arg1, arg2, ... Are the arguments. &lt;br /&gt;
&lt;br /&gt;
A subroutine call has the following syntax &lt;br /&gt;
::subroutine (arg1, arg2, ... {outputfield|&#39;format&#39;})&lt;br /&gt;
where: subroutine --&gt;Is the name of the subroutine. arg1, arg2, ... Are the arguments. {outputfield|&#39;format&#39;} Is the name of the output field or its format. &lt;br /&gt;
&lt;br /&gt;
In addition, on some platforms, the functions are available immediately; whereas, the subroutines are available in a special subroutine library that you must access. &lt;br /&gt;
&lt;br /&gt;
Difference between Linked Object and Embedded Object?&lt;br /&gt;
Embedding objects - &lt;br /&gt;
When you embed an object, a copy of the object is inserted into the destination document. There&#39;s no link to the original file. When you change information in the source document, no changes will be reflected in the destination document. The actual data for the object is stored within the destination file. To make changes to the embedded object, double click it and it will launch the original application the source file was in. &lt;br /&gt;
Linking objects - &lt;br /&gt;
Information is updated when you modify the original source file when you use a linked object. This dynamic updating is very handy for things such as the aforementioned monthly report. You can open up the Excel spreadsheet that is referenced within your Word document. Make changes to the spreadsheet, close Excel, and when you open your Word document... viola! The changes are already there. If that object is linked to ten other Word files, the changes are already in those ten files, too! actually linking or embedding an object is fast and easy.&lt;br /&gt;
&lt;br /&gt;
Difference between listbox and combo box?&lt;br /&gt;
A LISTBOX CONTROL displays a list of items from which the user can select one or more. If the number of items exceeds the number that can be displayed, a scroll bar is automatically added to the ListBox control. A COMBOX CONTROL combines the features of a text box and a list box. This control allows the user to select an item either by typing text into the combo box, or by selecting it from the list. &lt;br /&gt;
DIFF:: Generally, a combo box is appropriate when there is a list of suggested choices, and a list box is appropriate when you want to limit input to what is on the list. A combo box contains an edit field, so choices not on the list can be typed in this field.&lt;br /&gt;
&lt;br /&gt;
Difference between Dynaset and Snapshot?&lt;br /&gt;
All Recordset objects are constructed using records (rows) and fields (columns). There are five types of Recordset objects: &lt;br /&gt;
&lt;br /&gt;
Table-type Recordset ::&lt;br /&gt;
representation in code of a base table that you can use to add, change, or delete records from a single database table (Microsoft Jet workspaces only). &lt;br /&gt;
&lt;br /&gt;
Dynaset-type Recordset ::&lt;br /&gt;
the result of a query that can have updatable records. A dynaset-type Recordset object is a dynamic set of records that you can use to add, change, or delete records from an underlying database table or tables. A dynaset-type Recordset object can contain fields from one or more tables in a database. This type corresponds to an ODBC keyset cursor.&lt;br /&gt;
&lt;br /&gt;
Snapshot-type Recordset ::&lt;br /&gt;
a static copy of a set of records that you can use to find data or generate reports. A snapshot-type Recordset object can contain fields from one or more tables in a database but can&#39;t be updated. This type corresponds to an ODBC static cursor. &lt;br /&gt;
&lt;br /&gt;
Forward-only-type Recordset::&lt;br /&gt;
identical to a snapshot except that no cursor is provided. You can only scroll forward through records. This improves performance in situations where you only need to make a single pass through a result set. This type corresponds to an ODBC forward-only cursor.&lt;br /&gt;
&lt;br /&gt;
Dynamic-type Recordset ::&lt;br /&gt;
a query result set from one or more base tables in which you can add, change, or delete records from a row-returning query. Further, records other users add, delete, or edit in the base tables also appear in your Recordset. This type corresponds to an ODBC dynamic cursor (ODBCDirect workspaces only). &lt;br /&gt;
&lt;br /&gt;
Difference Listindex and Tab index?&lt;br /&gt;
LIST INDEX::&lt;br /&gt;
Returns or sets the index of the currently selected item in the control. Not available at design time.Default LIST INDEX IS -1 for ComboBox, DirListBox, and DriveListBox controls&lt;br /&gt;
TAB INDEX::&lt;br /&gt;
Returns or sets the tab order of most objects within their parent form. Visual Basic automatically renumbers the TabIndex of other controls to reflect insertions and deletions. You can make changes at design time using the Properties window or at run time in code. The TabIndex property isn&#39;t affected by the ZOrder method.&lt;br /&gt;
&lt;br /&gt;
Difference modal and modeless window?&lt;br /&gt;
MODAL forms are forms which require user input before any other actions can be taken place. In other words, a modal form has exclusive focus in that application until it is dismissed. When showing a modal form, the&lt;br /&gt;
controls outside this modal form will not take user interaction until the form is closed. The internal MsgBox and InputBox forms are examples of modal forms. To show a form modally, use the syntax: &lt;br /&gt;
MyForm.SHOW.vbModal &#39; a predeclared constant for 1 &lt;br /&gt;
MODELESS forms are those which are shown but do not require immediate user input. MDI child forms are always modeless. To show a form modeless, use the syntax:: MyForm.SHOW&lt;br /&gt;
&lt;br /&gt;
Difference Object and Class?&lt;br /&gt;
Classes and objects are separate but related concepts. Every object belongs to a class and every class contains one or more related objects.&lt;br /&gt;
1)A Class is static. All of the attributes of a class are fixed before, during, and after the execution of a program. The attributes of a class don&#39;t change. The class to which an object belongs is also (usually) static. If a particular object belongs to a certain class at the time that it is created then it almost certainly will still belong to that class right up until the time that it is destroyed.&lt;br /&gt;
2)An Object on the other hand has a limited lifespan. Objects are created and eventually destroyed. Also during that lifetime, the attributes of the object may undergo significant change. So basically the difference between a class and an object is that a class is a general concept while objects are the specific and real instances that embody that concept. When creating an object oriented program we define the classes and the relationships between the classes . We then execute the program to create, update, and destroy the objects which are the specific realization of these classes.&lt;br /&gt;
&lt;br /&gt;
Difference Query unload and unload in form?&lt;br /&gt;
Occurs before a form or application closes. When an MDIForm object closes, the QueryUnload event occurs first for the MDI form and then in all MDI child forms. If no form cancels the QueryUnload event, the Unload event occurs first in all other forms and then in an MDI form. When a child form or a Form object closes, the QueryUnload event in that form occurs before the form&#39;s Unload event.&lt;br /&gt;
&lt;br /&gt;
Difference Declaration and Instantiation an object?&lt;br /&gt;
Dim obj as OBJ.CLASS with either&lt;br /&gt;
Set obj = New OBJ.CLASS or&lt;br /&gt;
Set obj = CreateObject(?OBJ.CLASS?) or&lt;br /&gt;
Set obj = GetObject( ,? OBJ.CLASS?)&lt;br /&gt;
or&lt;br /&gt;
Dim obj as New OBJ.CLASS&lt;br /&gt;
&lt;br /&gt;
Set object = Nothing &lt;br /&gt;
ensure the object is release from the memory.&lt;br /&gt;
&lt;br /&gt;
If this object is a form, you can add set myform = nothing and Form_Unload() event.Maintain a habit of remove the object by using set object = nothing which will benefit at last. &lt;br /&gt;
Visual Basic is supposed to automatically release objects when they go out of scope. To free up some memory usage, you can set the object to nothing. &lt;br /&gt;
&lt;br /&gt;
Draw and explain Sequence Modal of DAO &lt;br /&gt;
Connection,Container,Database,DBEngine,Document,Error,Field,Group,Index&lt;br /&gt;
Parameter Property,QueryDef,Recordset,Relation,TableDef,User,Workspace&lt;br /&gt;
&lt;br /&gt;
Version Year Significant Changes and New Features of Visual Basic&lt;br /&gt;
1 1991  initial release, with drag and drop GUI creation&lt;br /&gt;
2 1992 ODBC, object variables&lt;br /&gt;
3 1993 Access Engine, OLE 2.0, Crystal Reports, new tools and controls&lt;br /&gt;
4 1995 classes, OCXs&lt;br /&gt;
5 1997 compiler, ActiveX controls&lt;br /&gt;
6 1998 web support, windowless controls, designers, data sources&lt;br /&gt;
.NET 2001 XML, SOAP, inheritance, structured exception handling&lt;br /&gt;
&lt;br /&gt;
How can objects on different threads communicate with one another? &lt;br /&gt;
Processes communicate with one another through messages, using Microsoft&#39;s Remote Procedure Call (RPC) technology to pass information to one another. There is no difference to the caller between a call coming from a process on a remote machine and a call coming from another process on the same machine.&lt;br /&gt;
&lt;br /&gt;
Multithreaded applications must avoid two threading problems: deadlocks and races. A deadlock occurs when each thread is waiting for the other to do something &lt;br /&gt;
&lt;br /&gt;
How can you force new objects to be created on new threads? &lt;br /&gt;
The CreateThread function creates a thread to execute within the virtual address space of the calling process.&lt;br /&gt;
&lt;br /&gt;
To create a thread that runs in the virtual address space of another process Creating a new thread is as easy as declaring it and supplying it with a delegate to the method where the thread is to start. When you are ready to begin execution on the thread, call the Thread.Start Method. There are special considerations involved when working with multiple threads of execution. &lt;br /&gt;
&lt;br /&gt;
To create a new thread of execution &lt;br /&gt;
====================================&lt;br /&gt;
Declare the thread. &lt;br /&gt;
******************&lt;br /&gt;
&#39; Visual Basic&lt;br /&gt;
Dim myThread as System.Threading.Thread&lt;br /&gt;
&lt;br /&gt;
// C#&lt;br /&gt;
System.Threading.Thread myThread;&lt;br /&gt;
&lt;br /&gt;
Instantiate the thread with the appropriate delegate for the starting point of the thread. Use the AddressOf operator to create the delegate &lt;br /&gt;
in Visual Basic, or create a new ThreadStart object in C#.&lt;br /&gt;
******************* &lt;br /&gt;
&#39; Visual Basic&lt;br /&gt;
myThread = New System.Threading.Thread(AddressOf&lt;br /&gt;
myStartingMethod)&lt;br /&gt;
&lt;br /&gt;
// C#&lt;br /&gt;
myThread = new System.Threading.Thread(new &lt;br /&gt;
System.Threading.ThreadStart(myStartingMethod));&lt;br /&gt;
&lt;br /&gt;
call the Thread.Start method to start the thread. &lt;br /&gt;
*******************&lt;br /&gt;
&#39; Visual Basic&lt;br /&gt;
myThread.Start()&lt;br /&gt;
&lt;br /&gt;
// C#&lt;br /&gt;
myThread.Start();&lt;br /&gt;
&lt;br /&gt;
How does a DCOM component know where to instantiate itself? &lt;br /&gt;
To create a remote instance of a script component, call the CreateObject method, passing it the name of the remote computer as a parameter. If the remotable attribute of a script component&#39;s &lt;registration&gt; element has been set to &quot;true,&quot; the script component can be instantiated remotely from another computer using Distributed COM (DCOM). &lt;br /&gt;
Both computers must have basic DCOM installed. Note The ability to use CreateObject for instantiating remote script components requires Visual Basic 6.0 or later or VBScript 5.0 or later. The following Visual Basic example shows how to do this on a computer named &quot;myserver&quot;:&lt;br /&gt;
&lt;br /&gt;
Set newS = CreateObject(&quot;Component.MyComponent&quot;, &quot;myserver&quot;)&lt;br /&gt;
Note There can be a slight delay when you first instantiate a remote script component while DCOM establishes communication between the computers.&lt;br /&gt;
&lt;br /&gt;
1. You can specify the machine on which you want to create the remote server object in DCOM config (&#39;dcomcnfg&#39;).&lt;br /&gt;
&lt;br /&gt;
2. You can specify the machine name when instantiating the remote server object. &lt;br /&gt;
In C you can do this with a call to CoGetClassObject or CoCreateInstanceEx (instead of CoCreateInstance, which does not allow you to specify the name of the machine).&lt;br /&gt;
In VB you can specify the name in one of the parameters in the call to CreateObject &lt;br /&gt;
&lt;br /&gt;
What type of multi-threading does VB6 implement? &lt;br /&gt;
Apartment model threading&lt;br /&gt;
&lt;br /&gt;
What is Database Connection pooling (relative to MTS)&lt;br /&gt;
This allows MTS to reuse database connections. Database connections are&lt;br /&gt;
put to &quot;sleep&quot; As opposed to being created and destroyed and are activated upon request. &lt;br /&gt;
&lt;br /&gt;
What is the tool used to configure the port range and protocols for DCOM communications? &lt;br /&gt;
DCOMCONFIG.EXE&lt;br /&gt;
&lt;br /&gt;
What is a Type Library and what is its purpose ? &lt;br /&gt;
The type library may represent another Visual Basic project, or any other executable component that exposes a type library.&lt;br /&gt;
Visual Basic creates type library information for the classes you create, provides type libraries for the objects it includes, and lets you access the type libraries provided by other applications.&lt;br /&gt;
&lt;br /&gt;
What are binary and project compatibility? &lt;br /&gt;
Visual Basic’s Version Compatibility feature is a way of enhancing your components while maintaining backward compatibility with programs that were compiled using earlier versions. The Version Compatibility box, located on the Component tab of the Project Properties dialog box, contains three options: &lt;br /&gt;
No Compatibility: &lt;br /&gt;
Each time you compile the component, new type library information is generated, including new class IDs and new interface IDs. There is no relation between versions of a component, and programs compiled to use one version cannot use subsequent versions.&lt;br /&gt;
Project Compatibility:&lt;br /&gt;
Each time you compile the component the type library identifier is kept, so that your test projects can maintain their references to the component project. All class IDs from the previous version are maintained; interface IDs are changed only for classes that are no longer binary-compatible with their earlier counterparts. Note This is a change in Project Compatibility from Visual Basic 5.0, where all class IDs and interface IDs in the project changed if any one class was no longer binary-compatible.&lt;br /&gt;
&lt;br /&gt;
Important For the purpose of releasing compatible versions of a component, Project Compatibility is the same as No Compatibility.&lt;br /&gt;
Binary Compatibility:&lt;br /&gt;
When you compile the project, if any binary-incompatible changes are detected you will be presented with a warning dialog. If you choose to accept the warning, the component will retain the type library identifier and the class IDs. Interface IDs are changed only for classes that are no longer binary-compatible. This is the same behavior as Project Compatibility. &lt;br /&gt;
If, however, you choose to ignore the warning, the component will also maintain the interface IDs. This option is only available when the compiler determines that the change was in the procedure ID or signature of a method.&lt;br /&gt;
&lt;br /&gt;
Note:: When people talk about Version Compatibility, they’re usually referring to Binary Compatibility.&lt;br /&gt;
&lt;br /&gt;
How to set a shortcut key for label?&lt;br /&gt;
object.KeyLabel(keycode) [= string]&lt;br /&gt;
You would probably create the menu item as follows:&lt;br /&gt;
.Add &quot;keyFile&quot;, , , &quot;E&amp;xit&quot;, , vbAltMask + vbCtrlMask, vbKeyEnd&lt;br /&gt;
The default key label for vbKeyEnd is &quot;End&quot;. Thus, the shortcut string will be created by default as &quot;Ctrl+Alt+End&quot;.&lt;br /&gt;
&lt;br /&gt;
Name the four different cursor and locking types in ADO and describe them briefly ?&lt;br /&gt;
CURSORS::&lt;br /&gt;
*********&lt;br /&gt;
The cursor types are listed from least to most resource intensive. &lt;br /&gt;
Forward Only - Fastest, can only move forward in recordset &lt;br /&gt;
Static - Can move to any record in the recordset. Data is static and never changes.&lt;br /&gt;
KeySet - Changes are detectable, records that are deleted by other users are unavailable, and records created by other users are not detected Dynamic - All changes are visible.&lt;br /&gt;
LOCKING TYPES::&lt;br /&gt;
****************&lt;br /&gt;
LockPessimistic - Locks the row once after any edits occur.&lt;br /&gt;
LockOptimistic - Locks the row only when Update is called.&lt;br /&gt;
LockBatchOptimistic - Allows Batch Updates.&lt;br /&gt;
LockReadOnly - Read only. Cannot alter the data.&lt;br /&gt;
&lt;br /&gt;
Name the different compatibility types when creating a COM component.&lt;br /&gt;
No Compatibility - New GUID (Globally Unique Identifier) created, references from other components will not work Project Compatibility - Default for a new component &lt;Not as critical to mention this one&gt;&lt;br /&gt;
Binary Compatibility - GUID does not change references from other components will work&lt;br /&gt;
&lt;br /&gt;
Why is it important to use source control software for source code?&lt;br /&gt;
Modification history. Code ownership: Multiple people cannot modify the same code at the same time.&lt;br /&gt;
&lt;br /&gt;
List the ADO objects? &lt;br /&gt;
Connection - Connects to a data source; contains the Errors collection&lt;br /&gt;
Command - Executes commands to the data source. The only object that can accept parameters for a stored procedure Recordset - The set of data returned from the database. &lt;br /&gt;
Under the ADO Command Object, The Parameters collection. collection is responsible for input to stored procedures.&lt;br /&gt;
&lt;br /&gt;
What two methods are called from the ObjectContext object to inform MTS that the transaction was successful or unsuccessful?&lt;br /&gt;
SetComplete and SetAbort.&lt;br /&gt;
&lt;br /&gt;
What is the benefit of wrapping database calls into MTS transactions?&lt;br /&gt;
Aborting the transaction will undo and changes that occur within that transaction. This removes the possibility of stranded, or partial data&lt;br /&gt;
&lt;br /&gt;
Describe and In Process vs. Out of Process component. Which is faster? &lt;br /&gt;
An in-process component is implemented as a DLL, and runs in the same process space as its client app, enabling the most efficient communication between client and component. Each client app that uses the component starts a new instance of it.&lt;br /&gt;
An out of process component is implemented as an EXE, and unlike a dll, runs in its own process space. As a result, exe&#39;s are slower then dll&#39;s because communications between client and component must be marshaled across process boundaries. A single instance of an out of process component can service many clients.&lt;br /&gt;
&lt;br /&gt;
How would you declare and raise custom events in a class?&lt;br /&gt;
a) Public Event OnVarChange(); &lt;br /&gt;
b) RaiseEvent OnVarChange[(arg1, arg2, ... , argn)]&lt;br /&gt;
&lt;br /&gt;
What is the difference between a Property Let and Property Set procedure?&lt;br /&gt;
Let - for simple variable&lt;br /&gt;
Set - for object&lt;br /&gt;
&lt;br /&gt;
What is the difference between ANSI and UNICODE strings when passed as arguments to a DLL?&lt;br /&gt;
ANSI - one byte for a char UNICODE - two bytes per char - works only on NT&lt;br /&gt;
&lt;br /&gt;
What is the difference in passing values ByRef or ByVal to a procedure?&lt;br /&gt;
ByRef -pass the address (for string -address of address of first byte)&lt;br /&gt;
BY REF IS VERY USEFULL When the contents itself are being modified, when there is large data. Multiple arguments are needed to be returned, instead they can be passed as reference.&lt;br /&gt;
ByVal -pass the value (for string -it is the address of first byte)&lt;br /&gt;
&lt;br /&gt;
What is the purpose of the DoEvents command?&lt;br /&gt;
Fields execution so that the operating system can process other events. Returns number of open forms. Useful for things like ‘cancel search’ in Windows &lt;br /&gt;
&lt;br /&gt;
Name and define the logical tiers in a traditional 3-tiered architecture?&lt;br /&gt;
Presentation logic - front end (HTML, Visual Basic forms)&lt;br /&gt;
Business Logic - Applications and components that encapsulate business logic&lt;br /&gt;
Data end - databases to store data&lt;br /&gt;
&lt;br /&gt;
What is the difference between a PictureBox and Image control?&lt;br /&gt;
Image Control - Use this to display a picture. Use it over the PictureBox because it takes less operating system resources&lt;br /&gt;
PictureBox - While it can display pictures, it also acts as an area on which you can print text and graphics. Use it for home-grown graphics or print previews&lt;br /&gt;
&lt;br /&gt;
Under which circumstance does a VB application ignore a Timer event?&lt;br /&gt;
When the system is really busy doing something else and when DoEvents is being executed &lt;br /&gt;
&lt;br /&gt;
What does the NewIndex property return?&lt;br /&gt;
Used to retrieve the index of the item most recently added to a ListBox or ComboBox control&lt;br /&gt;
&lt;br /&gt;
What is the purpose of the ClipControls property on a form or container?&lt;br /&gt;
Returns or sets a value that determines whether graphics methods in Paint events repaint the entire object or only newly exposed areas. Also determines whether the Microsoft Windows operating environment creates a clipping region that excludes non-graphical controls contained by the object. Read-only at run time.&lt;br /&gt;
&lt;br /&gt;
What is the purpose of the AutoRedraw property on a form or container?&lt;br /&gt;
Setting AutoRedraw to True automatically redraws the output from these methods in a Form object or PictureBox control when, for example, the object is resized or redisplayed after being hidden by another object&lt;br /&gt;
&lt;br /&gt;
Have you ever used Collections? Collection Classes?&lt;br /&gt;
A collection is a set of Repository objects that are all connected to a common source object via a relationship collection. A collection provides a way to connect a group of dependent objects with an object that ‘contains’ them. For example, an Invoice object might have a collection of LineItem objects.&lt;br /&gt;
&lt;br /&gt;
What version control systems have you used?&lt;br /&gt;
TLIB 16-Bit add-in&lt;br /&gt;
&lt;br /&gt;
How about any other database engines?&lt;br /&gt;
Apollo OLE DB ,Apollo Server ,Apollo SQL ,FUNCky ,R&amp;R Report Writer &lt;br /&gt;
&lt;br /&gt;
What kind of components can you use as DCOM servers? &lt;br /&gt;
active-x components, Com&lt;br /&gt;
Dim x, y as integer. &lt;br /&gt;
What is x and y data type?&lt;br /&gt;
X as variant and y as integer. &lt;br /&gt;
&lt;br /&gt;
What is the size of the variant data type?&lt;br /&gt;
The Variant data type has a numeric storage size of 16 bytes and can contain data up to the range of a Decimal, or a character storage size of 22 bytes (plus string length), and can store any character text. &lt;br /&gt;
&lt;br /&gt;
What is the return type of Instr and Strcmp?&lt;br /&gt;
Instr – integer (Numeric position)&lt;br /&gt;
Strcmp - integer ( if both the string are equal they result = 0)&lt;br /&gt;
Strcmp (Str1, Str2, Comparetype)&lt;br /&gt;
Comparing mode = 0 – Binary Comparing &lt;br /&gt;
1 – Textual Comparing&lt;br /&gt;
&lt;br /&gt;
What is the max size allowed for Msgbox Prompt and Input Box?&lt;br /&gt;
1024 &lt;br /&gt;
&lt;br /&gt;
Max label caption length. – &lt;br /&gt;
2,048 &lt;br /&gt;
&lt;br /&gt;
Max Text box length – &lt;br /&gt;
32,000 &lt;br /&gt;
&lt;br /&gt;
Max Control Names length – &lt;br /&gt;
255. &lt;br /&gt;
&lt;br /&gt;
Extension in Visual Basic&lt;br /&gt;
Frm, bas, cls, res, vbx, ocx, frx, vbp, exe &lt;br /&gt;
&lt;br /&gt;
What is frx?&lt;br /&gt;
When some controls like grid and third party control placed in our application then it will create frx in run time. &lt;br /&gt;
&lt;br /&gt;
Name some date function&lt;br /&gt;
Dateadd(), Datediff(), Datepart(), Cdate() &lt;br /&gt;
&lt;br /&gt;
What will be the result for 15/4 and 15\4 &lt;br /&gt;
15/4 = 3.75 and 15\4 = 3 &lt;br /&gt;
&lt;br /&gt;
What is keyword used to compare to objects? &lt;br /&gt;
ISOperator – Returns Boolean. &lt;br /&gt;
&lt;br /&gt;
How many procedures are in VB?&lt;br /&gt;
2. function and sub procedures. Function Will return value but a sub procedure won’t return values…&lt;br /&gt;
&lt;br /&gt;
Where will we give the option explicit keyword and for what? &lt;br /&gt;
In the general declarations section. To trap undeclared variables.&lt;br /&gt;
&lt;br /&gt;
What is Friend Variable?&lt;br /&gt;
Scope sharable between projects.&lt;br /&gt;
&lt;br /&gt;
What is binding? What are types of binding?&lt;br /&gt;
Assigning variable with defined memory space. Late Binding - Memory size is allotted in later stage.&lt;br /&gt;
Ex:- Dim x as object &lt;br /&gt;
Early Binding - Memory size is allotted while declaring itself. New Key word is important.&lt;br /&gt;
Ex:- Dim x as New Object &lt;br /&gt;
&lt;br /&gt;
What is the difference between Property Get, Set and Let.&lt;br /&gt;
Set – Value is assigned to ActiveX Object from the form.&lt;br /&gt;
Let – Value is retried to ActiveX Object from the form. &lt;br /&gt;
Get- Assigns the value of an expression to a variable or property.&lt;br /&gt;
&lt;br /&gt;
What is Mask Edit and why it is used?&lt;br /&gt;
Control. Restricted data input as well as formatted data output.&lt;br /&gt;
&lt;br /&gt;
Drag and Drop state numbers and functions.&lt;br /&gt;
State 0 – Source control is being dragged with the range of a target.&lt;br /&gt;
State 1 – Out of the range of a target.&lt;br /&gt;
State 2 – One position in the target to another.&lt;br /&gt;
&lt;br /&gt;
What are the type of validation available in VB?&lt;br /&gt;
Field, Form&lt;br /&gt;
&lt;br /&gt;
With in the form we want to check all the text box control are typed or not? How?&lt;br /&gt;
For each currentcontrol in controls if typeof currentcontrol is TextBox then end if next&lt;br /&gt;
&lt;br /&gt;
What is control array and How many we can have it with in the form?&lt;br /&gt;
Group of control share the same name. Max 32, 767.&lt;br /&gt;
&lt;br /&gt;
What is the default model of the form? And what is it number? &lt;br /&gt;
VbModaless – 0 (Zero) – We can able to place another window above this form.&lt;br /&gt;
&lt;br /&gt;
Suppose from form1 to form2 object property settings will arise to ? &lt;br /&gt;
Invalid procedure call or argument (Run time error – 5)&lt;br /&gt;
&lt;br /&gt;
What is the diff between the Std and Class Module?&lt;br /&gt;
Std Global with in the project. Cls Global through out the all project only thing is we want to set the type lib. Class Modules can be Instantiated.&lt;br /&gt;
&lt;br /&gt;
Different type of Instantiation?&lt;br /&gt;
Private – Only for the Specific Module.&lt;br /&gt;
Public not creatable – Private &amp; Public&lt;br /&gt;
Multi Use - Variable we have to declare.&lt;br /&gt;
Single Use – Not possible through dll.&lt;br /&gt;
Global Multiuse – Have variable not Required to &lt;br /&gt;
Declare. Global Single Use - Only for exe. &lt;br /&gt;
&lt;br /&gt;
How to declare Dll Procedure?&lt;br /&gt;
Declare function &quot;&lt;Function Name&gt;&quot; lib &quot;&lt;Lib Name&gt;&quot; Alias &quot;&lt;Alias Name&gt;&quot; (Arg, …..) as Return type.&lt;br /&gt;
&lt;br /&gt;
What is MDI form? MDI Styles?&lt;br /&gt;
We can have only one MDI form for a project. Multiple Document Interface. This form type is VBModal. We have set the Child property of the forms to True to place forms inside this MDI. Styles available &lt;br /&gt;
1. VbCascade &lt;br /&gt;
2. VbTitle Horizontal&lt;br /&gt;
&lt;br /&gt;
How many images can be placed in the image list ?&lt;br /&gt;
64&lt;br /&gt;
&lt;br /&gt;
Diff type of Datatypes?&lt;br /&gt;
LOB (Large Object Data type).&lt;br /&gt;
CLOB (Stores Character Objects).&lt;br /&gt;
BLOB ( Store Binary Objects such as Graphic, Video Chips and Sound files).&lt;br /&gt;
BFILE(Store file pointers to LOB It may Contain filename for photo’s store on CD_ROM).&lt;br /&gt;
&lt;br /&gt;
What is Zorder Method?&lt;br /&gt;
Object.Zorder = 1 or 0 Place a Specified mdiform form or control at the front or back of the z-order with n it’s Graphical Level.&lt;br /&gt;
&lt;br /&gt;
What is diff between the Generic Variable and Specific Variable?&lt;br /&gt;
Generic Variable: Create Object Ex:-Ole-Automation . No need refer the object library.&lt;br /&gt;
Specific Variable: Binding Procedure Early and Late Binding ( Can be Remove from the Memory).&lt;br /&gt;
&lt;br /&gt;
What are properties available in Clip Board?&lt;br /&gt;
No Properties Available. Only the methods they are SetText, GetText, Setdata(), Getformat(), Clear.&lt;br /&gt;
&lt;br /&gt;
What is Dll?&lt;br /&gt;
Libraries of procedure external to the application but can be called from the application.&lt;br /&gt;
&lt;br /&gt;
What is Tabstrip control? What is the starting Index value? How to locate it?&lt;br /&gt;
It is tab control to place our controls with in the form in multiple sheets.&lt;br /&gt;
Index starts with 1. And to identify&lt;br /&gt;
If Tabstrip1.SelectedItem.Index = 1 Then&lt;br /&gt;
…..&lt;br /&gt;
End if&lt;br /&gt;
&lt;br /&gt;
Why we use Treeview Control?&lt;br /&gt;
To list the hierarchical list of the node objects. Such of files and Directories.&lt;br /&gt;
&lt;br /&gt;
Why we need OLE-Automation? Advantages?&lt;br /&gt;
Enables an application to exposes objects and methods to other Applications.&lt;br /&gt;
No need to reserve memory. No need to write functions.&lt;br /&gt;
Object library that simplify programming tasks. i.e., No need to Object library. (OLB, TLB).&lt;br /&gt;
&lt;br /&gt;
What is the diff between the Create Object and Get object?&lt;br /&gt;
Create Object - To create an instance of an object.&lt;br /&gt;
Get Object – To get the reference to an existing object.&lt;br /&gt;
&lt;br /&gt;
Have you create Properties and Methods for your own Controls?&lt;br /&gt;
Properties – Public variable of a Class&lt;br /&gt;
Method – Public procedure of a class&lt;br /&gt;
&lt;br /&gt;
What is Collection Objects?&lt;br /&gt;
Similarly to arrays but is preferred over an array because of the following reasons.&lt;br /&gt;
1. A collection objects uses less Memory than an array.&lt;br /&gt;
2. It provides methods to add and delete members.&lt;br /&gt;
3. It does not required reason statement when objects are added or deleted.&lt;br /&gt;
4. It does not have boundary limitations.&lt;br /&gt;
&lt;br /&gt;
What is Static Variable?&lt;br /&gt;
Its Scope will be available through out the life time.&lt;br /&gt;
&lt;br /&gt;
Private Dim x as integer. Is it true?&lt;br /&gt;
No. Private cannot be used in front of DIM.&lt;br /&gt;
&lt;br /&gt;
What is Implicit?&lt;br /&gt;
Instance of specific copy of a class with its own settings for the properties defined in that class. Note: The implicit defined variable is never equal to nothing. &lt;br /&gt;
&lt;br /&gt;
What are the scope of the class?&lt;br /&gt;
Public , private, Friend&lt;br /&gt;
&lt;br /&gt;
Can we set the Instancing properties like Singleuse, GlobalSingleuse to ActiveXDll?&lt;br /&gt;
No. &lt;br /&gt;
&lt;br /&gt;
In project properties if we set Unattended what is it mean?&lt;br /&gt;
This cannot have user interface. This can be used for the COM creation.&lt;br /&gt;
&lt;br /&gt;
What are the Style Properties of Combo Box?&lt;br /&gt;
Simple, Dropdown list – We can type and select.&lt;br /&gt;
Dropdown Combo – Only Drop Down.&lt;br /&gt;
&lt;br /&gt;
What are the Style properties of List Box?&lt;br /&gt;
Simple –Single Select , Extended. – Multiple Select.&lt;br /&gt;
&lt;br /&gt;
What are the different types of Dialog Box?&lt;br /&gt;
Predefined, Custom, User Defined.&lt;br /&gt;
&lt;br /&gt;
What is Parser Bug?&lt;br /&gt;
It is difficult to use database objects declared in a module from within a form.&lt;br /&gt;
&lt;br /&gt;
What is the Dll required for running the VB?&lt;br /&gt;
Vbrun300.dll&lt;br /&gt;
&lt;br /&gt;
Can We create CGI scripts in VB?&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
How to change the Mouse Pointer?&lt;br /&gt;
Screen.MousePointer = VBHourGlass/VBNormal.&lt;br /&gt;
&lt;br /&gt;
How to check the condition in Msgbox?&lt;br /&gt;
If(Msgbox(&quot;Do you want to delete this Record&quot;,VbYesNo)=VbYes)Then End if&lt;br /&gt;
&lt;br /&gt;
What is difference between datagrid and flexgrid?&lt;br /&gt;
Datagrid – Editable.&lt;br /&gt;
Flexigrid – Non-Editable. (Generally used for Read only purpose.) &lt;br /&gt;
&lt;br /&gt;
What is ADO? What are its objects ?&lt;br /&gt;
ActiveX Data Object. ADO can access data from both flat files as well as the databases. I.e., It is encapsulation of DAO, RDO, and OLE that is why we call it as OLE-DB Technology. Objects are Connection, Record Set, Command, Parameter, field, Error, Property. &lt;br /&gt;
&lt;br /&gt;
What is Dataware Control?&lt;br /&gt;
Any control bound to Data Control.&lt;br /&gt;
Ex:- Textbox, Check Box, Picture Box, Image Control, Label, List box, Combo Box, DB Combo, &lt;br /&gt;
What are two validate with Data Control?&lt;br /&gt;
Data_Validate, Data_Error.&lt;br /&gt;
&lt;br /&gt;
Record set types and Number available in VB?&lt;br /&gt;
3. 1- Dynaset, 0 – Table, 2 – Snap Shot.&lt;br /&gt;
&lt;br /&gt;
Referential Integrity (Take care By jet database Engine).&lt;br /&gt;
Cascade Delete, Cascade Update – is done setting property of Attributes.&lt;br /&gt;
DbRelationDeleteCascade,&lt;br /&gt;
DbRelationUpdateCascade.&lt;br /&gt;
&lt;br /&gt;
What are the locks available in Visual Basic?&lt;br /&gt;
Locking is the process by which a DBMS restricts access to a row in a multi-user environment&lt;br /&gt;
4 types of locks. They are &lt;br /&gt;
1.Batch Optimistic&lt;br /&gt;
2.Optimistic&lt;br /&gt;
3.Pessimistic&lt;br /&gt;
4.ReadOnly&lt;br /&gt;
&lt;br /&gt;
What is the diff between RDO and ADO?&lt;br /&gt;
RDO is Hierarchy model where as ADO is Object model. ADO can access data from both flat files as well as the data bases. I.e., It is encapsulation of DAO, RDO , OLE that is why we call it as OLE-DB Technology.&lt;br /&gt;
&lt;br /&gt;
How can we call Stored procedure of Back End in RDO and ADO ?&lt;br /&gt;
In RDO – We can call using RDO Query Objects.&lt;br /&gt;
In ADO – We can call using Command Objects.&lt;br /&gt;
&lt;br /&gt;
What is the different between Microsoft ODBC Driver and Oracle OBDC Driver?&lt;br /&gt;
Microsoft ODBC driver will support all the methods and properties of Visual Basic. Where as the Oracle not.&lt;br /&gt;
&lt;br /&gt;
What are the Technologies for Accessing Database from Visual Basic?&lt;br /&gt;
DAO, Data Control, RDO, ODBCDIRECT, ADO, ODBC API.&lt;br /&gt;
&lt;br /&gt;
Calling Stored Procedures in VB?&lt;br /&gt;
1. Calling Simply the Procedure with out Arguments &quot;Call ProcedureName}&quot;&lt;br /&gt;
&lt;br /&gt;
If it is with Arguments Means then&lt;br /&gt;
Declare the Query Def qy&lt;br /&gt;
Set Qy as New Query def&lt;br /&gt;
Qy.SQL = &quot;{Call ProcedureName(?,?,?)}&quot; &lt;br /&gt;
qy(0)=val(Txt1.Text) &lt;br /&gt;
qy(1)=val(Txt2.Text) &lt;br /&gt;
qy(2)=val(Txt3.Text) &lt;br /&gt;
Set Rs = Qy.OpenresultSet&lt;br /&gt;
Txt(1)=Rs.RdoColumns(0)&lt;br /&gt;
&lt;br /&gt;
What is MAPI ?&lt;br /&gt;
Messaging Application programming Interface.&lt;br /&gt;
&lt;br /&gt;
Different type of Passing Value?&lt;br /&gt;
By value, By ref, Optional, Param Array.&lt;br /&gt;
Note:- Optional keyword cannot be used while declaring arguments for a function using param array.&lt;br /&gt;
&lt;br /&gt;
What are the different types of error?&lt;br /&gt;
Syntax Errors, Runtime , Logic.&lt;br /&gt;
&lt;br /&gt;
What is Seek Method which type of record set is available this?&lt;br /&gt;
Only in DbOpenTables.&lt;br /&gt;
Syntax: rs.index = &quot;empno&quot;&lt;br /&gt;
rs.seek &quot;=&quot; , 10&lt;br /&gt;
If with our setting the rs.index then run time error will occur.&lt;br /&gt;
&lt;br /&gt;
What is Centralization Error Handling?&lt;br /&gt;
Writing function and calling it when error occurs.&lt;br /&gt;
&lt;br /&gt;
Handling Error in Calling chain.&lt;br /&gt;
This will call the top most error where the error is handled.&lt;br /&gt;
&lt;br /&gt;
To connect the Data Control with Back end What are all the properties to be set?&lt;br /&gt;
Data source Name, Record Source Name&lt;br /&gt;
&lt;br /&gt;
How to trap Data Base Error?&lt;br /&gt;
Dim x as RDOError&lt;br /&gt;
X(0).Des&lt;br /&gt;
X(1).Number&lt;br /&gt;
&lt;br /&gt;
What is view Port?&lt;br /&gt;
The area under which the container provides the view of the ActiveX Document is known as a view port.&lt;br /&gt;
&lt;br /&gt;
What methods are used for DBGrid in unbound mode?&lt;br /&gt;
AddData, EditData, Readdata, WriteData.&lt;br /&gt;
&lt;br /&gt;
How to increase the Date corresponding with month, date, year?&lt;br /&gt;
DateSerial(year(Now),Month(Now)+1,1)&lt;br /&gt;
Hour, min, sec, month, year, DateSerial, dateadd, datediff, weekday, datevalue, timeserial, timevalue.&lt;br /&gt;
&lt;br /&gt;
Setting the Cursors.&lt;br /&gt;
Default Cursor – 0&lt;br /&gt;
ODBC Cursor (Client side) – 1&lt;br /&gt;
ServerSide Cursors (More Network traffic) - 2Cursor management &lt;br /&gt;
Client Batch – Batch up the Multiple SQL Statements in a single string and Send them to the Server at one time.&lt;br /&gt;
&lt;br /&gt;
What are the record set types?&lt;br /&gt;
RdOpenFowardOnly 0 (Default used only for the read only purpose)&lt;br /&gt;
RdOpenStatic 1&lt;br /&gt;
RdOpenDynamic 2&lt;br /&gt;
RdOpenKeySet 3 (Normally used for the live project)&lt;br /&gt;
&lt;br /&gt;
Diff types of Lock Types?&lt;br /&gt;
RdConcurReadOnly 0 (Default)&lt;br /&gt;
RdConcurLock 1 (Pessimistic Locking)&lt;br /&gt;
RdConcurRowver 2 (Optimistic Locking)&lt;br /&gt;
RdConcurValues 3&lt;br /&gt;
RdConcurBatch 4&lt;br /&gt;
&lt;br /&gt;
What are the RDO Methods and Events?&lt;br /&gt;
Methods Events&lt;br /&gt;
Begin Trans Validate&lt;br /&gt;
Commit Trans Reposition&lt;br /&gt;
Rollback Trans Error&lt;br /&gt;
Cancel Query Complied&lt;br /&gt;
Refresh &lt;br /&gt;
Update Controls&lt;br /&gt;
Update row&lt;br /&gt;
&lt;br /&gt;
What is Static Cursor?&lt;br /&gt;
In ADO Snap Shot is called so.&lt;br /&gt;
&lt;br /&gt;
What is Mixed Cursors?&lt;br /&gt;
Static + Keyset&lt;br /&gt;
&lt;br /&gt;
What is FireHouse Cursors?&lt;br /&gt;
Forward Only Some time Updateable&lt;br /&gt;
&lt;br /&gt;
What is DBSqlPassThrough?&lt;br /&gt;
It will By Passing the Jet Query Processor.&lt;br /&gt;
&lt;br /&gt;
What is DBFailError?&lt;br /&gt;
Rolls Back updates if any errors Occurs.&lt;br /&gt;
&lt;br /&gt;
DSN Less Connection?&lt;br /&gt;
&quot;Server=Oracle; Driver={Microsoft ODBC for Oracle};&quot;&lt;br /&gt;
&lt;br /&gt;
What is RdExecDirect?&lt;br /&gt;
Bypasses the Creation of a stored procedure to execute the query. Does not apply to Oracle.&lt;br /&gt;
&lt;br /&gt;
RdoParameter Object RdoParameterConstant&lt;br /&gt;
Direction RdparamInput&lt;br /&gt;
RdparamInputOutput&lt;br /&gt;
RdParamOutput&lt;br /&gt;
Name&lt;br /&gt;
Type&lt;br /&gt;
Value</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/916428602799105551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/vb-60-interview-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/916428602799105551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/916428602799105551'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/vb-60-interview-questions.html' title='VB 6.0 Interview Questions'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-5781371203377521371</id><published>2011-01-15T22:45:00.000+05:30</published><updated>2011-01-15T22:45:27.926+05:30</updated><title type='text'>STORED Procedure</title><content type='html'>CREATE PROCEDURE&lt;br /&gt;
Creates a stored procedure, which is a saved collection of Transact-SQL statements that can take and return user-supplied parameters.&lt;br /&gt;
Procedures can be created for permanent use or for temporary use within a session (local temporary procedure) or for temporary use within all sessions (global temporary procedure).&lt;br /&gt;
Stored procedures can also be created to run automatically when Microsoft® SQL Server™ starts.&lt;br /&gt;
Syntax&lt;br /&gt;
CREATE PROC [ EDURE ] procedure_name [ ; number ] &lt;br /&gt;
    [ { @parameter data_type } &lt;br /&gt;
        [ VARYING ] [ = default ] [ OUTPUT ] &lt;br /&gt;
    ] [ ,...n ] &lt;br /&gt;
&lt;br /&gt;
[ WITH &lt;br /&gt;
    { RECOMPILE | ENCRYPTION | RECOMPILE , ENCRYPTION } ] &lt;br /&gt;
&lt;br /&gt;
[ FOR REPLICATION ] &lt;br /&gt;
&lt;br /&gt;
AS sql_statement [ ...n ] &lt;br /&gt;
Arguments&lt;br /&gt;
procedure_name&lt;br /&gt;
Is the name of the new stored procedure. Procedure names must conform to the rules for identifiers and must be unique within the database and its owner. For more information, see Using Identifiers. &lt;br /&gt;
Local or global temporary procedures can be created by preceding the procedure_name with a single number sign (#procedure_name) for local temporary procedures and a double number sign (##procedure_name) for global temporary procedures. The complete name, including # or ##, cannot exceed 128 characters. Specifying the procedure owner name is optional.&lt;br /&gt;
;number&lt;br /&gt;
Is an optional integer used to group procedures of the same name so they can be dropped together with a single DROP PROCEDURE statement. For example, the procedures used with an application called orders may be named orderproc;1, orderproc;2, and so on. The statement DROP PROCEDURE orderproc drops the entire group. If the name contains delimited identifiers, the number should not be included as part of the identifier; use the appropriate delimiter around procedure_name only.&lt;br /&gt;
@parameter&lt;br /&gt;
Is a parameter in the procedure. One or more parameters can be declared in a CREATE PROCEDURE statement. The value of each declared parameter must be supplied by the user when the procedure is executed (unless a default for the parameter is defined). A stored procedure can have a maximum of 2,100 parameters.&lt;br /&gt;
Specify a parameter name using an at sign (@) as the first character. The parameter name must conform to the rules for identifiers. Parameters are local to the procedure; the same parameter names can be used in other procedures. By default, parameters can take the place only of constants; they cannot be used in place of table names, column names, or the names of other database objects. For more information, see EXECUTE. &lt;br /&gt;
data_type&lt;br /&gt;
Is the parameter data type. All data types, including text, ntext and image, can be used as a parameter for a stored procedure. However, the cursor data type can be used only on OUTPUT parameters. When you specify a data type of cursor, the VARYING and OUTPUT keywords must also be specified. For more information about SQL Server - supplied data types and their syntax, see Data Types. &lt;br /&gt;
 &lt;br /&gt;
Note  There is no limit on the maximum number of output parameters that can be of cursor data type.&lt;br /&gt;
VARYING&lt;br /&gt;
Specifies the result set supported as an output parameter (constructed dynamically by the stored procedure and whose contents can vary). Applies only to cursor parameters.&lt;br /&gt;
default&lt;br /&gt;
Is a default value for the parameter. If a default is defined, the procedure can be executed without specifying a value for that parameter. The default must be a constant or it can be NULL. It can include wildcard characters (%, _, [], and [^]) if the procedure uses the parameter with the LIKE keyword.&lt;br /&gt;
OUTPUT&lt;br /&gt;
Indicates that the parameter is a return parameter. The value of this option can be returned to EXEC[UTE]. Use OUTPUT parameters to return information to the calling procedure. Text, ntext, and image parameters can be used as OUTPUT parameters. An output parameter using the OUTPUT keyword can be a cursor placeholder.&lt;br /&gt;
n&lt;br /&gt;
Is a placeholder indicating that a maximum of 2,100 parameters can be specified.&lt;br /&gt;
{RECOMPILE | ENCRYPTION | RECOMPILE, ENCRYPTION}&lt;br /&gt;
RECOMPILE indicates that SQL Server does not cache a plan for this procedure and the procedure is recompiled at run time. Use the RECOMPILE option when using atypical or temporary values without overriding the execution plan cached in memory.&lt;br /&gt;
ENCRYPTION indicates that SQL Server encrypts the syscomments table entry containing the text of the CREATE PROCEDURE statement. Using ENCRYPTION prevents the procedure from being published as part of SQL Server replication.&lt;br /&gt;
 &lt;br /&gt;
Note  During an upgrade, SQL Server uses the encrypted comments stored in syscomments to re-create encrypted procedures.&lt;br /&gt;
FOR REPLICATION&lt;br /&gt;
Specifies that stored procedures created for replication cannot be executed on the Subscriber. A stored procedure created with the FOR REPLICATION option is used as a stored procedure filter and only executed during replication. This option cannot be used with the WITH RECOMPILE option.&lt;br /&gt;
AS&lt;br /&gt;
Specifies the actions the procedure is to take.&lt;br /&gt;
sql_statement&lt;br /&gt;
Is any number and type of Transact-SQL statements to be included in the procedure. Some limitations apply.&lt;br /&gt;
n&lt;br /&gt;
Is a placeholder that indicates multiple Transact-SQL statements may be included in this procedure.&lt;br /&gt;
Remarks&lt;br /&gt;
The maximum size of a stored procedure is 128 MB.&lt;br /&gt;
A user-defined stored procedure can be created only in the current database (except for temporary procedures, which are always created in tempdb). The CREATE PROCEDURE statement cannot be combined with other Transact-SQL statements in a single batch. &lt;br /&gt;
Parameters are nullable by default. If a NULL parameter value is passed and that parameter is used in a CREATE or ALTER TABLE statement in which the column referenced does not allow NULLs, SQL Server generates an error. To prevent passing a NULL parameter value to a column that does not allow NULLs, add programming logic to the procedure or use a default value (with the DEFAULT keyword of CREATE or ALTER TABLE) for the column.&lt;br /&gt;
It is recommended that you explicitly specify NULL or NOT NULL for each column in any CREATE TABLE or ALTER TABLE statement in a stored procedure, such as when creating a temporary table. The ANSI_DFLT_ON and ANSI_DFLT_OFF options control the way SQL Server assigns the NULL or NOT NULL attributes to columns if not specified in a CREATE TABLE or ALTER TABLE statement. If a connection executes a stored procedure with different settings for these options than the connection that created the procedure, the columns of the table created for the second connection can have different nullability and exhibit different behaviors. If NULL or NOT NULL is explicitly stated for each column, the temporary tables are created with the same nullability for all connections that execute the stored procedure.&lt;br /&gt;
SQL Server saves the settings of both SET QUOTED_IDENTIFIER and SET ANSI_NULLS when a stored procedure is created or altered. These original settings are used when the stored procedure is executed. Therefore, any client session settings for SET QUOTED_IDENTIFIER and SET ANSI_NULLS are ignored during stored procedure execution. SET QUOTED_IDENTIFIER and SET ANSI_NULLS statements that occur within the stored procedure do not affect the functionality of the stored procedure.&lt;br /&gt;
Other SET options, such as SET ARITHABORT, SET ANSI_WARNINGS, or SET ANSI_PADDINGS are not saved when a stored procedure is created or altered. If the logic of the stored procedure is dependent on a particular setting, include a SET statement at the start of the procedure to ensure the proper setting. When a SET statement is executed from a stored procedure, the setting remains in effect only until the stored procedure completes. The setting is then restored to the value it had when the stored procedure was called. This allows individual clients to set the options wanted without affecting the logic of the stored procedure.&lt;br /&gt;
 &lt;br /&gt;
Note  Whether SQL Server interprets an empty string as either a single space or as a true empty string is controlled by the compatibility level setting. If the compatibility level is less than or equal to 65, SQL Server interprets empty strings as single spaces. If the compatibility level is equal to 70, SQL Server interprets empty strings as empty strings. For more information, see sp_dbcmptlevel. &lt;br /&gt;
Getting Information About Stored Procedures&lt;br /&gt;
To display the text used to create the procedure, execute sp_helptext in the database in which the procedure exists with the procedure name as the parameter. &lt;br /&gt;
 &lt;br /&gt;
Note  Stored procedures created with the ENCRYPTION option cannot be viewed with sp_helptext.&lt;br /&gt;
For a report on the objects referenced by a procedure, use sp_depends. &lt;br /&gt;
To rename a procedure, use sp_rename. &lt;br /&gt;
Referencing Objects&lt;br /&gt;
SQL Server allows the creation of stored procedures that reference objects that do not yet exist. At creation time, only syntax checking is done. The stored procedure is compiled to generate an execution plan when executed, if a valid plan does not already exist in the cache. Only during compilation are all objects referenced in the stored procedure resolved. Thus, a syntactically correct stored procedure that references objects which do not exist can be created successfully, but will fail at run time because referenced objects do not exist. For more information, see Deferred Name Resolution and Compilation. &lt;br /&gt;
Deferred Name Resolution and Compatibility Level&lt;br /&gt;
SQL Server allows Transact-SQL stored procedures to refer to tables that do not exist at creation time. This ability is called deferred name resolution. If, however, the Transact-SQL stored procedure refers to a table defined within the stored procedure, a warning is issued at creation time if the compatibility level setting (set by executing sp_dbcmptlevel) is 65. An error message is returned at run time if the table referenced does not exist. For more information, see sp_dbcmptlevel and Deferred Name Resolution and Compilation. &lt;br /&gt;
Executing Stored Procedures&lt;br /&gt;
When a CREATE PROCEDURE statement is executed successfully, the procedure name is stored in the sysobjects system table and the text of the CREATE PROCEDURE statement is stored in syscomments. When executed for the first time, the procedure is compiled to determine an optimal access plan to retrieve the data.&lt;br /&gt;
Parameters Using the cursor Data Type&lt;br /&gt;
Stored procedures can use the cursor data type only for OUTPUT parameters. If the cursor data type is specified for a parameter, both the VARYING and OUTPUT parameters are required. If the VARYING keyword is specified for a parameter, the data type must be cursor and the OUTPUT keyword must be specified.&lt;br /&gt;
 &lt;br /&gt;
Note  The cursor data type cannot be bound to application variables through the database APIs such as OLE DB, ODBC, ADO, and DB-Library. Because OUTPUT parameters must be bound before an application can execute a stored procedure, stored procedures with cursor OUTPUT parameters cannot be called from the database APIs. These procedures can be called from Transact-SQL batches, stored procedures, or triggers only when the cursor OUTPUT variable is assigned to a Transact-SQL local cursor variable.&lt;br /&gt;
Cursor Output Parameters&lt;br /&gt;
The following rules pertain to cursor output parameters when the procedure is executed: &lt;br /&gt;
• For a forward-only cursor, the rows returned in the cursor&#39;s result set are only those rows at and beyond the position of the cursor at the conclusion of the stored procedure executed, for example: &lt;br /&gt;
• A nonscrollable cursor is opened in a procedure on a result set named RS of 100 rows. &lt;br /&gt;
• The procedure fetches the first 5 rows of result set RS.&lt;br /&gt;
• The procedure returns to its caller.&lt;br /&gt;
• The result set RS returned to the caller consists of rows from 6 through 100 of RS, and the cursor in the caller is positioned before the first row of RS. &lt;br /&gt;
• For a forward-only cursor, if the cursor is positioned before the first row upon completion of the stored procedure, the entire result set is returned to the calling batch, stored procedure, or trigger. When returned, the cursor position is set before the first row.&lt;br /&gt;
• For a forward-only cursor, if the cursor is positioned beyond the end of the last row upon completion of the stored procedure, an empty result set is returned to the calling batch, stored procedure, or trigger. &lt;br /&gt;
 &lt;br /&gt;
Note  An empty result set is not the same as a null value.&lt;br /&gt;
• For a scrollable cursor, all the rows in the result set are returned to the calling batch, stored procedure, or trigger at the conclusion of the execution of the stored procedure. When returned, the cursor position is left at the position of the last fetch executed in the procedure.&lt;br /&gt;
• For any type of cursor, if the cursor is closed, then a null value is passed back to the calling batch, stored procedure, or trigger. This will also be the case if a cursor is assigned to a parameter, but that cursor is never opened. &lt;br /&gt;
 &lt;br /&gt;
Note  The closed state matters only at return time. For example, it is valid to close a cursor part way through the procedure, to open it again later in the procedure, and return that cursor&#39;s result set to the calling batch, stored procedure, or trigger.&lt;br /&gt;
Temporary Stored Procedures&lt;br /&gt;
SQL Server supports two types of temporary procedures: local and global. A local temporary procedure is visible only to the connection that created it. A global temporary procedure is available to all connections. Local temporary procedures are automatically dropped at the end of the current session. Global temporary procedures are dropped at the end of the last session using the procedure. Usually, this is when the session that created the procedure ends.&lt;br /&gt;
Temporary procedures named with # and ## can be created by any user. When the procedure is created, the owner of the local procedure is the only one who can use it. Permission to execute a local temporary procedure cannot be granted for other users. If a global temporary procedure is created, all users can access it; permissions cannot be revoked explicitly. Explicitly creating a temporary procedure in tempdb (naming without a number sign) can be performed only by those with explicit CREATE PROCEDURE permission in the tempdb database. Permission can be granted and revoked from these procedures. &lt;br /&gt;
 &lt;br /&gt;
Note  Heavy use of temporary stored procedures can create contention on the system tables in tempdb and adversely affect performance. It is recommended that sp_executesql be used instead. sp_executesql does not store data in the system tables and therefore avoids the problem.&lt;br /&gt;
Automatically Executing Stored Procedures&lt;br /&gt;
One or more stored procedures can execute automatically when SQL Server starts. The stored procedures must be created by the system administrator and executed under the sysadmin fixed server role as a background process. The procedure(s) cannot have any input parameters. &lt;br /&gt;
There is no limit to the number of startup procedures you can have, but be aware that each consumes one connection while executing. If you must execute multiple procedures at startup but do not need to execute them in parallel, make one procedure the startup procedure and have that procedure call the other procedures. This uses only one connection.&lt;br /&gt;
Execution of the stored procedures starts when the last database is recovered at startup. To skip launching these stored procedures, specify trace flag 4022 as a startup parameter. If you start SQL Server with minimal configuration (using the -f flag), the startup stored procedures are not executed. For more information, see Trace Flags. &lt;br /&gt;
To create a startup stored procedure, you must be logged in as a member of the sysadmin fixed server role and create the stored procedure in the master database.&lt;br /&gt;
Use sp_procoption to: &lt;br /&gt;
• Designate an existing stored procedure as a startup procedure.&lt;br /&gt;
• Stop a procedure from executing at SQL Server startup.&lt;br /&gt;
• View a list of all procedures that execute at SQL Server startup. &lt;br /&gt;
Stored Procedure Nesting&lt;br /&gt;
Stored procedures can be nested; that is one stored procedure calling another. The nesting level is incremented when the called procedure starts execution, and decremented when the called procedure finishes execution. Exceeding the maximum levels of nesting causes the whole calling procedure chain to fail. The current nesting level is returned by the @@NESTLEVEL function.&lt;br /&gt;
To estimate the size of a compiled stored procedure, use these Performance Monitor Counters. &lt;br /&gt;
Performance Monitor object name Performance Monitor Counter name&lt;br /&gt;
SQLServer: Buffer Manager Cache Size (pages)&lt;br /&gt;
SQLServer: Cache Manager Cache Hit Ratio&lt;br /&gt;
  Cache Pages&lt;br /&gt;
  Cache Object Counts*&lt;br /&gt;
&lt;br /&gt;
* These counters are available for various categories of cache objects including adhoc sql, prepared sql, procedures, triggers, and so on.&lt;br /&gt;
For more information, see SQL Server: Buffer Manager Object and SQL Server: Cache Manager Object. &lt;br /&gt;
sql_statement Limitations&lt;br /&gt;
Any SET statement can be specified inside a stored procedure except SET SHOWPLAN_TEXT and SET SHOWPLAN_ALL, which must be the only statements in the batch. The SET option chosen remains in effect during the execution of the stored procedure and then reverts to its former setting. &lt;br /&gt;
Inside a stored procedure, object names used with certain statements must be qualified with the name of the object owner if other users are to use the stored procedure. The statements are: &lt;br /&gt;
• ALTER TABLE&lt;br /&gt;
• CREATE INDEX&lt;br /&gt;
• CREATE TABLE&lt;br /&gt;
• All DBCC statements&lt;br /&gt;
• DROP TABLE&lt;br /&gt;
• DROP INDEX&lt;br /&gt;
• TRUNCATE TABLE&lt;br /&gt;
• UPDATE STATISTICS &lt;br /&gt;
Permissions&lt;br /&gt;
CREATE PROCEDURE permissions default to members of the sysadmin fixed server role, and the db_owner and db_ddladmin fixed database roles. Members of the sysadmin fixed server role and the db_owner fixed database role can transfer CREATE PROCEDURE permissions to other users. Permission to execute a stored procedure is given to the procedure owner, who can then set execution permission for other database users.&lt;br /&gt;
Examples&lt;br /&gt;
A. Use a simple procedure with a complex SELECT&lt;br /&gt;
This stored procedure returns all authors (first and last names supplied), their titles, and their publishers from a four-table join. This stored procedure does not use any parameters.&lt;br /&gt;
USE pubs&lt;br /&gt;
IF EXISTS (SELECT name FROM sysobjects &lt;br /&gt;
         WHERE name = &#39;au_info_all&#39; AND type = &#39;P&#39;)&lt;br /&gt;
   DROP PROCEDURE au_info_all&lt;br /&gt;
GO&lt;br /&gt;
CREATE PROCEDURE au_info_all&lt;br /&gt;
AS&lt;br /&gt;
SELECT au_lname, au_fname, title, pub_name&lt;br /&gt;
   FROM authors a INNER JOIN titleauthor ta&lt;br /&gt;
      ON a.au_id = ta.au_id INNER JOIN titles t&lt;br /&gt;
      ON t.title_id = ta.title_id INNER JOIN publishers p&lt;br /&gt;
      ON t.pub_id = p.pub_id&lt;br /&gt;
GO&lt;br /&gt;
The au_info_all stored procedure can be executed in these ways:&lt;br /&gt;
EXECUTE au_info_all&lt;br /&gt;
-- Or&lt;br /&gt;
EXEC au_info_all&lt;br /&gt;
Or, if this procedure is the first statement within the batch:&lt;br /&gt;
au_info_all&lt;br /&gt;
B. Use a simple procedure with parameters &lt;br /&gt;
This stored procedure returns only the specified authors (first and last names supplied), their titles, and their publishers from a four-table join. This stored procedure accepts exact matches for the parameters passed.&lt;br /&gt;
USE pubs&lt;br /&gt;
IF EXISTS (SELECT name FROM sysobjects &lt;br /&gt;
         WHERE name = &#39;au_info&#39; AND type = &#39;P&#39;)&lt;br /&gt;
   DROP PROCEDURE au_info&lt;br /&gt;
GO&lt;br /&gt;
USE pubs&lt;br /&gt;
GO&lt;br /&gt;
CREATE PROCEDURE au_info &lt;br /&gt;
   @lastname varchar(40), &lt;br /&gt;
   @firstname varchar(20) &lt;br /&gt;
AS &lt;br /&gt;
SELECT au_lname, au_fname, title, pub_name&lt;br /&gt;
   FROM authors a INNER JOIN titleauthor ta&lt;br /&gt;
      ON a.au_id = ta.au_id INNER JOIN titles t&lt;br /&gt;
      ON t.title_id = ta.title_id INNER JOIN publishers p&lt;br /&gt;
      ON t.pub_id = p.pub_id&lt;br /&gt;
   WHERE  au_fname = @firstname&lt;br /&gt;
      AND au_lname = @lastname&lt;br /&gt;
GO&lt;br /&gt;
The au_info stored procedure can be executed in these ways:&lt;br /&gt;
EXECUTE au_info &#39;Dull&#39;, &#39;Ann&#39;&lt;br /&gt;
-- Or&lt;br /&gt;
EXECUTE au_info @lastname = &#39;Dull&#39;, @firstname = &#39;Ann&#39;&lt;br /&gt;
-- Or&lt;br /&gt;
EXECUTE au_info @firstname = &#39;Ann&#39;, @lastname = &#39;Dull&#39;&lt;br /&gt;
-- Or&lt;br /&gt;
EXEC au_info &#39;Dull&#39;, &#39;Ann&#39;&lt;br /&gt;
-- Or&lt;br /&gt;
EXEC au_info @lastname = &#39;Dull&#39;, @firstname = &#39;Ann&#39;&lt;br /&gt;
-- Or&lt;br /&gt;
EXEC au_info @firstname = &#39;Ann&#39;, @lastname = &#39;Dull&#39;&lt;br /&gt;
Or, if this procedure is the first statement within the batch:&lt;br /&gt;
au_info &#39;Dull&#39;, &#39;Ann&#39;&lt;br /&gt;
-- Or&lt;br /&gt;
au_info @lastname = &#39;Dull&#39;, @firstname = &#39;Ann&#39;&lt;br /&gt;
-- Or&lt;br /&gt;
au_info @firstname = &#39;Ann&#39;, @lastname = &#39;Dull&#39;&lt;br /&gt;
C. Use a simple procedure with wildcard parameters &lt;br /&gt;
This stored procedure returns only the specified authors (first and last names supplied), their titles, and their publishers from a four-table join. This stored procedure pattern matches the parameters passed or, if not supplied, uses the preset defaults.&lt;br /&gt;
USE pubs&lt;br /&gt;
IF EXISTS (SELECT name FROM sysobjects &lt;br /&gt;
      WHERE name = &#39;au_info2&#39; AND type = &#39;P&#39;)&lt;br /&gt;
   DROP PROCEDURE au_info2&lt;br /&gt;
GO&lt;br /&gt;
USE pubs&lt;br /&gt;
GO&lt;br /&gt;
CREATE PROCEDURE au_info2&lt;br /&gt;
   @lastname varchar(30) = &#39;D%&#39;,&lt;br /&gt;
   @firstname varchar(18) = &#39;%&#39;&lt;br /&gt;
AS &lt;br /&gt;
SELECT au_lname, au_fname, title, pub_name&lt;br /&gt;
FROM authors a INNER JOIN titleauthor ta&lt;br /&gt;
   ON a.au_id = ta.au_id INNER JOIN titles t&lt;br /&gt;
   ON t.title_id = ta.title_id INNER JOIN publishers p&lt;br /&gt;
   ON t.pub_id = p.pub_id&lt;br /&gt;
WHERE au_fname LIKE @firstname&lt;br /&gt;
   AND au_lname LIKE @lastname&lt;br /&gt;
GO&lt;br /&gt;
The au_info2 stored procedure can be executed in many combinations. Only a few combinations are shown here:&lt;br /&gt;
EXECUTE au_info2&lt;br /&gt;
-- Or&lt;br /&gt;
EXECUTE au_info2 &#39;Wh%&#39;&lt;br /&gt;
-- Or&lt;br /&gt;
EXECUTE au_info2 @firstname = &#39;A%&#39;&lt;br /&gt;
-- Or&lt;br /&gt;
EXECUTE au_info2 &#39;[CK]ars[OE]n&#39;&lt;br /&gt;
-- Or&lt;br /&gt;
EXECUTE au_info2 &#39;Hunter&#39;, &#39;Sheryl&#39;&lt;br /&gt;
-- Or&lt;br /&gt;
EXECUTE au_info2 &#39;H%&#39;, &#39;S%&#39;&lt;br /&gt;
D. Use OUTPUT parameters&lt;br /&gt;
OUTPUT parameters allow an external procedure, a batch, or more than one Transact-SQL statements to access a value set during the procedure execution. In this example, a stored procedure (titles_sum) is created and allows one optional input parameter and one output parameter.&lt;br /&gt;
First, create the procedure:&lt;br /&gt;
USE pubs&lt;br /&gt;
GO&lt;br /&gt;
IF EXISTS(SELECT name FROM sysobjects&lt;br /&gt;
      WHERE name = &#39;titles_sum&#39; AND type = &#39;P&#39;)&lt;br /&gt;
   DROP PROCEDURE titles_sum&lt;br /&gt;
GO&lt;br /&gt;
USE pubs&lt;br /&gt;
GO&lt;br /&gt;
CREATE PROCEDURE titles_sum @@TITLE varchar(40) = &#39;%&#39;, @@SUM money OUTPUT&lt;br /&gt;
AS&lt;br /&gt;
SELECT &#39;Title Name&#39; = title&lt;br /&gt;
FROM titles &lt;br /&gt;
WHERE title LIKE @@TITLE &lt;br /&gt;
SELECT @@SUM = SUM(price)&lt;br /&gt;
FROM titles&lt;br /&gt;
WHERE title LIKE @@TITLE&lt;br /&gt;
GO&lt;br /&gt;
Next, use the OUTPUT parameter with control-of-flow language. &lt;br /&gt;
 &lt;br /&gt;
Note  The OUTPUT variable must be defined during the table creation as well as during use of the variable.&lt;br /&gt;
The parameter name and variable name do not have to match; however, the data type and parameter positioning must match (unless @@SUM = variable is used). &lt;br /&gt;
DECLARE @@TOTALCOST money&lt;br /&gt;
EXECUTE titles_sum &#39;The%&#39;, @@TOTALCOST OUTPUT&lt;br /&gt;
IF @@TOTALCOST &lt; 200 &lt;br /&gt;
BEGIN&lt;br /&gt;
   PRINT &#39; &#39;&lt;br /&gt;
   PRINT &#39;All of these titles can be purchased for less than $200.&#39;&lt;br /&gt;
END&lt;br /&gt;
ELSE&lt;br /&gt;
   SELECT &#39;The total cost of these titles is $&#39; &lt;br /&gt;
         + RTRIM(CAST(@@TOTALCOST AS varchar(20)))&lt;br /&gt;
Here is the result set:&lt;br /&gt;
Title Name                                                               &lt;br /&gt;
------------------------------------------------------------------------ &lt;br /&gt;
The Busy Executive&#39;s Database Guide&lt;br /&gt;
The Gourmet Microwave&lt;br /&gt;
The Psychology of Computer Cooking&lt;br /&gt;
&lt;br /&gt;
(3 row(s) affected)&lt;br /&gt;
&lt;br /&gt;
Warning, null value eliminated from aggregate.&lt;br /&gt;
 &lt;br /&gt;
All of these titles can be purchased for less than $200.&lt;br /&gt;
E. Use an OUTPUT cursor parameter&lt;br /&gt;
OUTPUT cursor parameters are used to pass a cursor that is local to a stored procedure back to the calling batch, stored procedure, or trigger.&lt;br /&gt;
First, create the procedure that declares and then opens a cursor on the titles table:&lt;br /&gt;
USE pubs&lt;br /&gt;
IF EXISTS (SELECT name FROM sysobjects &lt;br /&gt;
      WHERE name = &#39;titles_cursor&#39; and type = &#39;P&#39;)&lt;br /&gt;
DROP PROCEDURE titles_cursor&lt;br /&gt;
GO&lt;br /&gt;
CREATE PROCEDURE titles_cursor @titles_cursor CURSOR VARYING OUTPUT&lt;br /&gt;
AS&lt;br /&gt;
SET @titles_cursor = CURSOR&lt;br /&gt;
FORWARD_ONLY STATIC FOR&lt;br /&gt;
SELECT *&lt;br /&gt;
FROM titles&lt;br /&gt;
&lt;br /&gt;
OPEN @titles_cursor&lt;br /&gt;
GO&lt;br /&gt;
Next, execute a batch that declares a local cursor variable, executes the procedure to assign the cursor to the local variable, and then fetches the rows from the cursor.&lt;br /&gt;
USE pubs&lt;br /&gt;
GO&lt;br /&gt;
DECLARE @MyCursor CURSOR&lt;br /&gt;
EXEC titles_cursor @titles_cursor = @MyCursor OUTPUT&lt;br /&gt;
WHILE (@@FETCH_STATUS = 0)&lt;br /&gt;
BEGIN&lt;br /&gt;
   FETCH NEXT FROM @MyCursor&lt;br /&gt;
END&lt;br /&gt;
CLOSE @MyCursor&lt;br /&gt;
DEALLOCATE @MyCursor&lt;br /&gt;
GO&lt;br /&gt;
F. Use the WITH RECOMPILE option&lt;br /&gt;
The WITH RECOMPILE clause is helpful when the parameters supplied to the procedure will not be typical, and when a new execution plan should not be cached or stored in memory.&lt;br /&gt;
USE pubs&lt;br /&gt;
IF EXISTS (SELECT name FROM sysobjects&lt;br /&gt;
      WHERE name = &#39;titles_by_author&#39; AND type = &#39;P&#39;)&lt;br /&gt;
   DROP PROCEDURE titles_by_author&lt;br /&gt;
GO&lt;br /&gt;
CREATE PROCEDURE titles_by_author @@LNAME_PATTERN varchar(30) = &#39;%&#39;&lt;br /&gt;
WITH RECOMPILE&lt;br /&gt;
AS&lt;br /&gt;
SELECT RTRIM(au_fname) + &#39; &#39; + RTRIM(au_lname) AS &#39;Authors full name&#39;,&lt;br /&gt;
   title AS Title&lt;br /&gt;
FROM authors a INNER JOIN titleauthor ta &lt;br /&gt;
   ON a.au_id = ta.au_id INNER JOIN titles t&lt;br /&gt;
   ON ta.title_id = t.title_id&lt;br /&gt;
WHERE au_lname LIKE @@LNAME_PATTERN&lt;br /&gt;
GO&lt;br /&gt;
G. Use the WITH ENCRYPTION option&lt;br /&gt;
The WITH ENCRYPTION clause hides the text of a stored procedure from users. This example creates an encrypted procedure, uses the sp_helptext system stored procedure to get information on that encrypted procedure, and then attempts to get information on that procedure directly from the syscomments table.&lt;br /&gt;
IF EXISTS (SELECT name FROM sysobjects&lt;br /&gt;
      WHERE name = &#39;encrypt_this&#39; AND type = &#39;P&#39;)&lt;br /&gt;
   DROP PROCEDURE encrypt_this&lt;br /&gt;
GO&lt;br /&gt;
USE pubs&lt;br /&gt;
GO&lt;br /&gt;
CREATE PROCEDURE encrypt_this&lt;br /&gt;
WITH ENCRYPTION&lt;br /&gt;
AS&lt;br /&gt;
SELECT * &lt;br /&gt;
FROM authors&lt;br /&gt;
GO&lt;br /&gt;
&lt;br /&gt;
EXEC sp_helptext encrypt_this&lt;br /&gt;
Here is the result set:&lt;br /&gt;
The object&#39;s comments have been encrypted.&lt;br /&gt;
Next, select the identification number and text of the encrypted stored procedure contents.&lt;br /&gt;
SELECT c.id, c.text &lt;br /&gt;
FROM syscomments c INNER JOIN sysobjects o&lt;br /&gt;
   ON c.id = o.id&lt;br /&gt;
WHERE o.name = &#39;encrypt_this&#39;&lt;br /&gt;
Here is the result set:&lt;br /&gt;
 &lt;br /&gt;
Note  The text column output is shown on a separate line. When executed, this information appears on the same line as the id column information.&lt;br /&gt;
id         text                                                        &lt;br /&gt;
---------- ------------------------------------------------------------&lt;br /&gt;
1413580074 ?????????????????????????????????e??????????????????????????????????????????????????????????????????????????&lt;br /&gt;
&lt;br /&gt;
(1 row(s) affected)&lt;br /&gt;
H. Create a user-defined system stored procedure&lt;br /&gt;
This example creates a procedure to display all the tables and their corresponding indexes with a table name beginning with the string emp. If not specified, this procedure returns all tables (and indexes) with a table name beginning with sys.&lt;br /&gt;
IF EXISTS (SELECT name FROM sysobjects&lt;br /&gt;
      WHERE name = &#39;sp_showindexes&#39; AND type = &#39;P&#39;)&lt;br /&gt;
   DROP PROCEDURE sp_showindexes&lt;br /&gt;
GO&lt;br /&gt;
USE master&lt;br /&gt;
GO&lt;br /&gt;
CREATE PROCEDURE sp_showindexes&lt;br /&gt;
   @@TABLE varchar(30) = &#39;sys%&#39;&lt;br /&gt;
AS &lt;br /&gt;
SELECT o.name AS TABLE_NAME,&lt;br /&gt;
   i.name AS INDEX_NAME, &lt;br /&gt;
   indid AS INDEX_ID&lt;br /&gt;
FROM sysindexes i INNER JOIN sysobjects o&lt;br /&gt;
   ON o.id = i.id &lt;br /&gt;
WHERE o.name LIKE @@TABLE&lt;br /&gt;
GO         &lt;br /&gt;
USE pubs&lt;br /&gt;
EXEC sp_showindexes &#39;emp%&#39;&lt;br /&gt;
GO&lt;br /&gt;
Here is the result set:&lt;br /&gt;
TABLE_NAME       INDEX_NAME       INDEX_ID &lt;br /&gt;
---------------- ---------------- ----------------&lt;br /&gt;
employee         employee_ind     1&lt;br /&gt;
employee         PK_emp_id        2&lt;br /&gt;
&lt;br /&gt;
(2 row(s) affected)&lt;br /&gt;
I. Use deferred name resolution&lt;br /&gt;
This example shows four procedures and the various ways that deferred name resolution can be used. Each stored procedure is created, although the table or column referenced does not exist at compile time.&lt;br /&gt;
IF EXISTS (SELECT name FROM sysobjects&lt;br /&gt;
      WHERE name = &#39;proc1&#39; AND type = &#39;P&#39;)&lt;br /&gt;
   DROP PROCEDURE proc1&lt;br /&gt;
GO&lt;br /&gt;
-- Creating a procedure on a nonexistent table.&lt;br /&gt;
USE pubs&lt;br /&gt;
GO&lt;br /&gt;
CREATE PROCEDURE proc1&lt;br /&gt;
AS&lt;br /&gt;
   SELECT *&lt;br /&gt;
   FROM does_not_exist&lt;br /&gt;
GO  &lt;br /&gt;
-- Here is the statement to actually see the text of the procedure.&lt;br /&gt;
SELECT o.id, c.text&lt;br /&gt;
FROM sysobjects o INNER JOIN syscomments c &lt;br /&gt;
   ON o.id = c.id&lt;br /&gt;
WHERE o.type = &#39;P&#39; AND o.name = &#39;proc1&#39;&lt;br /&gt;
GO&lt;br /&gt;
USE master&lt;br /&gt;
GO&lt;br /&gt;
IF EXISTS (SELECT name FROM sysobjects&lt;br /&gt;
      WHERE name = &#39;proc2&#39; AND type = &#39;P&#39;)&lt;br /&gt;
   DROP PROCEDURE proc2&lt;br /&gt;
GO&lt;br /&gt;
-- Creating a procedure that attempts to retrieve information from a&lt;br /&gt;
-- nonexistent column in an existing table.&lt;br /&gt;
USE pubs&lt;br /&gt;
GO&lt;br /&gt;
CREATE PROCEDURE proc2&lt;br /&gt;
AS&lt;br /&gt;
   DECLARE @middle_init char(1)&lt;br /&gt;
   SET @middle_init = NULL&lt;br /&gt;
   SELECT au_id, middle_initial = @middle_init&lt;br /&gt;
   FROM authors&lt;br /&gt;
GO  &lt;br /&gt;
-- Here is the statement to actually see the text of the procedure.&lt;br /&gt;
SELECT o.id, c.text&lt;br /&gt;
FROM sysobjects o INNER JOIN syscomments c &lt;br /&gt;
   ON o.id = c.id&lt;br /&gt;
WHERE o.type = &#39;P&#39; and o.name = &#39;proc2&#39;&lt;br /&gt;
See Also&lt;br /&gt;
ALTER PROCEDURE&lt;br /&gt;
Batches &lt;br /&gt;
Control-of-Flow Language&lt;br /&gt;
Cursors &lt;br /&gt;
DBCC&lt;br /&gt;
DECLARE @local_variable&lt;br /&gt;
DROP PROCEDURE&lt;br /&gt;
Functions&lt;br /&gt;
GRANT&lt;br /&gt;
Programming Stored Procedures&lt;br /&gt;
SELECT&lt;br /&gt;
sp_addextendedproc&lt;br /&gt;
sp_depends&lt;br /&gt;
sp_helptext&lt;br /&gt;
sp_procoption&lt;br /&gt;
sp_recompile&lt;br /&gt;
sp_rename&lt;br /&gt;
System Tables&lt;br /&gt;
Using Comments&lt;br /&gt;
Using Variables and Parameters</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/5781371203377521371/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/stored-procedure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/5781371203377521371'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/5781371203377521371'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/stored-procedure.html' title='STORED Procedure'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-591827895206647207</id><published>2011-01-15T22:34:00.000+05:30</published><updated>2011-01-15T22:34:02.769+05:30</updated><title type='text'>DBA Questions</title><content type='html'>What is normalization? Explain different levels of normalization?&lt;br /&gt;
Check out the article Q100139 from Microsoft knowledge base and of&lt;br /&gt;
course, there&#39;s much more information available in the net. It&#39;ll be a&lt;br /&gt;
good idea to get a hold of any RDBMS fundamentals textbook,&lt;br /&gt;
especially the one by C. J. Date. Most of the times, it will be okay&lt;br /&gt;
if you can explain till third normal form.&lt;br /&gt;
What is denormalization and when would you go for it?&lt;br /&gt;
As the name indicates, denormalization is the reverse process of&lt;br /&gt;
normalization. It&#39;s the controlled introduction of redundancy in to&lt;br /&gt;
the database design. It helps improve the query performance as the&lt;br /&gt;
number of joins could be reduced.&lt;br /&gt;
How do you implement one-to-one, one-to-many and many-to-many&lt;br /&gt;
relationships while designing tables?&lt;br /&gt;
One-to-One relationship can be implemented as a single table and&lt;br /&gt;
rarely as two tables with primary and foreign key relationships.&lt;br /&gt;
One-to-Many relationships are implemented by splitting the data into&lt;br /&gt;
two tables with primary key and foreign key relationships.&lt;br /&gt;
Many-to-Many relationships are implemented using a junction table with&lt;br /&gt;
the keys from both the tables forming the composite primary key of the&lt;br /&gt;
junction table.&lt;br /&gt;
It will be a good idea to read up a database designing fundamentals&lt;br /&gt;
textbook.&lt;br /&gt;
What&#39;s the difference between a primary key and a unique key?&lt;br /&gt;
Both primary key and unique enforce uniqueness of the column on which&lt;br /&gt;
they are defined. But by default primary key creates a clustered index&lt;br /&gt;
on the column, where are unique creates a nonclustered index by&lt;br /&gt;
default. Another major difference is that, primary key doesn&#39;t allow&lt;br /&gt;
NULLs, but unique key allows one NULL only.&lt;br /&gt;
What are users defined datatypes and when you should go for them?&lt;br /&gt;
User defined datatypes let you extend the base SQL Server datatypes by&lt;br /&gt;
providing a descriptive name, and format to the database. Take for&lt;br /&gt;
example, in your database, there is a column called Flight_Num which&lt;br /&gt;
appears in many tables. In all these tables it should be varchar(8).&lt;br /&gt;
In this case you could create a user-defined datatype called&lt;br /&gt;
Flight_num_type of varchar (8) and use it across all your tables.&lt;br /&gt;
See sp_addtype, sp_droptype in books online.&lt;br /&gt;
What is bit datatype and what&#39;s the information that can be stored&lt;br /&gt;
inside a bit column?&lt;br /&gt;
Bit datatype is used to store boolean information like 1 or 0 (true or&lt;br /&gt;
false). Untill SQL Server 6.5 bit datatype could hold either a 1 or 0&lt;br /&gt;
and there was no support for NULL. But from SQL Server 7.0 onwards,&lt;br /&gt;
bit datatype can represent a third state, which is NULL.&lt;br /&gt;
Define candidate key, alternate key, composite key.&lt;br /&gt;
A candidate key is one that can identify each row of a table uniquely.&lt;br /&gt;
Generally a candidate key becomes the primary key of the table. If the&lt;br /&gt;
table has more than one candidate key, one of them will become the&lt;br /&gt;
primary key, and the rest are called alternate keys.&lt;br /&gt;
A key formed by combining at least two or more columns is called&lt;br /&gt;
composite key.&lt;br /&gt;
What are defaults? Is there a column to which a default can&#39;t be bound?&lt;br /&gt;
A default is a value that will be used by a column, if no value is&lt;br /&gt;
supplied to that column while inserting data. IDENTITY columns and&lt;br /&gt;
timestamp columns can&#39;t have defaults bound to them. See CREATE&lt;br /&gt;
DEFUALT in books online.&lt;br /&gt;
Back to top&lt;br /&gt;
SQL Server architecture       (top)&lt;br /&gt;
What is a transaction and what are ACID properties?&lt;br /&gt;
A transaction is a logical unit of work in which, all the steps must&lt;br /&gt;
be performed or none. ACID stands for Atomicity, Consistency,&lt;br /&gt;
Isolation, Durability. These are the properties of a transaction. For&lt;br /&gt;
more information and explanation of these properties, see SQL Server&lt;br /&gt;
books online or any RDBMS fundamentals text book.&lt;br /&gt;
Explain different isolation levels&lt;br /&gt;
An isolation level determines the degree of isolation of data between&lt;br /&gt;
concurrent transactions. The default SQL Server isolation level is&lt;br /&gt;
Read Committed. Here are the other isolation levels (in the ascending&lt;br /&gt;
order of isolation): Read Uncommitted, Read Committed, Repeatable&lt;br /&gt;
Read, Serializable. See SQL Server books online for an explanation of&lt;br /&gt;
the isolation levels. Be sure to read about SET TRANSACTION ISOLATION&lt;br /&gt;
LEVEL, which lets you customize the isolation level at the connection&lt;br /&gt;
level.&lt;br /&gt;
CREATE INDEX myIndex ON myTable(myColumn)&lt;br /&gt;
What type of Index will get created after executing the above statement?&lt;br /&gt;
Non-clustered index. Important thing to note: By default a clustered&lt;br /&gt;
index gets created on the primary key, unless specified otherwise.&lt;br /&gt;
What&#39;s the maximum size of a row?&lt;br /&gt;
8060 bytes. Don&#39;t be surprised with questions like &#39;what is the&lt;br /&gt;
maximum number of columns per table&#39;. Check out SQL Server books&lt;br /&gt;
online for the page titled: &quot;Maximum Capacity Specifications&quot;.&lt;br /&gt;
Explain Active/Active and Active/Passive cluster configurations&lt;br /&gt;
Hopefully you have experience setting up cluster servers. But if you&lt;br /&gt;
don&#39;t, at least be familiar with the way clustering works and the two&lt;br /&gt;
clustering configurations Active/Active and Active/Passive. SQL&lt;br /&gt;
Server books online has enough information on this topic and there is&lt;br /&gt;
a good white paper available on Microsoft site.&lt;br /&gt;
Explain the architecture of SQL Server&lt;br /&gt;
This is a very important question and you better be able to answer it&lt;br /&gt;
if consider yourself a DBA. SQL Server books online is the best place&lt;br /&gt;
to read about SQL Server architecture. Read up the chapter dedicated&lt;br /&gt;
to SQL Server Architecture.&lt;br /&gt;
What is lock escalation?&lt;br /&gt;
Lock escalation is the process of converting a lot of low level locks&lt;br /&gt;
(like row locks, page locks) into higher-level locks (like table&lt;br /&gt;
locks). Every lock is a memory structure too many locks would mean,&lt;br /&gt;
more memory being occupied by locks. To prevent this from happening,&lt;br /&gt;
SQL Server escalates the many fine-grain locks to fewer coarse-grain&lt;br /&gt;
locks. Lock escalation threshold was definable in SQL Server 6.5, but&lt;br /&gt;
from SQL Server 7.0 onwards it&#39;s dynamically managed by SQL Server.&lt;br /&gt;
What&#39;s the difference between DELETE TABLE and TRUNCATE TABLE commands?&lt;br /&gt;
DELETE TABLE is a logged operation, so the deletion of each row gets&lt;br /&gt;
logged in the transaction log, which makes it slow. TRUNCATE TABLE&lt;br /&gt;
also deletes all the rows in a table, but it won&#39;t log the deletion of&lt;br /&gt;
each row, instead it logs the reallocations of the data pages of the&lt;br /&gt;
table, which makes it faster. Of course, TRUNCATE TABLE can be rolled&lt;br /&gt;
back.&lt;br /&gt;
Explain the storage models of OLAP&lt;br /&gt;
Check out MOLAP, ROLAP and HOLAP in SQL Server books online for more&lt;br /&gt;
information.&lt;br /&gt;
What are the new features introduced in SQL Server 2000 (or the latest&lt;br /&gt;
release of SQL Server at the time of your interview)? What changed&lt;br /&gt;
between the previous version of SQL Server and the current version?&lt;br /&gt;
This question is generally asked to see how current is your knowledge.&lt;br /&gt;
Generally there is a section in the beginning of the books online&lt;br /&gt;
titled &quot;What&#39;s New&quot;, which has all such information. Of course,&lt;br /&gt;
reading just that is not enough, you should have tried those things to&lt;br /&gt;
better answer the questions. Also check out the section titled&lt;br /&gt;
&quot;Backward Compatibility&quot; in books online, which talks about the changes&lt;br /&gt;
that have taken place in the new version.&lt;br /&gt;
What are constraints? Explain different types of constraints.&lt;br /&gt;
Constraints enable the RDBMS enforce the integrity of the database&lt;br /&gt;
automatically, without needing you to create triggers, rule or defaults.&lt;br /&gt;
Types of constraints: NOT NULL, CHECK, UNIQUE, PRIMARY KEY, FOREIGN KEY&lt;br /&gt;
For an explanation of these constraints see books online for the pages&lt;br /&gt;
titled: &quot;Constraints&quot; and &quot;CREATE TABLE&quot;, &quot;ALTER TABLE&quot;&lt;br /&gt;
What is an index? What are the types of indexes? How many clustered&lt;br /&gt;
indexes can be created on a table? I create a separate index on each&lt;br /&gt;
column of a table. What are the advantages and disadvantages of this&lt;br /&gt;
approach?&lt;br /&gt;
Indexes in SQL Server are similar to the indexes in books. They help&lt;br /&gt;
SQL Server retrieve the data quicker.&lt;br /&gt;
Indexes are of two types. Clustered indexes and non-clustered indexes.&lt;br /&gt;
When you create a clustered index on a table, all the rows in the&lt;br /&gt;
table are stored in the order of the clustered index key. So, there&lt;br /&gt;
can be only one clustered index per table. Non-clustered indexes have&lt;br /&gt;
their own storage separate from the table data storage. Non-clustered&lt;br /&gt;
indexes are stored as B-tree structures (so do clustered indexes),&lt;br /&gt;
with the leaf level nodes having the index key and it&#39;s row locater.&lt;br /&gt;
The row located could be the RID or the Clustered index key, depending&lt;br /&gt;
up on the absence or presence of clustered index on the table.&lt;br /&gt;
If you create an index on each column of a table, it improves the&lt;br /&gt;
query performance, as the query optimizer can choose from all the&lt;br /&gt;
existing indexes to come up with an efficient execution plan. At the&lt;br /&gt;
same time, data modification operations (such as INSERT, UPDATE,&lt;br /&gt;
DELETE) will become slow, as every time data changes in the table, all&lt;br /&gt;
the indexes need to be updated. Another disadvantage is that, indexes&lt;br /&gt;
need disk space, the more indexes you have, more disk space is used.&lt;br /&gt;
Back to top&lt;br /&gt;
Database administration       (top)&lt;br /&gt;
What is RAID and what are different types of RAID configurations?&lt;br /&gt;
RAID stands for Redundant Array of Inexpensive Disks, used to provide&lt;br /&gt;
fault tolerance to database servers. There are six RAID levels 0&lt;br /&gt;
through 5 offering different levels of performance, fault tolerance.&lt;br /&gt;
MSDN has some information about RAID levels and for detailed&lt;br /&gt;
information; check out the RAID advisory board&#39;s homepage&lt;br /&gt;
What are the steps you will take to improve performance of a poor&lt;br /&gt;
performing query?&lt;br /&gt;
This is a very open ended question and there could be a lot of reasons&lt;br /&gt;
behind the poor performance of a query. But some general issues that&lt;br /&gt;
you could talk about would be: No indexes, table scans, missing or out&lt;br /&gt;
of date statistics, blocking, excess recompilations of stored&lt;br /&gt;
procedures, procedures and triggers without SET NOCOUNT ON, poorly&lt;br /&gt;
written query with unnecessarily complicated joins, too much&lt;br /&gt;
normalization, excess usage of cursors and temporary tables.&lt;br /&gt;
Some of the tools/ways that help you troubleshooting performance&lt;br /&gt;
problems are: SET SHOWPLAN_ALL ON, SET SHOWPLAN_TEXT ON, SET&lt;br /&gt;
STATISTICS IO ON, SQL Server Profiler, Windows NT /2000 Performance&lt;br /&gt;
monitor, Graphical execution plan in Query Analyzer.&lt;br /&gt;
Download the white paper on performance tuning SQL Server from&lt;br /&gt;
Microsoft web site. Don&#39;t forget to check out sql-server-performance.com&lt;br /&gt;
What are the steps you will take, if you are tasked with securing an&lt;br /&gt;
SQL Server?&lt;br /&gt;
Again this is another open-ended question. Here are some things you&lt;br /&gt;
could talk about: Preferring NT authentication, using server, database&lt;br /&gt;
and application roles to control access to the data, securing the&lt;br /&gt;
physical database files using NTFS permissions, using an unguessable&lt;br /&gt;
SA password, restricting physical access to the SQL Server, renaming&lt;br /&gt;
the Administrator account on the SQL Server computer, disabling the&lt;br /&gt;
Guest account, enabling auditing, using multiprotocol encryption,&lt;br /&gt;
setting up SSL, setting up firewalls, isolating SQL Server from the&lt;br /&gt;
web server etc.&lt;br /&gt;
Read the white paper on SQL Server security from Microsoft website.&lt;br /&gt;
Also check out My SQL Server security best practices&lt;br /&gt;
What is a deadlock and what is a live lock? How will you go about&lt;br /&gt;
resolving deadlocks?&lt;br /&gt;
Deadlock is a situation when two processes, each having a lock on one&lt;br /&gt;
piece of data, attempt to acquire a lock on the other&#39;s piece. Each&lt;br /&gt;
process would wait indefinitely for the other to release the lock,&lt;br /&gt;
unless one of the user processes is terminated. SQL Server detects&lt;br /&gt;
deadlocks and terminates one user&#39;s process.&lt;br /&gt;
A livelock is one, where a request for an exclusive lock is&lt;br /&gt;
repeatedly denied because a series of overlapping shared locks keeps&lt;br /&gt;
interfering. SQL Server detects the situation after four denials and&lt;br /&gt;
refuses further shared locks. A livelock also occurs when read&lt;br /&gt;
transactions monopolize a table or page, forcing a write transaction&lt;br /&gt;
to wait indefinitely.&lt;br /&gt;
Check out SET DEADLOCK_PRIORITY and &quot;Minimizing Deadlocks” in SQL&lt;br /&gt;
Server books online. Also check out the article Q169960 from Microsoft&lt;br /&gt;
knowledge base.&lt;br /&gt;
What is blocking and how would you troubleshoot it?&lt;br /&gt;
Blocking happens when one connection from an application holds a lock&lt;br /&gt;
and a second connection requires a conflicting lock type. This forces&lt;br /&gt;
the second connection to wait, blocked on the first.&lt;br /&gt;
Read up the following topics in SQL Server books online: Understanding&lt;br /&gt;
and avoiding blocking, coding efficient transactions.&lt;br /&gt;
Explain CREATE DATABASE syntax&lt;br /&gt;
Many of us are used to creating databases from the Enterprise Manager&lt;br /&gt;
or by just issuing the command: CREATE DATABAE MyDB. But what if you&lt;br /&gt;
have to create a database with two file groups, one on drive C and the&lt;br /&gt;
other on drive D with log on drive E with an initial size of 600 MB&lt;br /&gt;
and with a growth factor of 15%? That&#39;s why being a DBA you should be&lt;br /&gt;
familiar with the CREATE DATABASE syntax. Check out SQL Server books&lt;br /&gt;
online for more information.&lt;br /&gt;
How to restart SQL Server in single user mode? How to start SQL Server&lt;br /&gt;
in minimal configuration mode?&lt;br /&gt;
SQL Server can be started from command line, using the SQLSERVR.EXE.&lt;br /&gt;
This EXE has some very important parameters with which a DBA should be&lt;br /&gt;
familiar with. -m is used for starting SQL Server in single user mode&lt;br /&gt;
and -f is used to start the SQL Server in minimal configuration mode.&lt;br /&gt;
Check out SQL Server books online for more parameters and their&lt;br /&gt;
explanations.&lt;br /&gt;
As a part of your job, what are the DBCC commands that you commonly&lt;br /&gt;
use for database maintenance?&lt;br /&gt;
DBCC CHECKDB, DBCC CHECKTABLE, DBCC CHECKCATALOG, DBCC CHECKALLOC,&lt;br /&gt;
DBCC SHOWCONTIG, DBCC SHRINKDATABASE, DBCC SHRINKFILE etc. But there&lt;br /&gt;
are whole loads of DBCC commands, which are very useful for DBAs.&lt;br /&gt;
Check out SQL Server books online for more information.&lt;br /&gt;
What are statistics, under what circumstances they go out of date, how&lt;br /&gt;
do you update them?&lt;br /&gt;
Statistics determine the selectivity of the indexes. If an indexed&lt;br /&gt;
column has unique values then the selectivity of that index is more,&lt;br /&gt;
as opposed to an index with non-unique values. Query optimizer uses&lt;br /&gt;
these indexes in determining whether to choose an index or not while&lt;br /&gt;
executing a query.&lt;br /&gt;
Some situations under which you should update statistics:&lt;br /&gt;
1) If there is significant change in the key values in the index&lt;br /&gt;
2) If a large amount of data in an indexed column has been added,&lt;br /&gt;
changed, or removed (that is, if the distribution of key values has&lt;br /&gt;
changed), or the table has been truncated using the TRUNCATE TABLE&lt;br /&gt;
statement and then repopulated&lt;br /&gt;
3) Database is upgraded from a previous version&lt;br /&gt;
Look up SQL Server books online for the following commands: UPDATE&lt;br /&gt;
STATISTICS, STATS_DATE, DBCC SHOW_STATISTICS, CREATE STATISTICS, DROP&lt;br /&gt;
STATISTICS, sp_autostats, sp_createstats, sp_updatestats&lt;br /&gt;
What are the different ways of moving data/databases between servers&lt;br /&gt;
and databases in SQL Server?&lt;br /&gt;
There are lots of options available; you have to choose your option&lt;br /&gt;
depending upon your requirements. Some of the options you have are:&lt;br /&gt;
BACKUP/RESTORE, detaching and attaching databases, replication, DTS,&lt;br /&gt;
BCP, logshipping, INSERT...SELECT, SELECT...INTO, creating INSERT&lt;br /&gt;
scripts to generate data.&lt;br /&gt;
Explian different types of BACKUPs avaialabe in SQL Server? Given a&lt;br /&gt;
particular scenario, how would you go about choosing a backup plan?&lt;br /&gt;
Types of backups you can create in SQL Sever 7.0+ are Full database&lt;br /&gt;
backup, differential database backup, transaction log backup,&lt;br /&gt;
filegroup backup. Check out the BACKUP and RESTORE commands in SQL&lt;br /&gt;
Server books online. Be prepared to write the commands in your&lt;br /&gt;
interview. Books online also has information on detailed&lt;br /&gt;
backup/restore architecture and when one should go for a particular&lt;br /&gt;
kind of backup.&lt;br /&gt;
What is database replicaion? What are the different types of&lt;br /&gt;
replication you can set up in SQL Server?&lt;br /&gt;
Replication is the process of copying/moving data between databases on&lt;br /&gt;
the same or different servers. SQL Server supports the following types&lt;br /&gt;
of replication scenarios:&lt;br /&gt;
    * Snapshot replication&lt;br /&gt;
    * Transactional replication (with immediate updating subscribers,&lt;br /&gt;
with queued updating subscribers)&lt;br /&gt;
    * Merge replication&lt;br /&gt;
See SQL Server books online for indepth coverage on replication. Be&lt;br /&gt;
prepared to explain how different replication agents function, what&lt;br /&gt;
are the main system tables used in replication etc.&lt;br /&gt;
How to determine the service pack currently installed on SQL Server?&lt;br /&gt;
The global variable @@Version stores the build number of the&lt;br /&gt;
sqlservr.exe, which is used to determine the service pack installed.&lt;br /&gt;
To know more about this process visit SQL Server service packs and&lt;br /&gt;
versions.&lt;br /&gt;
Back to top&lt;br /&gt;
Database programming       (top)&lt;br /&gt;
What are cursors? Explain different types of cursors. What are the&lt;br /&gt;
disadvantages of cursors? How can you avoid cursors?&lt;br /&gt;
Cursors allow row-by-row processing of the result sets.&lt;br /&gt;
Types of cursors: Static, Dynamic, Forward-only, Keyset-driven. See&lt;br /&gt;
books online for more information.&lt;br /&gt;
Disadvantages of cursors: Each time you fetch a row from the cursor,&lt;br /&gt;
it results in a network roundtrip, where as a normal SELECT query&lt;br /&gt;
makes only one rowundtrip, however large the resultset is. Cursors are&lt;br /&gt;
also costly because they require more resources and temporary storage&lt;br /&gt;
(results in more IO operations). Further, there are restrictions on&lt;br /&gt;
the SELECT statements that can be used with some types of cursors.&lt;br /&gt;
Most of the times, set based operations can be used instead of&lt;br /&gt;
cursors. Here is an example:&lt;br /&gt;
If you have to give a flat hike to your employees using the following&lt;br /&gt;
criteria:&lt;br /&gt;
Salary between 30000 and 40000 -- 5000 hike&lt;br /&gt;
Salary between 40000 and 55000 -- 7000 hike&lt;br /&gt;
Salary between 55000 and 65000 -- 9000 hike&lt;br /&gt;
In this situation many developers tend to use a cursor, determine each&lt;br /&gt;
employee&#39;s salary and update his salary according to the above&lt;br /&gt;
formula. But the same can be achieved by multiple update statements or&lt;br /&gt;
can be combined in a single UPDATE statement as shown below:&lt;br /&gt;
UPDATE tbl_emp SET salary =&lt;br /&gt;
CASE WHEN salary BETWEEN 30000 AND 40000 THEN salary + 5000&lt;br /&gt;
WHEN salary BETWEEN 40000 AND 55000 THEN salary + 7000&lt;br /&gt;
WHEN salary BETWEEN 55000 AND 65000 THEN salary + 10000&lt;br /&gt;
END&lt;br /&gt;
Another situation in which developers tend to use cursors: You need to&lt;br /&gt;
call a stored procedure when a column in a particular row meets&lt;br /&gt;
certain condition. You don&#39;t have to use cursors for this. This can be&lt;br /&gt;
achieved using WHILE loop, as long as there is a unique key to&lt;br /&gt;
identify each row. For examples of using WHILE loop for row by row&lt;br /&gt;
processing, check out the &#39;My code library&#39; section of my site or&lt;br /&gt;
search for WHILE.&lt;br /&gt;
Write down the general syntax for a SELECT statements covering all the&lt;br /&gt;
options.&lt;br /&gt;
Here&#39;s the basic syntax: (Also checkout SELECT in books online for&lt;br /&gt;
advanced syntax).&lt;br /&gt;
SELECT select list&lt;br /&gt;
[INTO new table_]&lt;br /&gt;
FROM table source&lt;br /&gt;
[WHERE search condition]&lt;br /&gt;
[GROUP BY group_by__expression]&lt;br /&gt;
[HAVING search_condition]&lt;br /&gt;
[ORDER BY order__expression [ASC | DESC] ]&lt;br /&gt;
What is a join and explain different types of joins.&lt;br /&gt;
Joins are used in queries to explain how different tables are related.&lt;br /&gt;
Joins also let you select data from a table depending upon data from&lt;br /&gt;
another table.&lt;br /&gt;
Types of joins: INNER Joins, OUTER Joins, CROSS Joins. OUTER Joins are&lt;br /&gt;
further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL&lt;br /&gt;
OUTER JOINS.&lt;br /&gt;
For more information seepages from books online titled: &quot;Join&lt;br /&gt;
Fundamentals&quot; and &quot;Using Joins&quot;.&lt;br /&gt;
Can you have a nested transaction?&lt;br /&gt;
Yes, very much. Check out BEGIN TRAN, COMMIT, ROLLBACK, SAVE TRAN and&lt;br /&gt;
@@TRANCOUNT&lt;br /&gt;
What is an extended stored procedure? Can you instantiate a COM object&lt;br /&gt;
by using T-SQL?&lt;br /&gt;
An extended stored procedure is a function within a DLL (written in a&lt;br /&gt;
programming language like C, C++ using Open Data Services (ODS) API)&lt;br /&gt;
that can be called from T-SQL, just the way we call normal stored&lt;br /&gt;
procedures using the EXEC statement. See books online to learn how to&lt;br /&gt;
create extended stored procedures and how to add them to SQL Server.&lt;br /&gt;
Yes, you can instantiate a COM (written in languages like VB, VC++)&lt;br /&gt;
object from T-SQL by using sp_OACreate stored procedure. Also see&lt;br /&gt;
books online for sp_OAMethod, sp_OAGetProperty, sp_OASetProperty,&lt;br /&gt;
sp_OADestroy. For an example of creating a COM object in VB and&lt;br /&gt;
calling it from T-SQL, see &#39;My code library&#39; section of this site.&lt;br /&gt;
What is the system function to get the current user&#39;s user id?&lt;br /&gt;
USER_ID(). Also check out other system functions like USER_NAME(),&lt;br /&gt;
SYSTEM_USER, SESSION_USER, CURRENT_USER, USER, SUSER_SID(), HOST_NAME().&lt;br /&gt;
What are triggers? How many triggers you can have on a table? How to&lt;br /&gt;
invoke a trigger on demand?&lt;br /&gt;
Triggers are special kind of stored procedures that get executed&lt;br /&gt;
automatically when an INSERT, UPDATE or DELETE operation takes place&lt;br /&gt;
on a table.&lt;br /&gt;
In SQL Server 6.5 you could define only 3 triggers per table, one for&lt;br /&gt;
INSERT, one for UPDATE and one for DELETE. From SQL Server 7.0&lt;br /&gt;
onwards, this restriction is gone, and you could create multiple&lt;br /&gt;
triggers per each action. But in 7.0 there&#39;s no way to control the&lt;br /&gt;
order in which the triggers fire. In SQL Server 2000 you could specify&lt;br /&gt;
which trigger fires first or fires last using sp_settriggerorder&lt;br /&gt;
Triggers can&#39;t be invoked on demand. They get triggered only when an&lt;br /&gt;
associated action (INSERT, UPDATE, DELETE) happens on the table on&lt;br /&gt;
which they are defined.&lt;br /&gt;
Triggers are generally used to implement business rules, auditing.&lt;br /&gt;
Triggers can also be used to extend the referential integrity checks,&lt;br /&gt;
but wherever possible, use constraints for this purpose, instead of&lt;br /&gt;
triggers, as constraints are much faster.&lt;br /&gt;
Till SQL Server 7.0, triggers fire only after the data modification&lt;br /&gt;
operation happens. So in a way, they are called post triggers. But in&lt;br /&gt;
SQL Server 2000 you could create pre triggers also. Search SQL Server&lt;br /&gt;
2000 books online for INSTEAD OF triggers.&lt;br /&gt;
Also check out books online for &#39;inserted table&#39;, &#39;deleted table&#39; and&lt;br /&gt;
COLUMNS_UPDATED()&lt;br /&gt;
There is a trigger defined for INSERT operations on a table, in an&lt;br /&gt;
OLTP system. The trigger is written to instantiate a COM object and&lt;br /&gt;
pass the newly insterted rows to it for some custom processing. What&lt;br /&gt;
do you think of this implementation? Can this be implemented better?&lt;br /&gt;
Instantiating COM objects is a time consuming process and since you&lt;br /&gt;
are doing it from within a trigger, it slows down the data insertion&lt;br /&gt;
process. Same is the case with sending emails from triggers. This&lt;br /&gt;
scenario can be better implemented by logging all the necessary data&lt;br /&gt;
into a separate table, and have a job which periodically checks this&lt;br /&gt;
table and does the needful.&lt;br /&gt;
What is a self join? Explain it with an example.&lt;br /&gt;
Self join is just like any other join, except that two instances of&lt;br /&gt;
the same table will be joined in the query. Here is an example:&lt;br /&gt;
Employees table which contains rows for normal employees as well as&lt;br /&gt;
managers. So, to find out the managers of all the employees, you need&lt;br /&gt;
a self join.&lt;br /&gt;
CREATE TABLE emp&lt;br /&gt;
(&lt;br /&gt;
empid int,&lt;br /&gt;
mgrid int,&lt;br /&gt;
empname char(10)&lt;br /&gt;
)&lt;br /&gt;
INSERT emp SELECT 1,2,&#39;Vyas&#39;&lt;br /&gt;
INSERT emp SELECT 2,3,&#39;Mohan&#39;&lt;br /&gt;
INSERT emp SELECT 3,NULL,&#39;Shobha&#39;&lt;br /&gt;
INSERT emp SELECT 4,2,&#39;Shridhar&#39;&lt;br /&gt;
INSERT emp SELECT 5,2,&#39;Sourabh&#39;&lt;br /&gt;
SELECT t1.empname [Employee], t2.empname [Manager]&lt;br /&gt;
FROM emp t1, emp t2&lt;br /&gt;
WHERE t1.mgrid = t2.empid&lt;br /&gt;
Here&#39;s an advanced query using a LEFT OUTER JOIN that even returns the&lt;br /&gt;
employees without managers (super bosses)&lt;br /&gt;
SELECT t1.empname [Employee], COALESCE(t2.empname, &#39;No manager&#39;) [Manager]&lt;br /&gt;
FROM emp t1&lt;br /&gt;
LEFT OUTER JOIN&lt;br /&gt;
emp t2&lt;br /&gt;
ON&lt;br /&gt;
t1.mgrid = t2.empid&lt;br /&gt;
&lt;br /&gt;
The logic behind this &#39;last day of the month&#39; calculations is that you get the month part of a given date, add one to it, there by getting to the next month. Then subtract 1 day from the first of that month. This whole Thing can be written in one line and here it is: &lt;br /&gt;
&lt;br /&gt;
SELECT DAY(DATEADD(d, -DAY(DATEADD(m,1,GETDATE())),DATEADD(m,1,GETDATE())))&lt;br /&gt;
1. How do you start and stop MySQL on Windows? - net start MySQL, net stop MySQL &lt;br /&gt;
2. How do you start MySQL on Linux? - /etc/init.d/mysql start &lt;br /&gt;
3. Explain the difference between mysql and mysqli interfaces in PHP? - mysqli is the object-oriented version of mysql library functions. &lt;br /&gt;
4. What’s the default port for MySQL Server? - 3306 &lt;br /&gt;
5. What does tee command do in MySQL? - tee followed by a filename turns on MySQL logging to a specified file. It can be stopped by command notee. &lt;br /&gt;
6. Can you save your connection settings to a conf file? - Yes, and name it ~/.my.conf. You might want to change the permissions on the file to 600, so that it’s not readable by others. &lt;br /&gt;
7. How do you change a password for an existing user via mysqladmin? - mysqladmin -u root -p password &quot;newpassword&quot; &lt;br /&gt;
8. Use mysqldump to create a copy of the database? - mysqldump -h mysqlhost -u username -p mydatabasename &gt; dbdump.sql &lt;br /&gt;
9. Have you ever used MySQL Administrator and MySQL Query Browser? Describe the tasks you accomplished with these tools. &lt;br /&gt;
10. What are some good ideas regarding user security in MySQL? - There is no user without a password. There is no user without a user name. There is no user whose Host column contains % (which here indicates that the user can log in from anywhere in the network or the Internet). There are as few users as possible (in the ideal case only root) who have unrestricted access. &lt;br /&gt;
11. Explain the difference between MyISAM Static and MyISAM Dynamic. - In MyISAM static all the fields have fixed width. The Dynamic MyISAM table would include fields such as TEXT, BLOB, etc. to accommodate the data types with various lengths. MyISAM Static would be easier to restore in case of corruption, since even though you might lose some data, you know exactly where to look for the beginning of the next record. &lt;br /&gt;
12. What does myisamchk do? - It compressed the MyISAM tables, which reduces their disk usage. &lt;br /&gt;
13. Explain advantages of InnoDB over MyISAM? - Row-level locking, transactions, foreign key constraints and crash recovery. &lt;br /&gt;
14. Explain advantages of MyISAM over InnoDB? - Much more conservative approach to disk space management - each MyISAM table is stored in a separate file, which could be compressed then with myisamchk if needed. With InnoDB the tables are stored in tablespace, and not much further optimization is possible. All data except for TEXT and BLOB can occupy 8,000 bytes at most. No full text indexing is available for InnoDB. TRhe COUNT(*)s execute slower than in MyISAM due to tablespace complexity. &lt;br /&gt;
15. What are HEAP tables in MySQL? - HEAP tables are in-memory. They are usually used for high-speed temporary storage. No TEXT or BLOB fields are allowed within HEAP tables. You can only use the comparison operators = and &lt;=&gt;. HEAP tables do not support AUTO_INCREMENT. Indexes must be NOT NULL. &lt;br /&gt;
16. How do you control the max size of a HEAP table? - MySQL config variable max_heap_table_size. &lt;br /&gt;
17. What are CSV tables? - Those are the special tables, data for which is saved into comma-separated values files. They cannot be indexed. &lt;br /&gt;
18. Explain federated tables. - Introduced in MySQL 5.0, federated tables allow access to the tables located on other databases on other servers. &lt;br /&gt;
19. What is SERIAL data type in MySQL? - BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT &lt;br /&gt;
20. What happens when the column is set to AUTO INCREMENT and you reach the maximum value for that table? - It stops incrementing. It does not overflow to 0 to prevent data losses, but further inserts are going to produce an error, since the key has been used already. &lt;br /&gt;
21. Explain the difference between BOOL, TINYINT and BIT. - Prior to MySQL 5.0.3: those are all synonyms. After MySQL 5.0.3: BIT data type can store 8 bytes of data and should be used for binary data. &lt;br /&gt;
22. Explain the difference between FLOAT, DOUBLE and REAL. - FLOATs store floating point numbers with 8 place accuracy and take up 4 bytes. DOUBLEs store floating point numbers with 16 place accuracy and take up 8 bytes. REAL is a synonym of FLOAT for now. &lt;br /&gt;
23. If you specify the data type as DECIMAL (5,2), what’s the range of values that can go in this table? - 999.99 to -99.99. Note that with the negative number the minus sign is considered one of the digits. &lt;br /&gt;
24. What happens if a table has one column defined as TIMESTAMP? - That field gets the current timestamp whenever the row gets altered. &lt;br /&gt;
25. But what if you really want to store the timestamp data, such as the publication date of the article? - Create two columns of type TIMESTAMP and use the second one for your real data. &lt;br /&gt;
26. Explain data type TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP - The column exhibits the same behavior as a single timestamp column in a table with no other timestamp columns. &lt;br /&gt;
27. What does TIMESTAMP ON UPDATE CURRENT_TIMESTAMP data type do? - On initialization places a zero in that column, on future updates puts the current value of the timestamp in. &lt;br /&gt;
28. Explain TIMESTAMP DEFAULT ‘2006:09:02 17:38:44′ ON UPDATE CURRENT_TIMESTAMP. - A default value is used on initialization, a current timestamp is inserted on update of the row. &lt;br /&gt;
29. If I created a column with data type VARCHAR(3), what would I expect to see in MySQL table? - CHAR(3), since MySQL automatically adjusted the data type.</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/591827895206647207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/dba-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/591827895206647207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/591827895206647207'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/dba-questions.html' title='DBA Questions'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-8125194362183168203</id><published>2011-01-15T22:19:00.000+05:30</published><updated>2011-01-15T22:19:56.516+05:30</updated><title type='text'>OOPS Fundamental</title><content type='html'>Object Oriented Programming-Interview Questions &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
What is OOP? &lt;br /&gt;
The object oriented programming is commonly known as OOP. Most of the languages&lt;br /&gt;
are developed using OOP concept. Object-oriented programming (OOP) is a&lt;br /&gt;
programming concept that uses &quot;objects&quot; to develop a system.&lt;br /&gt;
A programming object has an ability to perform actions and has attributes. It&lt;br /&gt;
performs just like real world entities for e.g. a motor bike. A bike performs actions&lt;br /&gt;
such as ’Start’, ’Stop’ etc., and it has attributes like red color, 150 cc etc. So does&lt;br /&gt;
an Object. Actions and attributes are represented by Methods and fields or properties&lt;br /&gt;
respectively in programming language.&lt;br /&gt;
An object hides the implementation details and exposes only the functionalities and&lt;br /&gt;
parameters it requires to its client. Here also an object shares the same concept as&lt;br /&gt;
that of a bike. While driving a motor bike, we are unaware of its implementation&lt;br /&gt;
details such as how it is developed, internal working of gears etc.? We know only the&lt;br /&gt;
functions or actions it can perform.&lt;br /&gt;
What are the various elements of OOP? &lt;br /&gt;
Various elements of OOP are:&lt;br /&gt;
• Object&lt;br /&gt;
• Class&lt;br /&gt;
• Method&lt;br /&gt;
• Encapsulation&lt;br /&gt;
• Information Hiding&lt;br /&gt;
• Inheritance&lt;br /&gt;
• Polymorphism&lt;br /&gt;
Explain an object. &lt;br /&gt;
An object is an entity that keeps together state and behaviors. For instance, a car&lt;br /&gt;
encapsulates state such as red color, 900 cc etc and behaviors as ’Start’, ’Stop’ etc.,&lt;br /&gt;
so does an object.&lt;br /&gt;
An object is an instance of a class. If you consider Dog as a class, it will contain all&lt;br /&gt;
possible dog traits, while object German Shepherd contains characteristics of&lt;br /&gt;
specific type of dog.&lt;br /&gt;
Define a class. &lt;br /&gt;
A class represents description of objects that share same attributes and actions. It&lt;br /&gt;
defines the characteristics of the objects such as attributes and actions or behaviors.&lt;br /&gt;
It is the blue print that describes objects. &lt;br /&gt;
 &lt;br /&gt;
What is Method?  &lt;br /&gt;
 &lt;br /&gt;
Method is an objects behavior. If you consider Dog as an object then its behaviors&lt;br /&gt;
are bark, walk, run etc.&lt;br /&gt;
Explain Encapsulation concept in OOP. &lt;br /&gt;
Encapsulation means keeping actions and attributes together under a single unit.&lt;br /&gt;
This can also be understood using a motor bike example. A bike has actions such as&lt;br /&gt;
’switch on light’, ’horn’ etc. and attributes such specific color, size, weight etc. Here&lt;br /&gt;
the actions and attributes are bundled together under a single unit, bike.&lt;br /&gt;
In a programming language, methods and properties that correspond to actions and&lt;br /&gt;
attributes respectively are kept under a unit called object. The advantage of&lt;br /&gt;
encapsulation is that the implementation is not accessible to the client. The user has&lt;br /&gt;
to know only the functionality of encapsulated unit and information to be supplied to&lt;br /&gt;
get the result.&lt;br /&gt;
What is Information Hiding in OOP? &lt;br /&gt;
Information hiding concept restricts direct exposure of data. Data is accessed&lt;br /&gt;
indirectly using safe mechanism, methods in case of programming object. Taking&lt;br /&gt;
bike as an example, we have no access to the piston directly, we can use ’start&lt;br /&gt;
button’ to run the piston. You can understand the advantage of information hiding&lt;br /&gt;
concept from this example. If a bike manufacturer allows direct access to piston, it&lt;br /&gt;
would be very difficult to control actions on the piston.&lt;br /&gt;
Define Inheritance. &lt;br /&gt;
Inheritance concept in OOP allows us to create a new class using an existing one. It&lt;br /&gt;
also allows the new class to add its own functionality. This concept can also be&lt;br /&gt;
related to real world entity. A bike manufacturer uses same mechanism of existing&lt;br /&gt;
version of the bike while launching a new version with some added functionalities.&lt;br /&gt;
This allows him to save time and efforts.&lt;br /&gt;
Explain the term Polymorphism. &lt;br /&gt;
Polymorphism means the ability to take more than one form. An operation may&lt;br /&gt;
exhibit different behaviors in different instances. The behavior depends on the data&lt;br /&gt;
types used in the operation.&lt;br /&gt;
What is Overloading Polymorphism? &lt;br /&gt;
Overloading allows multiple functions to exist with same name but different&lt;br /&gt;
parameters. Again if you take bike as an example, it has a function Start with two&lt;br /&gt;
forms i.e. ’Auto Start’ and ’kick start’.&lt;br /&gt;
Explain Overriding Polymorphism. &lt;br /&gt;
Overriding means changing behavior of methods of base class in derive class by&lt;br /&gt;
overriding the base class methods. If class A is a base class with method ’calculate’&lt;br /&gt;
and class B inherits class A, thus derives method ’calculate’ of class A. The behavior&lt;br /&gt;
of ’calculate’ in class B can be changed by overriding it.&lt;br /&gt;
What are the advantages of OOP? &lt;br /&gt;
 &lt;br /&gt;
Following are the advantages of OOP: &lt;br /&gt;
 &lt;br /&gt;
• It presents a simple, clear and easy to maintain structure.&lt;br /&gt;
• It enhances program modularity since each object exists independently.&lt;br /&gt;
• New features can be easily added without disturbing the existing one.&lt;br /&gt;
• Objects can be reused in other program.</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/8125194362183168203/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/oops-fundamental.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/8125194362183168203'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/8125194362183168203'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/oops-fundamental.html' title='OOPS Fundamental'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6099378866206239797.post-8658472029227928322</id><published>2011-01-15T22:09:00.001+05:30</published><updated>2011-01-15T22:09:06.129+05:30</updated><title type='text'>Introduction Object and Class for C#</title><content type='html'>Introduction:&lt;br /&gt;
OOP stands for Object-Oriented Programming. OOP is relatively a new way to program computer applications. Before OOP programmers used to creating computer applications using procedural-programming (or structure-programming) but when OOP solved a lot of the problems of the procedural-programming so almost all of the programmers and developers began using OOP languages. In procedural- programming all the program functionality written in a few modules of code or maybe one module (depending on the program)and these modules depend on one another and maybe if you change a line of code you will have to rewrite the whole module again and maybe the whole program butin Object-Oriented Programming programmers write independent parts of a program called classes each class represent a part of the program functionality and these classes can be assembled to form a program and when you need to change some of the program functionality all what you have to do is to replace the target class which may contain a problem. So in OOP applications create by these of classes and these applications can contain any number of classes. That will get us to discuss the Class and Object concept.&lt;br /&gt;
Classes and objects:&lt;br /&gt;
You may find it not easy to understand the class and object story but I will try to do my best explaining it. Actually the class and object concept is related to each other and some beginners don’t care about understanding it clear so I think they will have a hard times learning C#.&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
Object-Oriented concept takes the most of its functionality from the real-life concepts. For example, I will discuss the concept of Classes and Objects of the world first and then you will understand the computer’s Classes and Objects before I even write anything about it.&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
World’s Classes and Objects:&lt;br /&gt;
In our world we have a classes and objects for those classes. Everything in our world considered to be an object. For example, people are objects, animals are objects too, minerals are objects, everything in the world are objects. Easy right ? but what about classes. In our world we have to differentiate between objects that we are living with. So we must understand that there are a classifications (this is how they get the name and the concepts of the Class) for all of those objects. For example, I ‘man object, David is object too, Maria is another object so we are from apeople class (or type). I have a dog called Ricky so it’s an object, Myfriend’s dog called Doby is also an object so they are from a Dogs class (ortype). A third example, I have a computer Pentium III this is object, My friend have a computer Pentium IIII so this is another object and they are froma Computers class (or type). Now I think you got the concept of theClass and Object but let me crystallize it for you. In our world we have classifications for objects and every object must be from some classification. So a Class is a way for describing some properties and functionalities or behaviors of a group of objects. In other words, The class considered to be template for some objects. So maybe I will create a class called person so thisis a template of the functionality and the properties of persons. I explained it by more than a way so wait until you see the first example and I think you will grasp it completely.&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
Computer’s Classes and Objects:&lt;br /&gt;
Computer’s Classes discussion is similar to what you grasp from the last section with some modifications to become computerized.&lt;br /&gt;
A C# Class Considered being the primary building block of the language. What I mean by the primary building block of the language is that every time you work with C# you will create Classes to form a program. We use Classes as a template to put the properties and functionalities or behaviors in one building block for some group of objects and after that we use that template to create the objects we need. For example, We need to have persons objects in our program so the first thing to do here is to create a Class called Person that contains all the functionalities or behaviors and properties of any person and after that we will use that Class or template to create as many objects as we need. Creating object of a specific class type called “instance of the class”. Don’t worry if you didn’t grasp it 100% and don’t worry if you don’t know what’s the Class and Object’s properties and functionalities or behaviors because we still in the beginning and until now I didn’t give any code examples. So let’s take a brief of what’s the Class and what’s an object?&lt;br /&gt;
The Class : Is a building block that contains the properties and functionalities that&lt;br /&gt;
describe some group of objects, We can create a class Person that contains:&lt;br /&gt;
1- The properties of any normal person on the earth like :Hair Color, Age, Height, Weight, Eyes Color.&lt;br /&gt;
2- The functionalities or behaviors of any normal person on the earth like : Drink water, Eat, Go to the work and later we will see how we can implement the functionalities or behaviors and properties.&lt;br /&gt;
There are 2 kinds of classes : The built-it classes that come with the .NET Framework and called Framework Class Library. And the programmer defined-classes which we create it.&lt;br /&gt;
The class contains data (in the form of variables and properties) and behaviors (in the form of methods to process these data). We will understand this concept more later in the article.&lt;br /&gt;
When we declare a variable in a class we call it member variables or instance variables. The name instance come from the fact that when we create an object we instance a class to create that object so instance of a class means object of that class and instance variable means variable that exists in that class.&lt;br /&gt;
The Object : It’s object of some classification (or class, or type. All means the same thing) and when you create the object you can specify the properties of that object. What I mean here is me as an object can have a different properties (Hair Color, Age, Height, Weight) of you as another object. For example, I have a brown eyes and you have a green eyes so when I create  2 objects I will specify a brown color for my object’s Eyes Color property and I will specify a green color for your object’s Eyes Color property.&lt;br /&gt;
So to complete my introduction to Classes we must discuss Properties and Variables.&lt;br /&gt;
Properties and Variables:&lt;br /&gt;
Variables declared in a class store the data for each instance, What that means ? means that when you instantiate this class (that is, When you create an object of this class) the object will allocate a memory locations to store the data of its variables. Let’s take an example to understand it well.&lt;br /&gt;
class Person&lt;br /&gt;
{&lt;br /&gt;
public int Age;&lt;br /&gt;
public string HairColor;&lt;br /&gt;
}&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
This is our simple class which contains 2 variables. Don’t worry about public keyword now because we will talk about it later . Now we will instantiate this class (that is, When you create an object of this class).&lt;br /&gt;
static void Main(string[]args)&lt;br /&gt;
{&lt;br /&gt;
Person Michael = newPerson();&lt;br /&gt;
Person Mary = new Person();&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
// Specify some values for the instance variables&lt;br /&gt;
Michael.Age = 20;&lt;br /&gt;
Michael.HairColor = “Brown”;&lt;br /&gt;
Mary.Age = 25;&lt;br /&gt;
Mary.HairColor = “Black”;&lt;br /&gt;
// print the console’s screen someof the variable’s values&lt;br /&gt;
Console.WriteLine(“Michael’s age = {0}, and Mary’s age= {1}”,Michael.Age,&lt;br /&gt;
Mary.Age);&lt;br /&gt;
Console.ReadLine();&lt;br /&gt;
}&lt;br /&gt;
So we begin our Main method by creating 2 objects of Person type. After creating the 2 objects we initialize the instance variables for object Michael and then for object Mary. Finally we print some values to the console. Here when you create Michael object C# compiler allocate a memory location for the 2 instance variables to put the values there. Also the same thing with Mary object the compiler will create 2 variables in the memory for Mary object. So each object now contains a different data. Note that we directly accessed the variables and we put any values we want, Right? So maybe someone doesn’t like me will put in my object’s variable Age value of 120 years so I will not get any kind of jobs. But wait there are a solution for this problem. We will use properties.&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
Properties:&lt;br /&gt;
Properties are a way to access the variables of the class in secure manner. Let’s see the same example using properties.&lt;br /&gt;
class Person&lt;br /&gt;
{&lt;br /&gt;
private int age;&lt;br /&gt;
private string hairColor;&lt;br /&gt;
public int Age&lt;br /&gt;
{&lt;br /&gt;
get&lt;br /&gt;
{&lt;br /&gt;
returnage;&lt;br /&gt;
}&lt;br /&gt;
set&lt;br /&gt;
{&lt;br /&gt;
if(value &lt;= 65 &amp;&amp; value &gt;= 18)&lt;br /&gt;
{&lt;br /&gt;
age = value;&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
age = 18;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
public string HairColor&lt;br /&gt;
{&lt;br /&gt;
get&lt;br /&gt;
{&lt;br /&gt;
return hairColor;&lt;br /&gt;
}&lt;br /&gt;
set&lt;br /&gt;
{&lt;br /&gt;
hairColor = value;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
I made some modifications but please just care about the new2 properties that I created it here. So the property consists of 2 access or. The get access or which is responsible of retrieving the variable value, And the set accessor which is responsible of modifying the variable’s value. So The get access or code is very simple we just use the keyword return with the variable name to return its value. so the following code:&lt;br /&gt;
get&lt;br /&gt;
{&lt;br /&gt;
return hairColor;&lt;br /&gt;
}&lt;br /&gt;
return the value stored in hairColor.&lt;br /&gt;
Note: the keyword value is a reserved keyword by C# (that is, reserved keywords means that these keywords own only by C# and you can’t create it for other purpose. For example, You can’t create a variable called value .If you did that C# compiler will generate an error and to make things easier Visual Studio.NET will color the reserved keywords to blue.)&lt;br /&gt;
Let’s put this code at work and after that discuss the set access or.&lt;br /&gt;
static void Main(string[]args)&lt;br /&gt;
{&lt;br /&gt;
Person Michael = newPerson();&lt;br /&gt;
Person Mary = new Person()&lt;br /&gt;
;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
// Specify some values for the instance variables&lt;br /&gt;
Michael.Age = 20;&lt;br /&gt;
Michael.HairColor = “Brown”;&lt;br /&gt;
Mary.Age = 25;&lt;br /&gt;
Mary.HairColor = “Black”;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
// print the console’s screen some of the variable’s values&lt;br /&gt;
Console.WriteLine(“Michael’s age = {0}, and Mary’s age= {1}”,Michael.Age,&lt;br /&gt;
Mary.Age);&lt;br /&gt;
Console.ReadLine();&lt;br /&gt;
}&lt;br /&gt;
Here I created the same objects from last example the modifications that I used only properties to access the variable instead of access it directly. Look at the following line of code&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
Michael.Age = 20;&lt;br /&gt;
When you assign a value to the property like that C# will use the set accessor. The great thing withthe set accessor is that we can controlthe assigned value and test it and maybe change to in some cases. When you assign a value to a property C# change the value in a variable and you can access the variable’s value using the reserved keyword value exactly as I did in the example. Let’s see it again here.&lt;br /&gt;
set&lt;br /&gt;
{&lt;br /&gt;
if(value &lt;= 65 &amp;&amp; value &gt;= 18)&lt;br /&gt;
{&lt;br /&gt;
age = value;&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
age = 18;&lt;br /&gt;
}&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
Here in the code I used if statement to test the assigned value because for some reason I want any object of type Person to be in age between 18 and 65. Here I test the value and if it in the range then simply I will store it in the variable age and it it’s not in the range I will put 18 as a value to age. It was just a simple example for the properties but there is a complete article about properties soon.&lt;br /&gt;
How we create objects and classes?&lt;br /&gt;
We create classes by define it like that:&lt;br /&gt;
using the keyword class followed by the class name like that&lt;br /&gt;
class Person&lt;br /&gt;
Then we open a left brace “{” and after we write our methods and properties we close it by a right brace “}”. That ‘show we create a class. Let’s see how we create an instance of that class.&lt;br /&gt;
In the same way as we declare a variable of type int we create an object variable of Person type with some modifications:&lt;br /&gt;
int age;&lt;br /&gt;
Person Michael = new Person();&lt;br /&gt;
In the first line of code we specified integer variable called age. In the second line we specified first the type of Object we need tocreate followed by the object’s name followed by a reserved operator called new and we end by typing the class name again followed byparenthesis “()”.&lt;br /&gt;
Let’s understand it step-by-step. Specifying the class nameat the beginning tell the C# Compiler to allocate a memory location for thattype (C# compiler knows all the variables and properties and methods of theclass so it will allocate the right amount of memory). Then we followed theclass name by out object variable name that we want it. The rest of the code”=new Person();” callthe object’s constructor. We will talk about constructor later but for nowunderstand that the constructor is a way to initialize your object’s variablewhile you are creating it not after you create it. For example, The Michaelobject we created it in the last section can be written as following : &lt;br /&gt;
Person Michael = new Person(20, “Brown”);&lt;br /&gt;
here I specified the variable’s values in the parameter listso I initialized the variables while I’m creating the object. But for this codeto work we will need to specify the constructor in the Person class and I willnot do that here because constructor section will come in later articles. Ithink you got a good introduction about Classes and Objects not I will completein in my next article and I will talk about constructors and building blockscoping. I hope you got a new thing from my article.</content><link rel='replies' type='application/atom+xml' href='http://bhaumik84.blogspot.com/feeds/8658472029227928322/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/introduction-object-and-class-for-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/8658472029227928322'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6099378866206239797/posts/default/8658472029227928322'/><link rel='alternate' type='text/html' href='http://bhaumik84.blogspot.com/2011/01/introduction-object-and-class-for-c.html' title='Introduction Object and Class for C#'/><author><name>Bhaumik.</name><uri>http://www.blogger.com/profile/16162057115381030794</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_haq8rHGFNGuRduvwkCpx-t1VUQR5mU0l7YSGG1LvD05Hp-4FybW8Yy5MJwUHKpn8tkvhOA7GZldkkloOeVTeN0zzKzZEHimMXD8smUTzsMM87PviuV5L6WHZU2mzVJ4/s113/Myself.jpg'/></author><thr:total>0</thr:total></entry></feed>