<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>SQLHELP</title>
	<atom:link href="https://sqlhelp.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://sqlhelp.wordpress.com</link>
	<description>Blog for SQL Server, Database Geek, SQL Tips, Microsoft SQL Server, TSQL, Storeprocedure, Query Tips, Data Science,</description>
	<lastBuildDate>Thu, 28 Apr 2016 07:22:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<site xmlns="com-wordpress:feed-additions:1">5672629</site><cloud domain='sqlhelp.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>https://secure.gravatar.com/blavatar/e458b1d3b049e90f3dfa1a0d4770243eb21cace29a6cfa735de7ab24a62e3439?s=96&#038;d=https%3A%2F%2Fs0.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>SQLHELP</title>
		<link>https://sqlhelp.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="https://sqlhelp.wordpress.com/osd.xml" title="SQLHELP" />
	<atom:link rel='hub' href='https://sqlhelp.wordpress.com/?pushpress=hub'/>
	<item>
		<title>Find Table Locked Session</title>
		<link>https://sqlhelp.wordpress.com/2016/04/28/find-table-locked-session/</link>
					<comments>https://sqlhelp.wordpress.com/2016/04/28/find-table-locked-session/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Thu, 28 Apr 2016 07:03:12 +0000</pubDate>
				<category><![CDATA[Find Table Locked Session]]></category>
		<category><![CDATA[Advance SQL tips and tricks]]></category>
		<category><![CDATA[blocking]]></category>
		<category><![CDATA[locking]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[Session Lock]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL server tips]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=514</guid>

					<description><![CDATA[Some time your table may locked by some session and you want to know that session and why i can not access my table? This mean your begain transaction is completed and insert/update/delete is runing but Comit transacion is yet be run OR you can create the situation by running the below query: BEGIN TRANSACTION [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Some time your table may locked by some session and you want to know that session and why i can not access my table?</p>
<p>This mean your begain transaction is completed and insert/update/delete is runing but Comit transacion is yet be run</p>
<blockquote><p>OR you can create the situation by running the below query:</p></blockquote>
<p><code><br />
BEGIN TRANSACTION<br />
DELETE * FROM Table1<br />
</code></p>
<blockquote><p>Below script will allow you to find which session is Locking your table:</p></blockquote>
<p><code>SELECT<br />
OBJECT_NAME(P.object_id) AS TableName,<br />
Resource_type,<br />
request_session_id<br />
FROM<br />
sys.dm_tran_locks L<br />
join sys.partitions P<br />
ON L.resource_associated_entity_id = p.hobt_id<br />
WHERE   OBJECT_NAME(P.object_id) = 'Table1'<br />
</code></p>
<blockquote><p>To release the Loking you can kill that session using below script:</p></blockquote>
<p><code>KILL 54</code></p>
<p>&nbsp;</p>
<blockquote><p>If you want to know in detail why, when and which session is locking then below script is useful:</p></blockquote>
<p><code><br />
SELECT<br />
blocking_session_id AS BlockingSessionID,<br />
session_id AS VictimSessionID,<br />
(SELECT [text] FROM sys.sysprocesses<br />
CROSS APPLY sys.dm_exec_sql_text([sql_handle])<br />
WHERE spid = blocking_session_id) AS BlockingQuery,<br />
[text] AS VictimQuery,<br />
wait_time/1000 AS WaitDurationSecond,<br />
wait_type AS WaitType,<br />
percent_complete AS BlockingQueryCompletePercent<br />
FROM sys.dm_exec_requests<br />
CROSS APPLY sys.dm_exec_sql_text([sql_handle])<br />
WHERE blocking_session_id &gt; 0<br />
</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2016/04/28/find-table-locked-session/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">514</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>IDENTITY_INSERT Scope level</title>
		<link>https://sqlhelp.wordpress.com/2015/02/26/identity_insert-scope-level/</link>
					<comments>https://sqlhelp.wordpress.com/2015/02/26/identity_insert-scope-level/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Thu, 26 Feb 2015 04:33:48 +0000</pubDate>
				<category><![CDATA[IDENTITY_INSERT Scope level]]></category>
		<category><![CDATA[Advance MSSQL tips]]></category>
		<category><![CDATA[Auto increment Value insert]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[DBA help]]></category>
		<category><![CDATA[IDENTITY_INSERT]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL tips]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Rowid insert]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=506</guid>

					<description><![CDATA[Some time we need to insert in the identity field also but what will be the impact if we want to Allow the  identity insert, see the below example: Create a Test Table : &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; CREATE TABLE sample( id int IDENTITY(1,1) ,name VARCHAR(100) ,address VARCHAR(100) ,phoneNo VARCHAR(15) ) In One Session, I am going to [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Some time we need to insert in the identity field also but what will be the impact if we want to Allow the  identity insert, see the below example:</p>
<p><strong>Create a Test Table :</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p><code>CREATE TABLE sample(<br />
id int IDENTITY(1,1)<br />
,name VARCHAR(100)<br />
,address VARCHAR(100)<br />
,phoneNo VARCHAR(15)<br />
)</code></p>
<p><strong>In One Session, I am going to Allow the Identity Insert</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p><code>SET IDENTITY_INSERT dbo.sample ON;</code></p>
<p><code>INSERT INTO sample(id,name,address,phoneNo)<br />
SELECT 10,'user-2','address-2','014002555-2'</code><br />
<code><br />
SELECT * FROM sample</code></p>
<p><strong>In another session i am going to insert normally without ID value: </strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
<code>INSERT INTO dbo.sample(name,address,phoneNo)<br />
SELECT 'user','address','014002555'<br />
</code></p>
<p><code>SELECT * FROM sample</code></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>So the Conclusion is <code>IDENTITY_INSERT</code> will be Enabled on Session Level only. You can insert with identity value from one session and another session will be working normally with auto identity value.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2015/02/26/identity_insert-scope-level/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">506</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>UPDATE with top clause</title>
		<link>https://sqlhelp.wordpress.com/2013/11/06/update-with-top-1/</link>
					<comments>https://sqlhelp.wordpress.com/2013/11/06/update-with-top-1/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Wed, 06 Nov 2013 07:25:09 +0000</pubDate>
				<category><![CDATA[UPDATE with top 1]]></category>
		<category><![CDATA[how to return updated rowid]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[update with top clause]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=498</guid>

					<description><![CDATA[If you want update a table with top clause see the below script: UPDATE top (1) TABLE1 SET status ='ready' where status ='hold' At the same time if you want to return the Row IDs of updated table: UPDATE top (1) TABLE1 SET status ='ready' OUTPUT INSERTED.rowid where status ='hold' &#8212;&#8212;&#8212;&#8212;&#8212;&#8212; result&#8212;&#8212;&#8212;&#8212;&#8212;- rowid 1 Same [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>If you want update a table with top clause see the below script:</strong></p>
<p><code>UPDATE top (1) TABLE1<br />
SET status ='ready'<br />
where status ='hold'</code></p>
<p><strong>At the same time if you want to return the Row IDs of updated table:</strong></p>
<p><code>UPDATE top (1) TABLE1<br />
SET status ='ready'<br />
OUTPUT INSERTED.rowid<br />
where status ='hold'</code></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; result&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
<code>rowid<br />
1</code></p>
<p><strong>Same thing if you want to store in variable</strong></p>
<p><code>DECLARE @UpdatedIds table (id int)<br />
DECLARE @rowId int</code></p>
<p><code><br />
UPDATE top (1) TABLE1<br />
SET status ='ready'<br />
OUTPUT INSERTED.rowid INTO @UpdatedIds<br />
where status ='hold'</code></p>
<p><code>SELECT @rowId=id FROM @UpdateIds<br />
SELECT @rowId</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2013/11/06/update-with-top-1/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">498</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>HTTP Get method from MSSQL</title>
		<link>https://sqlhelp.wordpress.com/2011/08/14/http-get-method-from-mssql/</link>
					<comments>https://sqlhelp.wordpress.com/2011/08/14/http-get-method-from-mssql/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Sun, 14 Aug 2011 11:25:39 +0000</pubDate>
				<category><![CDATA[HTTP Get method from MSSQL]]></category>
		<category><![CDATA[Advance MSSQL tips]]></category>
		<category><![CDATA[HTTP Method from SQL]]></category>
		<category><![CDATA[HTTP post]]></category>
		<category><![CDATA[Tips and tricks]]></category>
		<category><![CDATA[web api from MSSQL]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=486</guid>

					<description><![CDATA[If you want to call a URL and store the response of that url use this function: ALTER function [dbo].[GetHttp] ( @url varchar(8000) ) returns varchar(8000) as BEGIN DECLARE @win int DECLARE @hr  int DECLARE @text varchar(8000) EXEC @hr=sp_OACreate 'WinHttp.WinHttpRequest.5.1',@win OUT IF @hr &#60;&#62; 0 EXEC sp_OAGetErrorInfo @win EXEC @hr=sp_OAMethod @win, 'Open',NULL,'GET',@url,'false' IF @hr &#60;&#62; [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>If you want to call a URL and store the response of that url use this function</strong>:<br />
<code><br />
ALTER function [dbo].[GetHttp]<br />
(<br />
@url varchar(8000)<br />
)<br />
returns varchar(8000)<br />
as<br />
BEGIN<br />
DECLARE @win int<br />
DECLARE @hr  int<br />
DECLARE @text varchar(8000)</code></p>
<p><code>EXEC @hr=sp_OACreate 'WinHttp.WinHttpRequest.5.1',@win OUT<br />
IF @hr &lt;&gt; 0 EXEC sp_OAGetErrorInfo @win</code><br />
<code><br />
EXEC @hr=sp_OAMethod @win, 'Open',NULL,'GET',@url,'false'<br />
IF @hr &lt;&gt; 0 EXEC sp_OAGetErrorInfo @win</code></p>
<p><code>EXEC @hr=sp_OAMethod @win,'Send'<br />
IF @hr &lt;&gt; 0 EXEC sp_OAGetErrorInfo @win</code></p>
<p><code>EXEC @hr=sp_OAGetProperty @win,'ResponseText',@text OUTPUT<br />
IF @hr &lt;&gt; 0 EXEC sp_OAGetErrorInfo @win</code></p>
<p><code>EXEC @hr=sp_OADestroy @win<br />
IF @hr &lt;&gt; 0 EXEC sp_OAGetErrorInfo @win</code></p>
<p><code>RETURN @text</code></p>
<p><code><br />
END</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2011/08/14/http-get-method-from-mssql/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">486</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Http Post from MSSQL</title>
		<link>https://sqlhelp.wordpress.com/2011/08/14/http-post-from-mssql/</link>
					<comments>https://sqlhelp.wordpress.com/2011/08/14/http-post-from-mssql/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Sun, 14 Aug 2011 11:21:27 +0000</pubDate>
				<category><![CDATA[Http Post from MSSQL]]></category>
		<category><![CDATA[Advance MSSQL tips]]></category>
		<category><![CDATA[HTTP post using MSSQL]]></category>
		<category><![CDATA[MSSQL HTTP Post]]></category>
		<category><![CDATA[Tips and tricks]]></category>
		<category><![CDATA[web api from MSSQL]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=484</guid>

					<description><![CDATA[Call the HTTP post using MSSQL script : ALTER function [dbo].[POSTHttp] ( @url varchar(8000), @data varchar(2000) ) returns varchar(8000) as BEGIN DECLARE @win int DECLARE @hr  int DECLARE @text varchar(8000) EXEC @hr=sp_OACreate 'WinHttp.WinHttpRequest.5.1',@win OUT IF @hr &#60;&#62; 0 EXEC sp_OAGetErrorInfo @win EXEC @hr=sp_OAMethod @win, 'Open',NULL,'POST',@url,'false' IF @hr &#60;&#62; 0 EXEC sp_OAGetErrorInfo @win EXEC @hr=sp_OAMethod @win, [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong> Call the HTTP post using MSSQL script :<br />
</strong></p>
<p><strong><br />
</strong></p>
<p><code>ALTER function [dbo].[POSTHttp]<br />
(<br />
@url varchar(8000),<br />
@data varchar(2000)<br />
)<br />
returns varchar(8000)<br />
as</code></p>
<p><code>BEGIN<br />
DECLARE @win int<br />
DECLARE @hr  int<br />
DECLARE @text varchar(8000)</code><br />
<code><br />
EXEC @hr=sp_OACreate 'WinHttp.WinHttpRequest.5.1',@win OUT<br />
IF @hr &lt;&gt; 0 EXEC sp_OAGetErrorInfo @win</code></p>
<p><code>EXEC @hr=sp_OAMethod @win, 'Open',NULL,'POST',@url,'false'<br />
IF @hr &lt;&gt; 0 EXEC sp_OAGetErrorInfo @win</code></p>
<p><code>EXEC @hr=sp_OAMethod @win, 'setRequestHeader',NULL, 'Content-type'<br />
, 'application/x-www-form-urlencoded'<br />
IF @hr &lt;&gt; 0 EXEC sp_OAGetErrorInfo @win</code></p>
<p><code>EXEC @hr=sp_OAMethod @win,'Send',null,@data<br />
IF @hr &lt;&gt; 0 EXEC sp_OAGetErrorInfo @win</code></p>
<p><code>EXEC @hr=sp_OAGetProperty @win,'ResponseText',@text OUTPUT<br />
IF @hr &lt;&gt; 0 EXEC sp_OAGetErrorInfo @win</code></p>
<p><code>EXEC @hr=sp_OAGetProperty @win,'ResponseText',@text OUTPUT<br />
IF @hr &lt;&gt; 0 EXEC sp_OAGetErrorInfo @win</code></p>
<p><code>EXEC @hr=sp_OADestroy @win<br />
IF @hr &lt;&gt; 0 EXEC sp_OAGetErrorInfo @win<br />
</code><br />
<code>RETURN @text</code></p>
<p><code>END</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2011/08/14/http-post-from-mssql/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">484</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>CTE  Function</title>
		<link>https://sqlhelp.wordpress.com/2011/05/06/cte-function/</link>
					<comments>https://sqlhelp.wordpress.com/2011/05/06/cte-function/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Fri, 06 May 2011 13:34:17 +0000</pubDate>
				<category><![CDATA[CTE Function]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=479</guid>

					<description><![CDATA[CTE fucntion can be used on this way: IF OBJECT_ID('tempdb..#dataList') IS NOT NULL DROP TABLE #dataList CREATE TABLE #dataList( id            INT ,name        VARCHAR(50) ,parent        INT ,ip            INT ) INSERT #dataList SELECT 1    id, 'Group1'        Name, 0 Parent, 0 ip UNION ALL SELECT 2    id, 'SubGroup1'        Name, 1 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>CTE fucntion can be used on this way:</strong></p>
<p><code>IF OBJECT_ID('tempdb..#dataList') IS NOT NULL<br />
DROP TABLE #dataList<br />
</code></p>
<p><code>CREATE TABLE #dataList(<br />
id            INT<br />
,name        VARCHAR(50)<br />
,parent        INT<br />
,ip            INT<br />
)</code></p>
<p><code><br />
INSERT #dataList<br />
SELECT 1    id, 'Group1'        Name, 0 Parent, 0 ip UNION ALL<br />
SELECT 2    id, 'SubGroup1'        Name, 1 Parent, 0 ip UNION ALL<br />
SELECT 3    id, 'Item1'            Name, 2 Parent, 1 ip UNION ALL<br />
SELECT 4    id, 'Item2'            Name, 2 Parent, 1 ip UNION ALL<br />
SELECT 5    id, 'Item3'            Name, 2 Parent, 1 ip UNION ALL<br />
SELECT 6    id, 'Item4'            Name, 2 Parent, 1 ip UNION ALL<br />
SELECT 7    id, 'SubGroup2'        Name, 1 Parent, 0 ip UNION ALL<br />
SELECT 8    id, 'Item5'            Name, 7 Parent, 1 ip UNION ALL<br />
SELECT 9    id, 'Item6'            Name, 7 Parent, 1 ip UNION ALL<br />
SELECT 10    id, 'Item7'            Name, 7 Parent, 1 ip UNION ALL<br />
SELECT 11    id, 'Item8'            Name, 7 Parent, 1 ip<br />
</code></p>
<p><code>--SELECT * FROM #dataList<br />
</code></p>
<p><code><br />
DECLARE @id INT = 1<br />
;WITH CTE(id, name, parent, ip)<br />
AS<br />
(<br />
SELECT * FROM #dataList WHERE id = @id<br />
UNION ALL<br />
SELECT d.* FROM #dataList D<br />
INNER JOIN CTE c ON d.parent = c.id<br />
)</code></p>
<p><code>SELECT * FROM CTE WHERE ip = 1 ORDER BY id ASC;</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2011/05/06/cte-function/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">479</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Dynamic PIVOT</title>
		<link>https://sqlhelp.wordpress.com/2011/02/14/dynamic-pivot/</link>
					<comments>https://sqlhelp.wordpress.com/2011/02/14/dynamic-pivot/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Mon, 14 Feb 2011 11:52:48 +0000</pubDate>
				<category><![CDATA[Dynamic PIVOT]]></category>
		<category><![CDATA[Complex Cross Tab Result]]></category>
		<category><![CDATA[Customer and Loan Result from Cross Tab PIVOT]]></category>
		<category><![CDATA[Loan report]]></category>
		<category><![CDATA[MSSQL PIVOT]]></category>
		<category><![CDATA[PIVOT Query]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=465</guid>

					<description><![CDATA[Sample for Dynamic PIVOT Query: Some time we need complex cross tab result for report, that time we can use the PIVOT Query, for example we have 3 Tables and we have data like this : IF OBJECT_ID('tempdb..#customer') IS NOT NULL DROP TABLE #customer CREATE TABLE #customer ( CustomerId INT, CustomerName VARCHAR(50) ) INSERT #customer [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Sample for Dynamic PIVOT Query:</strong></p>
<p>Some time we need complex cross tab result for report, that time we can use the PIVOT Query, for example we have 3 Tables and we have data like this :</p>
<p><code><br />
IF OBJECT_ID('tempdb..#customer') IS NOT NULL<br />
DROP  TABLE #customer</code></p>
<p><code>CREATE TABLE #customer (<br />
CustomerId  INT,<br />
CustomerName VARCHAR(50)<br />
)<br />
</code><br />
<code><br />
INSERT #customer<br />
SELECT 1,  'Ram'<br />
INSERT #customer<br />
SELECT 2, 'Hari'<br />
INSERT #customer<br />
SELECT 3,  'Depesh'<br />
INSERT #customer<br />
SELECT 4, 'Sailesh'</code></p>
<p><code>--Select * from  #customer</code></p>
<p><a href="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image31.jpg"><br />
<img data-attachment-id="471" data-permalink="https://sqlhelp.wordpress.com/2011/02/14/dynamic-pivot/image3-2/" data-orig-file="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image31.jpg" data-orig-size="244,145" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="image3" data-image-description="" data-image-caption="" data-medium-file="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image31.jpg?w=244" data-large-file="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image31.jpg?w=244" class="alignnone size-full wp-image-471" title="image3" src="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image31.jpg?w=468" alt=""   srcset="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image31.jpg 244w, https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image31.jpg?w=150&amp;h=89 150w" sizes="(max-width: 244px) 100vw, 244px" /><br />
</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p><code>IF OBJECT_ID('tempdb..#LoanType') IS NOT NULL<br />
DROP TABLE  #LoanType</code></p>
<p><code>CREATE TABLE #LoanType (<br />
LoanId INT,<br />
LoanName  VARCHAR(50)<br />
)</code><br />
<code><br />
INSERT #LoanType<br />
SELECT 1, 'Loan-1'<br />
INSERT  #LoanType<br />
SELECT 2, 'Loan-2'<br />
INSERT #LoanType<br />
SELECT 3,  'Loan-3'<br />
INSERT #LoanType<br />
SELECT 4, 'Loan-4'<br />
INSERT #LoanType<br />
SELECT  5, 'Loan-5'<br />
INSERT #LoanType<br />
SELECT 6, 'Loan-6'</code></p>
<p><code>--Select * from  #LoanType</code></p>
<p><a href="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image21.jpg"><br />
<img title="image2" src="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image21.jpg?w=169&#038;h=181" alt="" width="169" height="181" /></a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><code>IF  OBJECT_ID('tempdb..#LoanCustomer') IS NOT NULL<br />
DROP TABLE  #LoanCustomer</code></p>
<p><code><br />
CREATE TABLE #LoanCustomer (<br />
CustomerId INT,<br />
LoanId  INT,<br />
Amount MONEY<br />
)<br />
</code><br />
<code><br />
INSERT #LoanCustomer<br />
SELECT 1, 1,  500<br />
INSERT #LoanCustomer<br />
SELECT 2, 1, 5300<br />
INSERT  #LoanCustomer<br />
SELECT 3, 3, 1500<br />
INSERT #LoanCustomer<br />
SELECT 2, 1,  2500<br />
INSERT #LoanCustomer<br />
SELECT 1, 6, 5500<br />
INSERT  #LoanCustomer<br />
SELECT 2, 4, 1100<br />
INSERT #LoanCustomer<br />
SELECT 2, 3,  3200<br />
INSERT #LoanCustomer<br />
SELECT 2, 3, 3200<br />
</code></p>
<p><code>--Select * from  #LoanCustomer</code></p>
<p><a href="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image1.jpg"><br />
<img title="image1" src="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image1.jpg?w=253&#038;h=217" alt="" width="253" height="217" /></a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p><strong>Combine Result of three table from PIVOT Query:</strong></p>
<p><code><br />
DECLARE<br />
@sql  VARCHAR(MAX)<br />
,@LoanType VARCHAR(MAX)</code><br />
<code><br />
SELECT<br />
@LoanType =  ISNULL(@LoanType + ', ', '') + '[' + LoanName + ']'<br />
FROM  (<br />
SELECT<br />
DISTINCT<br />
l.LoanName<br />
FROM #LoanCustomer lc<br />
INNER JOIN  #LoanType l ON lc.LoanId = l.LoanId<br />
) x<br />
</code></p>
<p><code><br />
SET @sql =  '<br />
SELECT<br />
CustomerName<br />
,' + @LoanType +<br />
Sample for Dynamic PIVOT</code></p>
<p><code><br />
FROM  (<br />
SELECT<br />
c.CustomerName,<br />
l.LoanName,<br />
lc.Amount<br />
FROM #LoanCustomer  lc<br />
INNER JOIN #customer c ON lc.CustomerId = c.CustomerId<br />
INNER JOIN  #LoanType l ON l.LoanId = lc.LoanId<br />
)  dataList<br />
PIVOT<br />
(<br />
SUM(Amount)<br />
FOR LoanName IN(' + @LoanType+ ')<br />
)  X '</code><br />
<code><br />
EXEC (@sql)<br />
</code></p>
<p><a href="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image21.jpg"></a><a href="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image31.jpg"></a><a href="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/result1.jpg"></a></p>
<p><a href="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/result1.jpg"><img data-attachment-id="472" data-permalink="https://sqlhelp.wordpress.com/2011/02/14/dynamic-pivot/result-2/" data-orig-file="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/result1.jpg" data-orig-size="373,157" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="result" data-image-description="" data-image-caption="" data-medium-file="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/result1.jpg?w=300" data-large-file="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/result1.jpg?w=373" class="alignnone size-medium wp-image-472" title="result" src="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/result1.jpg?w=300&#038;h=126" alt="" width="300" height="126" srcset="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/result1.jpg?w=300 300w, https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/result1.jpg?w=150 150w, https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/result1.jpg 373w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p><a href="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/result1.jpg"><br />
</a><a href="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/all.jpg"><img data-attachment-id="477" data-permalink="https://sqlhelp.wordpress.com/2011/02/14/dynamic-pivot/all/" data-orig-file="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/all.jpg" data-orig-size="958,622" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="all" data-image-description="" data-image-caption="" data-medium-file="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/all.jpg?w=300" data-large-file="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/all.jpg?w=468" class="alignnone size-medium wp-image-477" title="all" src="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/all.jpg?w=300&#038;h=194" alt="" width="300" height="194" srcset="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/all.jpg?w=300 300w, https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/all.jpg?w=600 600w, https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/all.jpg?w=150 150w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>&nbsp;</p>
<p><strong>This Script is Prepared by Netra Prasad Acharya (MSSQL Developer)</strong></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2011/02/14/dynamic-pivot/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">465</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>

		<media:content url="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image31.jpg" medium="image">
			<media:title type="html">image3</media:title>
		</media:content>

		<media:content url="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image21.jpg" medium="image">
			<media:title type="html">image2</media:title>
		</media:content>

		<media:content url="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/image1.jpg" medium="image">
			<media:title type="html">image1</media:title>
		</media:content>

		<media:content url="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/result1.jpg?w=300" medium="image">
			<media:title type="html">result</media:title>
		</media:content>

		<media:content url="https://sqlhelp.wordpress.com/wp-content/uploads/2011/02/all.jpg?w=300" medium="image">
			<media:title type="html">all</media:title>
		</media:content>
	</item>
		<item>
		<title>MSSQL Hash Algorithms</title>
		<link>https://sqlhelp.wordpress.com/2010/12/21/hash-algorithms/</link>
					<comments>https://sqlhelp.wordpress.com/2010/12/21/hash-algorithms/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Tue, 21 Dec 2010 09:14:27 +0000</pubDate>
				<category><![CDATA[Hash Algorithms]]></category>
		<category><![CDATA[MD5]]></category>
		<category><![CDATA[MSSQL encrypt]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=459</guid>

					<description><![CDATA[MSSQL Hash Algorithms: There are two forms of encryption algorithms: one-way and two-way. Two-way algorithms allow you to encrypt and decrypt data. One-way algorithms will only encrypt data without any ability to decrypt. A hash algorithm is the simplest way to encrypt data, however, once encrypted, you can&#8217;t decrypt the data. Your data remains secure, [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4>MSSQL Hash Algorithms:</h4>
<p>There are two forms of  encryption algorithms: one-way and two-way. Two-way algorithms allow you to  encrypt and decrypt data. One-way algorithms will only encrypt data without any  ability to decrypt.</p>
<p>A hash algorithm is the simplest way  to encrypt data, however, once encrypted, you can&#8217;t decrypt the data. Your data  remains secure, ensuring that in order to &#8220;decrypt&#8221; the contents of a column you  would first have to know the original data value.</p>
<p><code>--Different hash algorithms produce different hash values<br />
DECLARE @TEST_VAL varchar(100)<br />
SELECT @TEST_VAL = 'SQL Server'<br />
SELECT HashBytes('MD5', @TEST_VAL)<br />
SELECT @TEST_VAL = 'SQL Server'<br />
SELECT HashBytes('SHA1', @TEST_VAL)<br />
GO</code></p>
<p><code>--Hash values are case sensitive<br />
DECLARE @TEST_VAL varchar(100)<br />
SELECT @TEST_VAL = 'sql'<br />
SELECT HashBytes('SHA1', @TEST_VAL)<br />
SELECT @TEST_VAL = 'SQL'<br />
SELECT HashBytes('SHA1', @TEST_VAL)<br />
GO</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2010/12/21/hash-algorithms/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">459</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>SUBSTRING  Function</title>
		<link>https://sqlhelp.wordpress.com/2010/12/02/substring-function/</link>
					<comments>https://sqlhelp.wordpress.com/2010/12/02/substring-function/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Thu, 02 Dec 2010 09:42:25 +0000</pubDate>
				<category><![CDATA[SUBSTRING Function]]></category>
		<category><![CDATA[CHARINDEX]]></category>
		<category><![CDATA[REPLACE Functions of MSSQL.]]></category>
		<category><![CDATA[See the Uses of SUBSTRING]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=454</guid>

					<description><![CDATA[See the Uses of SUBSTRING, CHARINDEX, REPLACE Functions in MSSQL. SELECT '3/6/2010' as OLD_FORMAT, charindex('/','3/6/2010',1) [FIRST/POSITION], charindex('/','3/6/2010',3) [2nd/POSITION], replace( SUBSTRING ('3/6/2010', charindex('/','3/6/2010',1), 2),'/','') as MM, replace(left('3/6/2010',2),'/','') as DD, right('3/6/2010',4) as YYYY, replace( SUBSTRING ('3/6/2010', charindex('/','3/6/2010',1), 2),'/','')+'/'+ replace(left('3/6/2010',2),'/','')+'/'+ right('3/6/2010',4) as NEW_FORMAT Example to convert date  dd/mm/yyyy to mm/dd/yyyy]]></description>
										<content:encoded><![CDATA[<p>See the Uses of SUBSTRING, CHARINDEX, REPLACE Functions in MSSQL.</p>
<p><code><br />
SELECT<br />
'3/6/2010' as OLD_FORMAT,<br />
charindex('/','3/6/2010',1) [FIRST/POSITION],<br />
charindex('/','3/6/2010',3)  [2nd/POSITION],<br />
replace( SUBSTRING ('3/6/2010', charindex('/','3/6/2010',1), 2),'/','') as MM,<br />
replace(left('3/6/2010',2),'/','') as DD,<br />
right('3/6/2010',4) as YYYY,</code></p>
<p><code>replace( SUBSTRING ('3/6/2010', charindex('/','3/6/2010',1), 2),'/','')+'/'+<br />
replace(left('3/6/2010',2),'/','')+'/'+<br />
right('3/6/2010',4) as NEW_FORMAT</code></p>
<p>Example to convert date  dd/mm/yyyy to mm/dd/yyyy</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2010/12/02/substring-function/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">454</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Short Cut key and formatting</title>
		<link>https://sqlhelp.wordpress.com/2010/07/10/short-cut-key/</link>
					<comments>https://sqlhelp.wordpress.com/2010/07/10/short-cut-key/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Sat, 10 Jul 2010 06:06:09 +0000</pubDate>
				<category><![CDATA[Short Cut key]]></category>
		<category><![CDATA[MSSQL Management Studio]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[tricks]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=444</guid>

					<description><![CDATA[MSSQL Short Cut key for query Editors: Some easy short cut key for MSSQL Management studio or Query Editor: CTRL + f1 = sp_help CTRL + 1 = sp_who CTRL + 2 = sp_lock CTRL + R = Show/Hide Result Window CTRL + E = Execute the SQL statement CTRL + L = Execute with [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>MSSQL Short Cut key for query Editors:<br />
</strong><br />
Some easy short cut key for MSSQL Management studio or Query Editor:<strong><br />
</strong></p>
<p>CTRL + f1 = sp_help<br />
CTRL + 1 = sp_who<br />
CTRL + 2 = sp_lock</p>
<p>CTRL + R = Show/Hide Result Window<br />
CTRL + E = Execute the SQL statement<br />
CTRL + L = Execute with Execuation plan<br />
CTRL + G = GOTO line number<br />
CTRL + F = find<br />
CTRL + H = find and replace</p>
<p>CTRL + SHIFT + U = Convert to Upper Case<br />
CTRL + SHIFT + L = Convert to Lower Case</p>
<p>If you want to change the style of your query text editor in MSSQL Management studio:</p>
<p>Go to the following menu:</p>
<p><em>TOOLS  ==&gt; OPTIONS == &gt; ENVIRONMENT == &gt; FONTS AND COLORS</em></p>
<p><em><a href="https://sqlhelp.wordpress.com/wp-content/uploads/2010/07/formatting.png"><img loading="lazy" data-attachment-id="448" data-permalink="https://sqlhelp.wordpress.com/2010/07/10/short-cut-key/formatting/" data-orig-file="https://sqlhelp.wordpress.com/wp-content/uploads/2010/07/formatting.png" data-orig-size="764,441" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="formatting" data-image-description="" data-image-caption="" data-medium-file="https://sqlhelp.wordpress.com/wp-content/uploads/2010/07/formatting.png?w=300" data-large-file="https://sqlhelp.wordpress.com/wp-content/uploads/2010/07/formatting.png?w=468" class="alignnone size-medium wp-image-448" style="border:1px solid black;margin:2px;" title="formatting" src="https://sqlhelp.wordpress.com/wp-content/uploads/2010/07/formatting.png?w=300&#038;h=173" alt="MSSQL Formatting Window" width="300" height="173" srcset="https://sqlhelp.wordpress.com/wp-content/uploads/2010/07/formatting.png?w=300 300w, https://sqlhelp.wordpress.com/wp-content/uploads/2010/07/formatting.png?w=600 600w, https://sqlhelp.wordpress.com/wp-content/uploads/2010/07/formatting.png?w=150 150w" sizes="(max-width: 300px) 100vw, 300px" /></a></em></p>
<p><em> </em></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2010/07/10/short-cut-key/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">444</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>

		<media:content url="https://sqlhelp.wordpress.com/wp-content/uploads/2010/07/formatting.png?w=300" medium="image">
			<media:title type="html">formatting</media:title>
		</media:content>
	</item>
		<item>
		<title>MSSQL Backup to Map Drive</title>
		<link>https://sqlhelp.wordpress.com/2010/06/20/mssql-backup-to-map-drive/</link>
					<comments>https://sqlhelp.wordpress.com/2010/06/20/mssql-backup-to-map-drive/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Sun, 20 Jun 2010 13:44:56 +0000</pubDate>
				<category><![CDATA[MSSQL Backup to Map Drive]]></category>
		<category><![CDATA[Backup to network drive]]></category>
		<category><![CDATA[Login to network PC]]></category>
		<category><![CDATA[MSSQL Backup]]></category>
		<category><![CDATA[MSSQL help]]></category>
		<category><![CDATA[MSSQL tips]]></category>
		<category><![CDATA[tricks]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=434</guid>

					<description><![CDATA[MSSQL Backup to Map Drive: if you want to backup a SQL Server database to a mapped drive use the following script 1) First it will create Map Drive in Local PC 2) Backup the Database. 3) Delete the Map Drive, so that next time the same script can use again. EXEC master..xp_cmdshell 'net use [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>MSSQL Backup to Map Drive:</strong></p>
<p>if you want to backup a SQL Server database to a mapped drive use the following script<br />
1) First it will create Map Drive in Local PC<br />
2) Backup the Database.<br />
3) Delete the Map Drive, so that next time the same script can use again.</p>
<p><code>EXEC master..xp_cmdshell 'net use z: "\\192.168.1.93\share" password /user:user1'<br />
GO</code></p>
<p><code>BACKUP DATABASE DB1<br />
to disk='z:\db1.bak' with init<br />
GO<br />
</code><br />
<code>EXEC master..xp_cmdshell 'net use z: /delete'<br />
GO</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2010/06/20/mssql-backup-to-map-drive/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">434</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>MSSQL MAX, MIN from the column data</title>
		<link>https://sqlhelp.wordpress.com/2010/05/12/mssql-max-min-from-the-column-data/</link>
					<comments>https://sqlhelp.wordpress.com/2010/05/12/mssql-max-min-from-the-column-data/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Wed, 12 May 2010 06:14:38 +0000</pubDate>
				<category><![CDATA[MIN from the column data]]></category>
		<category><![CDATA[How to compare and find the MAX]]></category>
		<category><![CDATA[MAX User Fucntion]]></category>
		<category><![CDATA[MIN]]></category>
		<category><![CDATA[MSSQL MAX]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=406</guid>

					<description><![CDATA[How to compare and find the MAX, MIN from the column data? Some time we want to find the MAX, MIN form our own data or Colunm data On that case MSSQL dose not have system function to do it but here is the solution to do it. See the example to find Max value: [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>How to compare and find the MAX, MIN from the column data?<br />
</strong>Some time we want to find the MAX, MIN form our own data or Colunm data On that case MSSQL dose not have system function to do it but here is the solution to do it.<strong> </strong></p>
<p><strong>See the example to find Max value:</strong><br />
<code><br />
-- select dbo.FuncGetMax(123,5,null,null,null)</code><br />
<code><br />
ALTER FUNCTION [dbo].[FuncGetMax] (@str float, @str1 float, @str2 float, @str3 float,@str4 float)<br />
RETURNS float<br />
BEGIN</code></p>
<p><code>Declare @result int</code></p>
<p><code>-- First compare</code><br />
<code>if @str &gt; @str1<br />
set @result=@str<br />
else<br />
set @result=@str1</code></p>
<p><code>-- 2nd compare</code><br />
<code>if @str2 is null OR @result &gt; @str2<br />
set @result=@result<br />
else<br />
set @result=@str2</code></p>
<p><code>-- 3rd compare</code><br />
<code>if @str3 is null OR @result &gt; @str3<br />
set @result=@result<br />
else<br />
set @result=@str3</code></p>
<p><code>-- 4th compare</code><br />
<code>if @str4 is null OR @result &gt; @str4<br />
set @result=@result<br />
else<br />
set @result=@str4</code></p>
<p><code>return @result</code><br />
<code><br />
end</code></p>
<p><strong>See the example to find MIN value:</strong></p>
<p><code><br />
-- select dbo.FuncGetMIN(123,5,null,null,null)</code></p>
<p><code>Alter FUNCTION [dbo].FuncGetMIN(@str float, @str1 float, @str2 float, @str3 float,@str4 float)<br />
RETURNS float<br />
BEGIN</code></p>
<p><code>Declare @result int</code></p>
<p><code>-- First compare</code><br />
<code>if @str &lt; @str1<br />
set @result=@str<br />
else<br />
set @result=@str1</code></p>
<p><code>-- 2nd compare</code><br />
<code>if @str2 is null OR @result &lt; @str2<br />
set @result=@result<br />
else<br />
set @result=@str2</code><br />
<code><br />
-- 3rd compare</code><br />
<code>if @str3 is null OR @result &lt; @str3<br />
set @result=@result<br />
else<br />
set @result=@str3</code></p>
<p><code>-- 4th compare</code><br />
<code>if @str4 is null OR @result &lt; @str4<br />
set @result=@result<br />
else<br />
set @result=@str4</code><br />
<code><br />
return @result</code></p>
<p><code>end</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2010/05/12/mssql-max-min-from-the-column-data/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">406</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>MSSQL Cross-Tab Query</title>
		<link>https://sqlhelp.wordpress.com/2010/05/09/mssql-cross-tab-query/</link>
					<comments>https://sqlhelp.wordpress.com/2010/05/09/mssql-cross-tab-query/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Sun, 09 May 2010 11:09:04 +0000</pubDate>
				<category><![CDATA[MSSQL Cross-Tab Query]]></category>
		<category><![CDATA[PIVOT Example]]></category>
		<category><![CDATA[Cross-Tab Query]]></category>
		<category><![CDATA[MSSQL Resources]]></category>
		<category><![CDATA[MSSQL Server help]]></category>
		<category><![CDATA[MSSQL tips]]></category>
		<category><![CDATA[MSSQL tricks]]></category>
		<category><![CDATA[PIVOT in MSSQL]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[SQL script]]></category>
		<category><![CDATA[T-SQL PIVOT]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=420</guid>

					<description><![CDATA[Example Script for MSSQL Cross-Tab Query Create table #Table ( yearofJoining int, EmpId int, Deptid int ) GO insert into #Table select 1990,1,1 insert into #Table select 1991,2,2 insert into #Table select 1990,3,4 insert into #Table select 1991,4,2 insert into #Table select 1990,5,1 insert into #Table select 1990,6,3 insert into #Table select 1992,7,3 insert into [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Example Script for MSSQL Cross-Tab Query</strong></p>
<p><code>Create table #Table<br />
(<br />
yearofJoining int,<br />
EmpId int,<br />
Deptid int<br />
)<br />
GO</code></p>
<p><code><br />
insert into #Table select 1990,1,1<br />
insert into #Table select 1991,2,2<br />
insert into #Table select 1990,3,4<br />
insert into #Table select 1991,4,2<br />
insert into #Table select 1990,5,1<br />
insert into #Table select 1990,6,3<br />
insert into #Table select 1992,7,3<br />
insert into #Table select 1990,8,4<br />
insert into #Table select 1993,9,1<br />
insert into #Table select 1994,10,2<br />
insert into #Table select 1990,11,3<br />
insert into #Table select 1995,12,3<br />
insert into #Table select 1995,14,3<br />
insert into #Table select 1995,15,3<br />
insert into #Table select 1995,16,6<br />
GO</code></p>
<p><code>--Original Cross Tab query</code><br />
<code>select YearofJoining,<br />
count(case [DeptId] when 1 then 1 else null end) as [Department-1],<br />
count(case [DeptId] when 2 then 1 else null end) as [Department-2],<br />
count(case [DeptId] when 3 then 1 else null end) as [Department-3]<br />
from #Table where deptid in(1,2,3)<br />
group by Yearofjoining</code></p>
<p><strong>Out put:</strong></p>
<p><code>YearofJoining  Department-1  Department-2  Department-3<br />
-------------  ------------  ------------  ------------<br />
1990   2             0             2<br />
1991   0             2             0<br />
1992   0             0             1<br />
1993   1             0             0<br />
1994   0             1             0<br />
1995   0             0             3</code></p>
<p><strong>PIVOT Example:</strong></p>
<p><code><br />
SELECT YearofJoining, [1] as [Department-1],[2] as [Department-2],<br />
[3] as [Department-3] FROM<br />
(SELECT YearOfJoining,Deptid from #Table) p<br />
PIVOT<br />
( Count(DeptId) for DEPTID in ([1],[2],[3]))<br />
AS pvt<br />
ORDER BY Yearofjoining</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2010/05/09/mssql-cross-tab-query/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">420</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>MSSQL Group by and Sum</title>
		<link>https://sqlhelp.wordpress.com/2010/04/09/mssql-group-by-and-sum/</link>
					<comments>https://sqlhelp.wordpress.com/2010/04/09/mssql-group-by-and-sum/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Fri, 09 Apr 2010 10:53:33 +0000</pubDate>
				<category><![CDATA[MSSQL Group by and Sum]]></category>
		<category><![CDATA[Group by and Sum in T-SQL]]></category>
		<category><![CDATA[MSQL tips]]></category>
		<category><![CDATA[SQL book]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[SQL scripts]]></category>
		<category><![CDATA[Sum Example]]></category>
		<category><![CDATA[T-SQL Sum function]]></category>
		<category><![CDATA[tricks]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=415</guid>

					<description><![CDATA[Here are some example for MSQL SUM function and GROUP BY: USE AdventureWorks; GO SELECT Color, SUM(ListPrice), SUM(StandardCost) FROM Production.Product WHERE Color IS NOT NULL AND ListPrice != 0.00 AND Name LIKE 'Mountain%' GROUP BY Color ORDER BY Color; GO Alternate way. USE AdventureWorks ; GO SELECT Color, ListPrice, StandardCost FROM Production.Product WHERE Color IS [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Here are some example for MSQL SUM function and GROUP BY:</strong></p>
<p><code><br />
USE AdventureWorks;<br />
GO<br />
SELECT Color, SUM(ListPrice), SUM(StandardCost)<br />
FROM Production.Product<br />
WHERE Color IS NOT NULL<br />
AND ListPrice != 0.00<br />
AND Name LIKE 'Mountain%'<br />
GROUP BY Color<br />
ORDER BY Color;<br />
GO<br />
</code></p>
<p><strong>Alternate way.</strong></p>
<p><code>USE AdventureWorks ;<br />
GO<br />
SELECT Color, ListPrice, StandardCost<br />
FROM Production.Product<br />
WHERE Color IS NOT NULL<br />
AND ListPrice != 0.00<br />
AND Name LIKE 'Mountain%'<br />
ORDER BY Color<br />
COMPUTE SUM(ListPrice), SUM(StandardCost) BY Color;<br />
GO</code></p>
<p><strong>Other Example:</strong></p>
<p><code>USE AdventureWorks;<br />
GO<br />
SELECT Color, SUM(ListPrice), SUM(StandardCost)<br />
FROM Production.Product<br />
GROUP BY Color<br />
ORDER BY Color;<br />
GO<br />
</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2010/04/09/mssql-group-by-and-sum/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">415</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>MSSQL Case</title>
		<link>https://sqlhelp.wordpress.com/2010/03/09/mssql-case/</link>
					<comments>https://sqlhelp.wordpress.com/2010/03/09/mssql-case/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Tue, 09 Mar 2010 10:47:00 +0000</pubDate>
				<category><![CDATA[MSSQL Case]]></category>
		<category><![CDATA[Case T-SQL]]></category>
		<category><![CDATA[Case when in SQL]]></category>
		<category><![CDATA[MSQL help]]></category>
		<category><![CDATA[MSSQL tips]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=412</guid>

					<description><![CDATA[Here are some example of MSSQL Cases: USE AdventureWorks; GO SELECT ProductNumber, Category = CASE ProductLine WHEN 'R' THEN 'Road' WHEN 'M' THEN 'Mountain' WHEN 'T' THEN 'Touring' WHEN 'S' THEN 'Other sale items' ELSE 'Not for sale' END, Name FROM Production.Product ORDER BY ProductNumber; GO Other way: USE AdventureWorks; GO SELECT ProductNumber, Name, 'Price [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Here are some example of MSSQL Cases:</strong></p>
<p><code>USE AdventureWorks;<br />
GO<br />
SELECT   ProductNumber, Category =<br />
CASE ProductLine<br />
WHEN 'R' THEN 'Road'<br />
WHEN 'M' THEN 'Mountain'<br />
WHEN 'T' THEN 'Touring'<br />
WHEN 'S' THEN 'Other sale items'<br />
ELSE 'Not for sale'<br />
END,<br />
Name<br />
FROM Production.Product<br />
ORDER BY ProductNumber;<br />
GO</code></p>
<p><strong>Other way:</strong></p>
<p><code>USE AdventureWorks;<br />
GO<br />
SELECT   ProductNumber, Name, 'Price Range' =<br />
CASE<br />
WHEN ListPrice =  0 THEN 'Mfg item - not for resale'<br />
WHEN ListPrice &lt; 50 THEN 'Under $50'          WHEN ListPrice &gt;= 50 and ListPrice &lt; 250 THEN 'Under $250'          WHEN ListPrice &gt;= 250 and ListPrice &lt; 1000 THEN 'Under $1000'<br />
ELSE 'Over $1000'<br />
END<br />
FROM Production.Product<br />
ORDER BY ProductNumber ;<br />
GO</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2010/03/09/mssql-case/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">412</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>MSSQL EXISTS and IF EXISTS</title>
		<link>https://sqlhelp.wordpress.com/2010/03/01/mssql-exists/</link>
					<comments>https://sqlhelp.wordpress.com/2010/03/01/mssql-exists/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Mon, 01 Mar 2010 11:20:52 +0000</pubDate>
				<category><![CDATA[MSSQL EXISTS]]></category>
		<category><![CDATA[If Exists]]></category>
		<category><![CDATA[MSQL tricks]]></category>
		<category><![CDATA[MSSQL help]]></category>
		<category><![CDATA[MSSQL Resources]]></category>
		<category><![CDATA[MSSQL tips]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=425</guid>

					<description><![CDATA[Using NULL in a subquery to still return a result set: USE AdventureWorks ; GO SELECT DepartmentID, Name FROM HumanResources.Department WHERE EXISTS (SELECT NULL) ORDER BY Name ASC ; Comparing queries by using EXISTS and IN USE AdventureWorks ; GO SELECT a.FirstName, a.LastName FROM Person.Contact AS a WHERE EXISTS (SELECT * FROM HumanResources.Employee AS b [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Using NULL in a subquery to still return a result set:</strong></p>
<p><code>USE AdventureWorks ;<br />
GO<br />
SELECT DepartmentID, Name<br />
FROM HumanResources.Department<br />
WHERE EXISTS (SELECT NULL)<br />
ORDER BY Name ASC ;<br />
</code></p>
<p><strong>Comparing queries by using EXISTS and IN</strong></p>
<p><code>USE AdventureWorks ;<br />
GO<br />
SELECT a.FirstName, a.LastName<br />
FROM Person.Contact AS a<br />
WHERE EXISTS<br />
(SELECT *<br />
FROM HumanResources.Employee AS b<br />
WHERE a.ContactId = b.ContactID<br />
AND a.LastName = 'Johnson');<br />
GO</code></p>
<p><strong>Usage of IN :</strong></p>
<p><code>USE AdventureWorks ;<br />
GO<br />
SELECT a.FirstName, a.LastName<br />
FROM Person.Contact AS a<br />
WHERE a.LastName IN<br />
(SELECT a.LastName<br />
FROM HumanResources.Employee AS b<br />
WHERE a.ContactId = b.ContactID<br />
AND a.LastName = 'Johnson');<br />
GO</code></p>
<p><strong>Comparing queries by using EXISTS and = ANY</strong></p>
<p><code><br />
USE AdventureWorks ;<br />
GO<br />
SELECT DISTINCT s.Name<br />
FROM Sales.Store s<br />
WHERE EXISTS<br />
(SELECT *<br />
FROM Purchasing.Vendor v<br />
WHERE s.Name = v.Name) ;<br />
GO<br />
</code></p>
<p><strong>Usage of ANY:</strong></p>
<p><code>USE AdventureWorks ;<br />
GO<br />
SELECT DISTINCT s.Name<br />
FROM Sales.Store s<br />
WHERE s.Name = ANY<br />
(SELECT v.Name<br />
FROM Purchasing.Vendor v ) ;<br />
GO<br />
</code></p>
<p><strong>Comparing queries by using EXISTS and IN</strong></p>
<p><code>USE AdventureWorks;<br />
GO<br />
SELECT c.FirstName, c.LastName, e.Title<br />
FROM Person.Contact c JOIN HumanResources.Employee e<br />
ON e.ContactID = c.ContactID WHERE EXISTS<br />
(SELECT *<br />
FROM HumanResources.Department d<br />
WHERE e.DepartmentID = d.DepartmentID<br />
AND d.Name LIKE 'P%');<br />
GO<br />
</code></p>
<p><strong>Usage of IN :</strong></p>
<p><code>USE AdventureWorks;<br />
GO<br />
SELECT c.FirstName, c.LastName, e.Title<br />
FROM Person.Contact c JOIN HumanResources.Employee e<br />
ON e.ContactID = c.ContactID WHERE DepartmentID IN<br />
(SELECT DepartmentID<br />
FROM HumanResources.Department<br />
WHERE Name LIKE 'P%');<br />
GO</code></p>
<p><strong>Using NOT EXISTS</strong></p>
<p><code>USE AdventureWorks;<br />
GO<br />
SELECT c.FirstName, c.LastName, e.Title<br />
FROM Person.Contact c JOIN HumanResources.Employee e<br />
ON e.ContactID = c.ContactID WHERE NOT EXISTS<br />
(SELECT *<br />
FROM HumanResources.Department d<br />
WHERE e.DepartmentID = d.DepartmentID<br />
AND d.Name LIKE 'P%')<br />
ORDER BY LastName, FirstName<br />
GO</code></p>
<p><strong>Advance Usage of Exists</strong></p>
<p><code>If exists(<br />
SELECT id FROM Table1 where price &gt; = 1000<br />
)<br />
begin</code><br />
<code> SELECT  '&gt;= than 10000' as MSG<br />
print '&gt; than 10000'  -- OR you can print as out put<br />
return;</code><br />
<code><br />
end</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2010/03/01/mssql-exists/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">425</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>MSSQL Joins</title>
		<link>https://sqlhelp.wordpress.com/2010/02/09/mssql-joins/</link>
					<comments>https://sqlhelp.wordpress.com/2010/02/09/mssql-joins/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Tue, 09 Feb 2010 10:38:52 +0000</pubDate>
				<category><![CDATA[MSSQL Joins]]></category>
		<category><![CDATA[Inner join]]></category>
		<category><![CDATA[left join]]></category>
		<category><![CDATA[outer join]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=410</guid>

					<description><![CDATA[Here are some Example of SQL Joins --The basic JOIN statement -- JOIN: SELECT Customer.CustomerID, TransID, TransAmt FROM Customer JOIN Transaction ON Customer.CustomerID = Transaction.CustomerID; -- similar: SELECT Customer.CustomerID, TransID, TransAmt FROM Customer, Transaction; where Customer.CustomerID = Transaction.CustomerID; -- INNER JOIN SELECT CustomerName, TransDate FROM Customer INNER JOIN Transaction ON Customer.CustomerID = Transaction.CustomerID; -- LEFT [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Here are some Example of SQL Joins</strong></p>
<p><code><br />
--The basic JOIN statement<br />
-- JOIN:<br />
SELECT Customer.CustomerID, TransID, TransAmt<br />
FROM Customer JOIN Transaction<br />
ON Customer.CustomerID = Transaction.CustomerID;</code><br />
<code><br />
-- similar:<br />
SELECT Customer.CustomerID, TransID, TransAmt<br />
FROM Customer, Transaction;<br />
where Customer.CustomerID = Transaction.CustomerID;</code></p>
<p><code>-- INNER JOIN<br />
SELECT CustomerName, TransDate<br />
FROM Customer INNER JOIN Transaction<br />
ON Customer.CustomerID = Transaction.CustomerID;</code></p>
<p><code>-- LEFT OUTER JOIN<br />
SELECT CustomerName, TransDate, TransAmt<br />
FROM Customer LEFT OUTER JOIN Transaction<br />
ON Customer.CustomerID = Transaction.CustomerID;</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2010/02/09/mssql-joins/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">410</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Temp Tables in MSSQL Database</title>
		<link>https://sqlhelp.wordpress.com/2010/01/28/temp-tables-in-mssql-database/</link>
					<comments>https://sqlhelp.wordpress.com/2010/01/28/temp-tables-in-mssql-database/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Thu, 28 Jan 2010 08:23:51 +0000</pubDate>
				<category><![CDATA[Temp Tables]]></category>
		<category><![CDATA[##table]]></category>
		<category><![CDATA[@tables]]></category>
		<category><![CDATA[Global Temporary Tables]]></category>
		<category><![CDATA[Local Temporary Tables]]></category>
		<category><![CDATA[MSSQL tables]]></category>
		<category><![CDATA[scopes of temp table]]></category>
		<category><![CDATA[tables variable]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=395</guid>

					<description><![CDATA[Different types of temp Tables in Exists in MSSQL Database: 1) # TABLE (Local Temporary Tables) This types of temp table is created and populated on disk, in the system database tempdb — with a session-specific identifier packed onto the name. CREATE TABLE #TABLE ( rowid INT, fname VARCHAR(200) ) 2) ##TABLES  (Global Temporary Tables) [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Different types of temp Tables in Exists in MSSQL Database:</p>
<p><strong>1) </strong><strong># TABLE (Local Temporary Tables)</strong></p>
<p>This types of temp table is created and populated on disk, in the system database tempdb — with a session-specific identifier packed onto the name.</p>
<p><code>CREATE TABLE #TABLE<br />
(<br />
rowid INT,<br />
fname VARCHAR(200)<br />
)</code></p>
<p><strong>2) ##TABLES  (Global Temporary Tables</strong>)</p>
<p>This types of Global temporary tables operate much like local temporary tables; they are created in tempdb and cause less locking and logging than permanent tables. However, they are visible to all sessions, until the creating session goes out of scope (and the global ##temp table is no longer being referenced by other sessions)</p>
<p>If the session is running and other session try to create the Global Temp Table than second session will get a error.<br />
&#8220;There is already an object named ##TABLE in database. &#8221;</p>
<p><code>CREATE TABLE ##TABLE<br />
(<br />
rowid INT,<br />
fname VARCHAR(200)<br />
)</code></p>
<p><strong>3) @TABLES (</strong><strong>Table Variables )</strong></p>
<p>This types of table variable is created in memory, and so performs slightly better than #temp tables ( less locking and logging in a table variable). A table variable might still perform I/O to tempdb (which is where the performance issues of #temp tables make themselves apparent), though the documentation is not very explicit about this.</p>
<p><code>DECLARE @table TABLE<br />
(<br />
rowid INT,<br />
fname VARCHAR(200)<br />
)<br />
</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2010/01/28/temp-tables-in-mssql-database/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">395</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>How to pass parameters dynamically</title>
		<link>https://sqlhelp.wordpress.com/2009/11/15/how-pass-parameters-dynamically/</link>
					<comments>https://sqlhelp.wordpress.com/2009/11/15/how-pass-parameters-dynamically/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Sun, 15 Nov 2009 12:51:33 +0000</pubDate>
				<category><![CDATA[Parameters dynamically]]></category>
		<category><![CDATA[Best way to call procedure]]></category>
		<category><![CDATA[COALESCE]]></category>
		<category><![CDATA[How pass parameters dynamically]]></category>
		<category><![CDATA[MSQL tips]]></category>
		<category><![CDATA[Optional parameter in SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=387</guid>

					<description><![CDATA[How to pass parameters dynamically? MS-SQL has many features to call the procedure from other application and from SQL itself, See the example. Some time you need optional parameter in Procedure then assign null as default so that it will not ask you compulsory. CREATE PROCEDURE dbo.TESTPROCEDURE @param1 VARCHAR(32) = NULL, @param2 INT = NULL [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>How to pass parameters dynamically</strong>?<br />
MS-SQL has many features to call the procedure from other application and from SQL itself, See the example.<br />
Some time you need optional parameter in Procedure then assign null as default so that it will not ask you compulsory.</p>
<p><code>CREATE PROCEDURE dbo.TESTPROCEDURE<br />
@param1 VARCHAR(32) = NULL,<br />
@param2 INT = NULL<br />
AS<br />
BEGIN<br />
SET NOCOUNT ON </code></p>
<p><code>SELECT Param1 = COALESCE<br />
(<br />
@param1,<br />
'@param1 was Blank'<br />
)</code></p>
<p><code>SELECT Param2 = COALESCE<br />
(<br />
RTRIM(@param2),<br />
'@param2 was Blank'<br />
)<br />
END<br />
GO</code></p>
<p><code>EXEC dbo.TESTPROCEDURE @param1='HELLO', @param2=1<br />
EXEC dbo.TESTPROCEDURE @param1='HELLO'<br />
EXEC dbo.TESTPROCEDURE @param2=1<br />
EXEC dbo.TESTPROCEDURE 'HELLO',1<br />
EXEC dbo.TESTPROCEDURE 'HELLO</code></p>
<blockquote><p>There are so many way to get the result from procedure, Choose any of them which you like.</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/11/15/how-pass-parameters-dynamically/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">387</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Table Row in String</title>
		<link>https://sqlhelp.wordpress.com/2009/10/29/table-row-in-string/</link>
					<comments>https://sqlhelp.wordpress.com/2009/10/29/table-row-in-string/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Thu, 29 Oct 2009 11:58:42 +0000</pubDate>
				<category><![CDATA[Table Row in String]]></category>
		<category><![CDATA[COALESCE]]></category>
		<category><![CDATA[How to create a row data as string.]]></category>
		<category><![CDATA[MSSQL tisp]]></category>
		<category><![CDATA[MSSQL tricks]]></category>
		<category><![CDATA[Multiple value in single String]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[String creation]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=377</guid>

					<description><![CDATA[How to create the row data as string. If you have table row data and you need to show all the records in a single string, use the following query. DATA: -------------------- Name RAM SHYAM HARI RITA RESULT: --------------------- Name RAM,SHYAM,HARI,RITA Use the following query ------------------------------------ DECLARE @strList varchar(100) SELECT @strList = COALESCE(@strList + ', [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>How to create the row data as string.</strong></p>
<p>If you have table row data and you need to show all the records in a single string, use the following query.</p>
<pre><strong>DATA:</strong>
--------------------
<code>Name
RAM
SHYAM
HARI
RITA</code>

<strong>RESULT</strong>:
---------------------
<code>Name
RAM,SHYAM,HARI,RITA</code>

Use the following query
------------------------------------
<code>DECLARE @strList varchar(100)
SELECT @strList = COALESCE(@strList + ', ', '') +
 CAST(Name AS varchar(5))
FROM TABLE1

SELECT @strList</code></pre>
<p>There are complex example in internet but you can use this simple query to get this solutions. No need to use complex cursor to get such result.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/10/29/table-row-in-string/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">377</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>How to parametrize OPENQUERY in MSSQL</title>
		<link>https://sqlhelp.wordpress.com/2009/10/07/how-to-parametrize-openquery-in-mssql/</link>
					<comments>https://sqlhelp.wordpress.com/2009/10/07/how-to-parametrize-openquery-in-mssql/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Wed, 07 Oct 2009 07:17:19 +0000</pubDate>
				<category><![CDATA[Parametrize OPENQUERY]]></category>
		<category><![CDATA[How to parametrize OPENQUERY in MSSQL]]></category>
		<category><![CDATA[Linked server]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL tricks]]></category>
		<category><![CDATA[OPENQUERY]]></category>
		<category><![CDATA[parametrize query]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=373</guid>

					<description><![CDATA[How to parametrize OPENQUERY in MSSQL: MSSQL has good feature of linked server between two different Database in same location or in remote location. OPENQUERY helps you to execute your query in Linked server (remote) . In linked server you can directly execute your query without OPENQUERY but the performance will be a issue. As [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>How to parametrize OPENQUERY in MSSQL:</strong></p>
<p>MSSQL has good feature of linked server between two different Database in same location or in remote location.<br />
OPENQUERY helps you to execute your query in Linked server (remote) .</p>
<p>In linked server you can directly execute your query without OPENQUERY but the performance will be a issue.</p>
<p>As per my experience OPENQUERY is best way to access the linked servers.</p>
<p><strong>If you want to pass your variable in OPENQUERY than it is so simple. Use the following way to pass your variable in OPENQUERY. </strong></p>
<p><strong><br />
</strong></p>
<p><code>DECLARE @strDate VARCHAR(10)<br />
DECLARE @strSql VARCHAR(8000)<br />
DECLARE @strLinked VARCHAR(8000)</code></p>
<p><code>SET @strDate= '2009-01-01'</code></p>
<p><code>SET @strSsql= 'SELECT * FROM TABLE1 WHERE TRN_DATE =' + '''' + '''' + @strDate+ '''' + ''''</code></p>
<p><code>SET @strLinked= 'SELECT * FROM OPENQUERY(MYLINKEDSERVER,' + '''' + @strSql+ '''' + ')'</code></p>
<p><code>--############ Print and see your script</code><br />
<code>PRINT @strLinked</code></p>
<p><code>--############ Final Execution</code><br />
<code>EXEC(@strLinked)</code></p>
<p><strong>As per MSDN:</strong></p>
<p>Executes the specified pass-through query on the specified linked server. This server is an OLE DB data source. OPENQUERY can be referenced in the FROM clause of a query as if it were a table name. OPENQUERY can also be referenced as the target table of an INSERT, UPDATE, or DELETE statement. This is subject to the capabilities of the OLE DB provider. Although the query may return multiple result sets, OPENQUERY returns only the first one.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/10/07/how-to-parametrize-openquery-in-mssql/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">373</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>How to find date name in MSSQL</title>
		<link>https://sqlhelp.wordpress.com/2009/08/10/how-to-find-date-name/</link>
					<comments>https://sqlhelp.wordpress.com/2009/08/10/how-to-find-date-name/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Mon, 10 Aug 2009 09:46:08 +0000</pubDate>
				<category><![CDATA[How to find Date Name]]></category>
		<category><![CDATA[datename]]></category>
		<category><![CDATA[dateName function in SQL]]></category>
		<category><![CDATA[dw]]></category>
		<category><![CDATA[getdate(0]]></category>
		<category><![CDATA[How to find Date Name in MSSQL]]></category>
		<category><![CDATA[how to return date name in SQL]]></category>
		<category><![CDATA[how to return dayname in SQL]]></category>
		<category><![CDATA[how to return weekday in SQL]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=367</guid>

					<description><![CDATA[How to find Date Name in MSSQL: if you want to return a weekday or date name of particular date then it is so simple in MSSQL. See the example: select DATENAME(dw , getDate()) This query returns today&#8217;s date name like Sunday, Monday etc. You can pass &#8220;dw&#8221; or &#8220;weekday&#8221; as a first parameter to [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>How to find Date Name in MSSQL:</strong></p>
<p><strong></strong>if you want to return a weekday or date name of particular date then it is so simple in MSSQL.<br />
<strong><br />
See the example:</strong></p>
<p><code>select DATENAME(dw , getDate())<br />
</code><br />
This query returns today&#8217;s date name like Sunday, Monday etc.</p>
<p>You can pass &#8220;dw&#8221; or &#8220;weekday&#8221; as a first parameter to date name which specifies the part of date returned.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/08/10/how-to-find-date-name/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">367</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>How to delete the MSSQL transaction log.</title>
		<link>https://sqlhelp.wordpress.com/2009/08/09/how-to-delete-the-mssql-transaction-log/</link>
					<comments>https://sqlhelp.wordpress.com/2009/08/09/how-to-delete-the-mssql-transaction-log/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Sun, 09 Aug 2009 13:34:35 +0000</pubDate>
				<category><![CDATA[How to delete the MSSQL transaction log.]]></category>
		<category><![CDATA[Advance query]]></category>
		<category><![CDATA[BACKUP LOG]]></category>
		<category><![CDATA[Database tricks]]></category>
		<category><![CDATA[DBA jobs]]></category>
		<category><![CDATA[DBCC]]></category>
		<category><![CDATA[DBCC SHRINKFILE]]></category>
		<category><![CDATA[How to check file size from query]]></category>
		<category><![CDATA[MSSQL LOG BACKUP]]></category>
		<category><![CDATA[step to clean your LOG size]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[tricks]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=361</guid>

					<description><![CDATA[How to delete the MSSQL transaction log. If your transaction log is big or too much large. it will utilize your space and other issue might be there, so you need to clean up the transaction log time to time. Follow the following steps and clean your LOG size. 1)  first take log backup -- [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>How to delete the MSSQL transaction log.</strong></p>
<p>If your transaction log is big or too much large. it will utilize your space and other issue might be there, so you need to clean up the transaction log time to time. Follow the following steps and clean your LOG size.</p>
<p>1)  first take log backup</p>
<p><code>-- Backup on Drive<br />
BACKUP LOG TESTDB TO DISK='d:\TEMP.bak' with init</code></p>
<p><code><br />
-- Backup and Delete file</code><br />
<code>BACKUP LOG <code>TESTDB</code> TO DISK='NUL'</code></p>
<p>&nbsp;</p>
<p>2) Shrink your Database.</p>
<p><code><br />
USE TESTDB<br />
GO<br />
DBCC SHRINKFILE ('TESTDB_log', EMPTYFILE);<br />
GO<br />
</code></p>
<p><strong>From GUI mode: <em>Rclick  DB ==&gt; Task ==&gt; Shirinks ==&gt; Database ==&gt; specify size and press OK</em><br />
</strong></p>
<p>3) Now see your log and file size.</p>
<p><code><br />
SELECT name AS [File Name] , file_id, physical_name AS [Physical Name],<br />
size/128 AS [Total Size in MB],<br />
size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0<br />
AS [Available Space In MB]<br />
FROM sys.database_files;</code></p>
<p>MSDN:<br />
You can reduce the default size of an empty file by using DBCC SHRINKFILE <em>target_size</em>. For example, if you create a 5-MB file and then shrink the file to 3 MB while the file is still empty, the default file size is set to 3 MB. This applies only to empty files that have never contained data.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/08/09/how-to-delete-the-mssql-transaction-log/feed/</wfw:commentRss>
			<slash:comments>10</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">361</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Display Line Numbers In SQL Queries</title>
		<link>https://sqlhelp.wordpress.com/2009/07/10/display-line-numbers-in-sql-queries/</link>
					<comments>https://sqlhelp.wordpress.com/2009/07/10/display-line-numbers-in-sql-queries/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Fri, 10 Jul 2009 13:26:54 +0000</pubDate>
				<category><![CDATA[Display Line Numbers]]></category>
		<category><![CDATA[Display Line Numbers In SQL Queries]]></category>
		<category><![CDATA[Line number in SQL]]></category>
		<category><![CDATA[SQL 2008 line number]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=356</guid>

					<description><![CDATA[Display Line Numbers In SQL Queries By default in SQL Query analyzer line numbers are not shown. Follow the steps below: GOTO:  Tools =&#62; Text Editor =&#62;All Languages =&#62; General =&#62;Line Number (Select this check box). Now when you open a “New Query” line numbers will appear.]]></description>
										<content:encoded><![CDATA[<p><strong>Display Line Numbers In SQL Queries</strong></p>
<p>By default in SQL Query analyzer line numbers are not shown.</p>
<p>Follow the steps below:</p>
<p>GOTO:  Tools =&gt; Text Editor =&gt;All Languages =&gt; General =&gt;Line Number (Select this check box).</p>
<p>Now when you open a “New Query” line numbers will appear.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/07/10/display-line-numbers-in-sql-queries/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">356</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Saving change is not permitted</title>
		<link>https://sqlhelp.wordpress.com/2009/07/02/saving-change-is-not-permitted/</link>
					<comments>https://sqlhelp.wordpress.com/2009/07/02/saving-change-is-not-permitted/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Thu, 02 Jul 2009 10:38:26 +0000</pubDate>
				<category><![CDATA[Saving change is not permitted]]></category>
		<category><![CDATA[Permission issue to update table]]></category>
		<category><![CDATA[SQL 2008]]></category>
		<category><![CDATA[Sql 2008 Management Tools]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=348</guid>

					<description><![CDATA[Saving change is not permitted Some time if your setting changed by some one then you can not update table in MSSQL 2008. you will see the below error: &#8220;A table that can not be re-created or enabled the options prevent saving changes. Sql 2008 Management Tools: Can&#8217;t save changes that require Recreation of Database&#8221; [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Saving change is not permitted</strong></p>
<p>Some time if your setting changed by some one then you can not update table in MSSQL 2008.<br />
you will see the below error:</p>
<blockquote><p>&#8220;A table that can not be re-created or enabled the options prevent saving changes.<br />
Sql 2008 Management Tools: Can&#8217;t save changes that require Recreation of Database&#8221;</p></blockquote>
<p>That time you need to update your setting.</p>
<p>The fix is:</p>
<p><strong>Go to Tools =&gt; Options =&gt; Designers =&gt;Tables and Designers and uncheck the <em>Prevent Saving Changes</em> <em>that require table re-creation </em>option:</strong></p>
<p>As it is, reverting back to the &#8216;old&#8217; behavior now doesn&#8217;t let you know that a table recreate is required either, so the behavior now is the same as was with the old tools. Here Microsoft added some useful functionality and then UI fails to expose it intelligently.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/07/02/saving-change-is-not-permitted/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">348</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>MERGE (Transact-SQL)</title>
		<link>https://sqlhelp.wordpress.com/2009/07/01/merge-transact-sql/</link>
					<comments>https://sqlhelp.wordpress.com/2009/07/01/merge-transact-sql/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Wed, 01 Jul 2009 11:54:01 +0000</pubDate>
				<category><![CDATA[MERGE (Transact-SQL 2008)]]></category>
		<category><![CDATA[How to use MERGE in SQL]]></category>
		<category><![CDATA[Multiple TSQL in SAME Query]]></category>
		<category><![CDATA[New SQL features]]></category>
		<category><![CDATA[Raghunath Bhandari]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=343</guid>

					<description><![CDATA[MERGE (Transact-SQL 2008) MERGE is new feature , it Performs insert, update, or delete operations on a target table based on the results of a join with a source table. For example, you can synchronize two tables by inserting, updating, or deleting rows in one table based on differences found in the other table. Examples [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><strong>MERGE (Transact-SQL 2008)</strong></div>
<p><!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--></p>
<p><span> </span></p>
<p>MERGE is new feature , it Performs insert, update, or delete operations on a target table based on the results of a join with a source table. For example, you can synchronize two tables by inserting, updating, or deleting rows in one table based on differences found in the other table.</p>
<p><strong>Examples </strong> <a id="sectionToggle2"></a></p>
<p><code>CREATE TABLE TABLE1<br />
(<br />
Monthid INTEGER,<br />
Month_Name VARCHAR(15)<br />
)<br />
GO<br />
INSERT INTO TABLE1<br />
VALUES(1,'JAN')<br />
INSERT INTO TABLE1<br />
VALUES(2,'FEB')<br />
INSERT INTO TABLE1<br />
VALUES(3,'MAR')<br />
INSERT INTO TABLE1<br />
VALUES(4,'APR')<br />
INSERT INTO TABLE1<br />
VALUES(5,'MAY')<br />
GO</code></p>
<p><code>CREATE TABLE TABLE2<br />
(<br />
Monthid INTEGER,<br />
Month_Name VARCHAR(15)<br />
)<br />
GO<br />
INSERT INTO TABLE2<br />
VALUES(1,'JAN')<br />
INSERT INTO TABLE2<br />
VALUES(6,'JUNE')<br />
INSERT INTO TABLE2<br />
VALUES(7,'JULY')</code><br />
<code><br />
select * from TABLE2<br />
select * from TABLE1</code></p>
<p><code>MERGE TABLE1 AS t1<br />
USING (SELECT Monthid,Month_Name FROM TABLE2) AS t2<br />
ON t1.Monthid = t2.Monthid<br />
WHEN MATCHED AND t1.Monthid &gt; 8 THEN DELETE<br />
WHEN MATCHED THEN UPDATE SET t1.Monthid = t2.Monthid<br />
WHEN NOT MATCHED THEN<br />
INSERT(Monthid,Month_Name)<br />
VALUES(Monthid,Month_Name);<br />
GO<br />
</code><br />
<strong>MSDN:<br />
Using MERGE to perform INSERT and UPDATE operations on a table in a single statement</strong></p>
<p>A common scenario is updating one or more columns in a table if a matching row exists, or inserting the data as a new row if a matching row does not exist. This is usually done by passing parameters to a stored procedure that contains the appropriate UPDATE and INSERT statements. With the MERGE statement, you can perform both tasks in a single statement. The following example shows a stored procedure that contains both an INSERT statement and an UPDATE statement. The procedure is then modified to perform the equivalent operations by using a single MERGE statement.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/07/01/merge-transact-sql/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">343</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>CREATE TYPE TABLE (Transact-SQL 2008)</title>
		<link>https://sqlhelp.wordpress.com/2009/06/28/create-type-table-transact-sql-2008/</link>
					<comments>https://sqlhelp.wordpress.com/2009/06/28/create-type-table-transact-sql-2008/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Sun, 28 Jun 2009 11:49:32 +0000</pubDate>
				<category><![CDATA[CREATE TYPE TABLE]]></category>
		<category><![CDATA[Author Raghunath Bhandari]]></category>
		<category><![CDATA[Create Type MyTable as TABLE]]></category>
		<category><![CDATA[how to use the Table UDT]]></category>
		<category><![CDATA[how to use Type Table in SQL 2008]]></category>
		<category><![CDATA[MS SQL new feature Create  type table]]></category>
		<category><![CDATA[New feature in SQL 2008]]></category>
		<category><![CDATA[SQL 2008]]></category>
		<category><![CDATA[Table UDT]]></category>
		<category><![CDATA[Table UDT as a parameter in SQL Stored Procedure.]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=338</guid>

					<description><![CDATA[CREATE TYPE TABLE (Transact-SQL 2008) Create TYPE  Table is new opotion in SQL2008. It is very easy to handle and good to use in TSQ. This is good as compare to TEMP Table. Here is the Example: Create Type MyTable as TABLE ( ID INT IDENTITY (1,1), NAME varchar(20), ADRES VARCHAR(200) ) DECLARE @T AS [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>CREATE TYPE TABLE (Transact-SQL 2008)</strong></p>
<p>Create TYPE  Table is new opotion in SQL2008. It is very easy to handle and good to use in TSQ.<br />
This is good as compare to TEMP Table.</p>
<p><strong>Here is the Example:</strong><br />
<code>Create Type MyTable as TABLE<br />
(<br />
ID INT IDENTITY (1,1),<br />
NAME varchar(20),<br />
ADRES VARCHAR(200)<br />
)<br />
</code><br />
<code>DECLARE @T AS MyTable;</code><br />
<code><br />
INSERT INTO @T( NAME, ADRES) VALUES( 'RAGHU', 'KTM' )<br />
INSERT INTO @T( NAME, ADRES) VALUES( 'RAGHU', 'KTM' )<br />
INSERT INTO @T( NAME, ADRES) VALUES( 'RAGHU', 'KTM' )<br />
INSERT INTO @T( NAME, ADRES) VALUES( 'RAGHU', 'KTM' )</code></p>
<p><code><br />
SELECT * FROM @T ;<br />
DROP TYPE MyTable;<br />
</code></p>
<p>Many a times, we need to utilize a single Stored Procedure to update multiple database tables with one-to-many relationships. In such occasions, we end up concatenating large strings, and inside the procedure, end up parsing the string to get records. With SQL Server 2008, it is very simple, and we no more need to write tons of lines of code to implement such requirements.</p>
<p><code>CREATE PROC dbo.sp_GetOrders<br />
(@T AS dbo.tbl_Order READONLY)<br />
AS<br />
SELECT O.OrderID, O.OrderDate, O.CustomerID<br />
FROM dbo.tbl_Order AS O JOIN @T AS T ON<br />
O.OrderID = T. OrderID<br />
ORDER BY T. RecordID;<br />
GO</code><br />
<code><br />
DECLARE @MyOrderIDs AS dbo.tbl_Order;<br />
INSERT INTO @MyOrderIDs(pos, orderid) VALUES(1, 10248)<br />
INSERT INTO @MyOrderIDs(pos, orderid) VALUES(2, 10250)<br />
INSERT INTO @MyOrderIDs(pos, orderid) VALUES(3, 10249);</code></p>
<p><code><br />
EXEC dbo.sp_GetOrders @T = @MyOrderIDs;<br />
</code></p>
<p>This example shows  how to use the <code>Table</code> UDT as a parameter in SQL Stored Procedure.<br />
Hope you enjoyed this feature. Happy Programming.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/06/28/create-type-table-transact-sql-2008/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">338</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Find All SQL Server Instance Running in Local Network</title>
		<link>https://sqlhelp.wordpress.com/2009/04/27/find-all-sql-server-instance-running-in-local-network/</link>
					<comments>https://sqlhelp.wordpress.com/2009/04/27/find-all-sql-server-instance-running-in-local-network/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Mon, 27 Apr 2009 09:50:53 +0000</pubDate>
				<category><![CDATA[SQL Server Instance Running]]></category>
		<category><![CDATA[How to list all SQL Server Instance Running in Local Network:]]></category>
		<category><![CDATA[Instance Running]]></category>
		<category><![CDATA[MS SQL server]]></category>
		<category><![CDATA[MSSQL tips]]></category>
		<category><![CDATA[MSSQL tricks]]></category>
		<category><![CDATA[Raghunath Bhandari]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=332</guid>

					<description><![CDATA[How to list all SQL Server Instance Running in Local Network: Some time you need to see the List of other running SQL server on your network. It is so simple and easy to call from other application also. See the example: -- ######### Query EXEC master..xp_cmdshell 'osql -L' -- ############ Result NULL Servers: (local) [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>How to list all SQL Server Instance Running in Local Network:</strong><br />
Some time you need to see the List of other running SQL server on your network. It is so simple and easy to call from other application also.</p>
<p>See the example:</p>
<pre>-- ######### Query
EXEC master..xp_cmdshell 'osql -L'

-- ############ Result

NULL
Servers:
    (local)
    MAIL_SERVER
    RAGHU
    RAGHU\SQLEXPRESS
    SERVER1
NULL</pre>
<p>If you want to get the same list from Command prompt then:</p>
<p>C:\&gt; osql -L</p>
<p>it will show you the same list.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/04/27/find-all-sql-server-instance-running-in-local-network/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">332</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>MSSQL Server cursors</title>
		<link>https://sqlhelp.wordpress.com/2009/04/06/mssql-server-cursors/</link>
					<comments>https://sqlhelp.wordpress.com/2009/04/06/mssql-server-cursors/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Mon, 06 Apr 2009 09:57:43 +0000</pubDate>
				<category><![CDATA[MSSQL Server cursors]]></category>
		<category><![CDATA[Author Raghu]]></category>
		<category><![CDATA[cursors]]></category>
		<category><![CDATA[Example of cursors]]></category>
		<category><![CDATA[how to user cursors]]></category>
		<category><![CDATA[Select row by row]]></category>
		<category><![CDATA[SQL cursor]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=329</guid>

					<description><![CDATA[How to use MSSQL Server cursors? SQL Server cursors are database objects used to manipulate data in a set on a row-by-row basis. You can fetch cursor rows and perform operations on them in a loop just like using any looping mechanism found in any other programming language. Before you can use a cursor, you [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>How to use MSSQL Server cursors?</strong><br />
SQL Server cursors are database objects used to manipulate data in a set on a row-by-row basis. You can fetch cursor rows and perform operations on them in a loop just like using any looping mechanism found in any other programming language. Before you can use a cursor, you need to declare it.</p>
<p><strong>Example:</strong></p>
<pre><code>declare @row as varchar(20)</code>
DECLARE cur1 CURSOR FOR

SELECT rowid FROM Table1</pre>
<pre>OPEN cur1</pre>
<pre>FETCH NEXT FROM cur1 INTO @row
WHILE @@FETCH_STATUS = 0
BEGIN</pre>
<pre>    SELECT * FROM Table1 WHERE rowid = @row</pre>
<pre>    FETCH NEXT FROM cur1 INTO @row</pre>
<pre>END
CLOSE cur1
DEALLOCATE cur1</pre>
<p><strong>DECLARE CURSOR</strong></p>
<p>The DECLARE CURSOR command defines the attributes of a Transact-SQL server cursor, such as its scrolling behavior and the query used to build the result set on which the cursor operates. DECLARE CURSOR accepts both a syntax based on the SQL-92 standard and a syntax using a set of Transact-SQL extensions.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/04/06/mssql-server-cursors/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">329</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Password Encryption and Decrypt</title>
		<link>https://sqlhelp.wordpress.com/2009/04/01/password-encryption-and-decrypt/</link>
					<comments>https://sqlhelp.wordpress.com/2009/04/01/password-encryption-and-decrypt/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Wed, 01 Apr 2009 06:15:26 +0000</pubDate>
				<category><![CDATA[Encrypt Password and Compare]]></category>
		<category><![CDATA[Easy way to check Password]]></category>
		<category><![CDATA[Insert encrypted value to a table]]></category>
		<category><![CDATA[MS SQL Password compare]]></category>
		<category><![CDATA[MSSQL builtin encrypt function]]></category>
		<category><![CDATA[MSSQL Encryption]]></category>
		<category><![CDATA[One way encryption]]></category>
		<category><![CDATA[Password encrypt function]]></category>
		<category><![CDATA[pwdcompare]]></category>
		<category><![CDATA[pwdencrypt]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=325</guid>

					<description><![CDATA[How to Encrypt Password and compare? MS SQL has its own built in function to Encrypt password or secure text and compare it. This is very simple see the Example: &#8212;1 , Create a Table to insert. Create table tempPassTable ( id int, pwd varbinary(200) ) &#8212;2, Insert encrypted value to a table. insert into [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>How to Encrypt Password and compare?</strong></p>
<p>MS SQL has its own built in function to Encrypt password or secure text and compare it. This is very simple see the Example:</p>
<p><strong>&#8212;1 , Create a Table to insert.</strong></p>
<pre>Create table tempPassTable
(
id int,
pwd varbinary(200)
)</pre>
<p><strong>&#8212;2, Insert encrypted value to a table.<br />
</strong></p>
<pre>insert into tempPassTable(id,pwd)
select 1, pwdencrypt('abcd')</pre>
<p><strong>&#8212;3, Compare encrypted value and user input value.<br />
</strong></p>
<pre>
if (select pwdcompare('abcd',pwd,0) from tempPassTable)=0 
select 'Invalid Password'
else
select 'Valid Password'</pre>
<pre></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/04/01/password-encryption-and-decrypt/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">325</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>TSQL Delete on join</title>
		<link>https://sqlhelp.wordpress.com/2009/02/27/tsql-delete-on-join/</link>
					<comments>https://sqlhelp.wordpress.com/2009/02/27/tsql-delete-on-join/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Fri, 27 Feb 2009 09:08:25 +0000</pubDate>
				<category><![CDATA[TSQL Delete on join]]></category>
		<category><![CDATA[Delete statement on join]]></category>
		<category><![CDATA[MS SQL]]></category>
		<category><![CDATA[MS SQL delete on join]]></category>
		<category><![CDATA[SQL Delete on Join]]></category>
		<category><![CDATA[subquery delete]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=318</guid>

					<description><![CDATA[Delete statement on join: Some time you need to delete a table on join. This example will help you to run delete statement on sql join. Example: DELETE table1 FROM table1 t1 JOIN table2 t2 ON t1.IDCOL=t2.IDCOL This T-SQL is checking TABLE2, If records exists then delete TABLE1. Weather IDCOL is already there in TABLE2 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Delete statement on join:</strong></p>
<p>Some time you need to delete a table on join.<br />
This example will help you to run delete statement on sql join.</p>
<p><strong>Example:</strong></p>
<p><code>DELETE table1<br />
FROM </code><code>table1 </code><code> t1<br />
JOIN </code><code>table2 </code><code>t2 ON t1.IDCOL=t2.</code><code>IDCOL</code></p>
<p>This T-SQL is checking TABLE2, If records exists then delete TABLE1. Weather IDCOL is already there in TABLE2 or not?</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/02/27/tsql-delete-on-join/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">318</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>How to find hard disk serial number ?</title>
		<link>https://sqlhelp.wordpress.com/2009/01/24/how-to-find-hard-disk-serial-number/</link>
					<comments>https://sqlhelp.wordpress.com/2009/01/24/how-to-find-hard-disk-serial-number/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Sat, 24 Jan 2009 07:44:39 +0000</pubDate>
				<category><![CDATA[Hard drive Serial Number]]></category>
		<category><![CDATA[Computer unique number]]></category>
		<category><![CDATA[Get Computer unique number form VB6]]></category>
		<category><![CDATA[get drive serial number]]></category>
		<category><![CDATA[getdrive serial number]]></category>
		<category><![CDATA[Hard disk serial number]]></category>
		<category><![CDATA[How to find Harddisk SerialNumber]]></category>
		<category><![CDATA[software security]]></category>
		<category><![CDATA[VB tips]]></category>
		<category><![CDATA[VB Tricks]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[Visual basic code]]></category>
		<category><![CDATA[Visual Basic Tips]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=302</guid>

					<description><![CDATA[How to find hard disk serial number ? If you want to get the hard drive serial number or computer unique number then use this function. This is Visual Basic 6.0 Code to Get the Computer Hard Drive Serial Number. &#8216;Computer Unique No or hard drive serial number From Visual Basic Private Declare Function GetVolumeInformation [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>How to find hard disk serial number ?</strong></p>
<p>If you want to get the  hard drive serial number or computer unique number then use this function.<br />
This is Visual Basic 6.0 Code to Get the Computer Hard Drive Serial Number.</p>
<p>&#8216;Computer Unique No or hard drive serial number From Visual Basic</p>
<pre>Private Declare Function GetVolumeInformation _
Lib "kernel32.dll" _
Alias "GetVolumeInformationA" _
(ByVal lpRootPathName As String, _
ByVal lpVolumeNameBuffer As String, _
ByVal nVolumeNameSize As Integer, _
lpVolumeSerialNumber As Long, _
lpMaximumComponentLength As Long, _
lpFileSystemFlags As Long, _
ByVal lpFileSystemNameBuffer As String, _
ByVal nFileSystemNameSize As Long) As Long</pre>
<p><strong>This Function will return serial number of a Drive</strong></p>
<pre>Public Function GetSerialNumber(DriveLetter As String) As String
Dim SerialNum As Long
Dim VolNameBuf As String
Dim FileSysNameBuf As String

Select Case Len(DriveLetter)
Case 1
If DriveLetter Like "[a-z]" Then
DriveLetter = Left$(DriveLetter, 1) &amp; ":\"
Else
GetSerialNumber = "Error - Bad drive designation"
End If
Case 2
If LCase(DriveLetter) Like "[a-z]:" Then
DriveLetter = DriveLetter &amp; "\"
Else
GetSerialNumber = "Error - Bad drive designation"
End If
Case 3
If LCase(DriveLetter) Like "[!a-z]:\" Then
GetSerialNumber = "Error - Bad drive designation"
End If
Case Else
GetSerialNumber = "Error - Bad drive designation"
End Select
If Len(GetSerialNumber) = 0 Then
VolNameBuf = String$(255, Chr$(0))
FileSysNameBuf = String$(255, Chr$(0))
GetVolumeInformation DriveLetter, VolNameBuf, _
Len(VolNameBuf), SerialNum, 0, 0, _
FileSysNameBuf, Len(FileSysNameBuf)
GetSerialNumber = Right$("00000000" &amp; Hex$(SerialNum), 8)
End If
End Function</pre>
<blockquote><p>This is good for security purpose. some time if you want to run your EXE file on some computer only then this is the best way.</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/01/24/how-to-find-hard-disk-serial-number/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">302</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Send SMS using AT command</title>
		<link>https://sqlhelp.wordpress.com/2009/01/24/send-sms-using-at-command/</link>
					<comments>https://sqlhelp.wordpress.com/2009/01/24/send-sms-using-at-command/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Sat, 24 Jan 2009 06:47:38 +0000</pubDate>
				<category><![CDATA[Send SMS using AT command]]></category>
		<category><![CDATA[1]]></category>
		<category><![CDATA[8]]></category>
		<category><![CDATA[AT command]]></category>
		<category><![CDATA[AT command to send sms]]></category>
		<category><![CDATA[AT Commands]]></category>
		<category><![CDATA[AT+CMGF=1]]></category>
		<category><![CDATA[AT+CMGR]]></category>
		<category><![CDATA[GSM modem]]></category>
		<category><![CDATA[How to send SMS using AT commands]]></category>
		<category><![CDATA[MSComm1]]></category>
		<category><![CDATA[MSComm1.PortOpen = True]]></category>
		<category><![CDATA[MSComm1.Settings = "9600]]></category>
		<category><![CDATA[N]]></category>
		<category><![CDATA[send SMS]]></category>
		<category><![CDATA[SMS from GSM modem]]></category>
		<category><![CDATA[Use MScomm library]]></category>
		<category><![CDATA[VB code to send sms]]></category>
		<category><![CDATA[VB Tricks and Tips]]></category>
		<category><![CDATA[VB6 code to send sms]]></category>
		<category><![CDATA[Visual basic code to send sms]]></category>
		<category><![CDATA[Visual Basic Tips]]></category>
		<category><![CDATA[Visual Basic Tricks]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=292</guid>

					<description><![CDATA[Send SMS using GSM modem from your computer. This Example shows you to use AT command to handle the GSM modem. Try this to send SMS using this example. 1- Insert a form in VB project 2- Insert textbox (txtMsg,txtDestinationNumber) 3- Insert command button (Command1) 4- Insert a MSComm1 5- Connect your mobile phone in [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Send SMS using GSM modem from your computer. This Example shows you to use AT command to handle the GSM modem.<br />
<strong>Try this to send SMS using this example.</strong></p>
<p>1- Insert a form in VB project<br />
2- Insert textbox (txtMsg,txtDestinationNumber)<br />
3- Insert command button (Command1)<br />
4- Insert a MSComm1<br />
5- Connect your mobile phone in computer with datacable</p>
<pre>Private Sub Command1_Click()
Call SENDSMS
End Sub

Sub SENDSMS()
On Error GoTo Errr:
If MsgBox("Are you sure to send SMS Message", vbYesNo) = vbNo Then
    Exit Sub
End If</pre>
<pre>' Set up the communications port
MSComm1.CommPort = 5 ' Com Port 5</pre>
<pre>' Set for 9600 baud, no parity, 8 data, and 1 stop bit.
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0
MSComm1.PortOpen = True
MSComm1.Output = "AT" &amp; Chr$(13)</pre>
<pre>' Set up the phone for a text message
MSComm1.Output = "AT+CMGF=1" &amp; Chr$(13)
MSComm1.Output = "AT+CMGS= " &amp; Chr(34) &amp; txtDestinationNumber.Text &amp; Chr(34) &amp; Chr$(13) &amp; Chr(10)
MSComm1.Output = txtMsg.Text &amp; Chr$(26)
MSComm1.PortOpen = False
MsgBox "Message Sent successfully"
Exit Sub</pre>
<pre>Errr:</pre>
<pre>MsgBox Err.Description &amp; Err.Number, vbExclamation

End Sub</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/01/24/send-sms-using-at-command/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">292</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>NULLIF (Transact-SQL)</title>
		<link>https://sqlhelp.wordpress.com/2009/01/23/nullif-transact-sql/</link>
					<comments>https://sqlhelp.wordpress.com/2009/01/23/nullif-transact-sql/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Fri, 23 Jan 2009 11:32:39 +0000</pubDate>
				<category><![CDATA[NULLIF (Transact-SQL)]]></category>
		<category><![CDATA[difference between nullif and case]]></category>
		<category><![CDATA[MS SQL tricks]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[SQL Tips]]></category>
		<category><![CDATA[use of nullif]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=284</guid>

					<description><![CDATA[How to use NULLIF (Transact-SQL) NULLIF will Return a null value if the two specified expressions are equal. If you want to compare to fields and then this will work for you like : Run these examples and you can see how to use it on your way. Select NULLIF('aa','aa') Select isnull( NULLIF('aa','aa'),'right') MSDN is [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>How to use NULLIF (Transact-SQL)</strong></p>
<p>NULLIF will Return a null value if the two specified expressions are equal. If you want to compare to fields and then this will work for you like :</p>
<p>Run these examples and you can see how to use it on your way.<br />
<code>Select NULLIF('aa','aa')<br />
Select isnull( NULLIF('aa','aa'),'right')</code></p>
<h3 class="subHeading">MSDN is comparing NULLIF and CASE</h3>
<div class="subSection">
<p>To show the similarity between <code>NULLIF</code> and <code>CASE</code>, the following queries evaluate whether the values in the <code>MakeFlag</code> and <code>FinishedGoodsFlag</code> columns are the same. The first query uses <code>NULLIF</code>. The second query uses the <code>CASE</code> expression.</p>
<p><code><br />
USE AdventureWorks;<br />
GO<br />
SELECT ProductID, MakeFlag, FinishedGoodsFlag,<br />
NULLIF(MakeFlag,FinishedGoodsFlag)AS 'Null if Equal'<br />
FROM Production.Product<br />
WHERE ProductID &lt; 10;<br />
GO</code></p>
<pre>SELECT ProductID, MakeFlag, FinishedGoodsFlag,'Null if Equal' =
CASE
WHEN MakeFlag = FinishedGoodsFlag THEN NULL
ELSE MakeFlag
END
FROM Production.Product
WHERE ProductID &lt; 10;
GO</pre>
<p>So NULLIF and ISNULL functions can help you on different way.</p></div>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/01/23/nullif-transact-sql/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">284</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Format money/decimal with commas</title>
		<link>https://sqlhelp.wordpress.com/2009/01/14/format-moneydecimal-with-commas/</link>
					<comments>https://sqlhelp.wordpress.com/2009/01/14/format-moneydecimal-with-commas/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Wed, 14 Jan 2009 09:04:20 +0000</pubDate>
				<category><![CDATA[SQL Formating]]></category>
		<category><![CDATA[CONVERT function]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MSSQL server]]></category>
		<category><![CDATA[SQL format money/decimal with commas]]></category>
		<category><![CDATA[SQL formatting]]></category>
		<category><![CDATA[SQL Server]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=245</guid>

					<description><![CDATA[SQL format money/decimal with commas: Sometimes you want to have your money fields properly formatted with commas like this: 13,243,543.57 You can use the CONVERT function and give a value between 0 and 2 to the style and the format will be displayed based on that Below is an example: DECLARE @v MONEY SELECT @v [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span style="font-size:small;"><strong>SQL format money/decimal with commas: </strong></span></p>
<p><span>Sometimes you want to have your money fields properly formatted with commas like this: 13,243,543.57<br />
You can use the CONVERT function and give a value between 0 and 2 to the style and the format will be displayed based on that</span></p>
<p><strong>Below is an example:</strong></p>
<pre><span>DECLARE @v MONEY
SELECT @v = 1322323.6666</span>

<span>SELECT CONVERT(VARCHAR,@v,0)  --1322323.67
Rounded but no formatting</span>

<span>SELECT CONVERT(VARCHAR,@v,1)    --1,322,323.67
Formatted with commas

SELECT CONVERT(VARCHAR,@v,2)    --1322323.6666
No formatting
</span></pre>
<p><strong><span>If you have a decimal field it doesn&#8217;t work with the convert function<br />
The work around is to convert it to money:</span></strong></p>
<pre><span>DECLARE @v2 DECIMAL (36,10)
SELECT @v2 = 13243543.56565656

SELECT CONVERT(VARCHAR,CONVERT(MONEY,@v2),1) --13,243,543.57
Formatted with commas</span></pre>
<p><span><br />
</span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/01/14/format-moneydecimal-with-commas/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">245</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Difference with (nolock) vs (nolock) as a SQL Table Hint</title>
		<link>https://sqlhelp.wordpress.com/2009/01/14/difference-with-nolock-vs-nolock-as-a-sql-table-hint/</link>
					<comments>https://sqlhelp.wordpress.com/2009/01/14/difference-with-nolock-vs-nolock-as-a-sql-table-hint/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Wed, 14 Jan 2009 06:07:20 +0000</pubDate>
				<category><![CDATA[with (nolock) vs (nolock)]]></category>
		<category><![CDATA[Difference with (nolock) vs (nolock)]]></category>
		<category><![CDATA[FASTFIRSTROW]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MSSQL server]]></category>
		<category><![CDATA[NOEXPAND]]></category>
		<category><![CDATA[NOLOCK]]></category>
		<category><![CDATA[NOWAIT]]></category>
		<category><![CDATA[PAGLOCK]]></category>
		<category><![CDATA[READCOMMITTED]]></category>
		<category><![CDATA[READPAST]]></category>
		<category><![CDATA[READUNCOMMITTED]]></category>
		<category><![CDATA[REPEATABLEREAD]]></category>
		<category><![CDATA[ROWLOCK]]></category>
		<category><![CDATA[SERIALIZABLE]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips]]></category>
		<category><![CDATA[SQL Tricks]]></category>
		<category><![CDATA[T-SQL best way]]></category>
		<category><![CDATA[Table Hints]]></category>
		<category><![CDATA[TABLOCK]]></category>
		<category><![CDATA[TABLOCKX]]></category>
		<category><![CDATA[UPDLOCK]]></category>
		<category><![CDATA[XLOCK]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=239</guid>

					<description><![CDATA[Difference with (nolock) vs (nolock) as a SQL Table Hint: select sum(amount) from reward_expired (nolock) difference was between using the table hint (nolock) and the table hint with (nolock). Look at MSDN under SQL 2005, &#8220;In SQL Server 2005, with some exceptions, table hints are supported in the FROM clause only when the hints are [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Difference with (nolock) vs (nolock) as a SQL Table Hint:</strong></p>
<pre>select sum(amount) from reward_expired (nolock)</pre>
<p>difference was between using the table hint (nolock) and the table hint with (nolock).<br />
<strong>Look at MSDN under SQL 2005,</strong></p>
<p>&#8220;In SQL Server 2005, with some exceptions, table hints are supported in the FROM clause only when the hints are specified with the WITH keyword. Table hints also must be specified with parentheses.</p>
<p>The following table hints are allowed with and without the WITH keyword: NOLOCK, READUNCOMMITTED, UPDLOCK, REPEATABLEREAD, SERIALIZABLE, READCOMMITTED, FASTFIRSTROW, TABLOCK, TABLOCKX, PAGLOCK, ROWLOCK, NOWAIT, READPAST, XLOCK, and NOEXPAND. When these table hints are specified without the WITH keyword, the hints should be specified alone.&#8221;<br />
<strong><br />
Micorosft plan to remove the ability to use just (nolock), and to future proof all SQL, users should write all table hints using the with keyword.</strong></p>
<blockquote><p>Omitting the WITH keyword is a deprecated feature: This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/01/14/difference-with-nolock-vs-nolock-as-a-sql-table-hint/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">239</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Table Hints (Transact-SQL)</title>
		<link>https://sqlhelp.wordpress.com/2009/01/13/table-hints-transact-sql/</link>
					<comments>https://sqlhelp.wordpress.com/2009/01/13/table-hints-transact-sql/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Tue, 13 Jan 2009 12:20:46 +0000</pubDate>
				<category><![CDATA[Table Hints]]></category>
		<category><![CDATA[and NOEXPAND]]></category>
		<category><![CDATA[FASTFIRSTROW]]></category>
		<category><![CDATA[MSSQL Table Hints]]></category>
		<category><![CDATA[NOLOCK]]></category>
		<category><![CDATA[NOWAIT]]></category>
		<category><![CDATA[PAGLOCK]]></category>
		<category><![CDATA[READCOMMITTED]]></category>
		<category><![CDATA[READPAST]]></category>
		<category><![CDATA[READUNCOMMITTED]]></category>
		<category><![CDATA[REPEATABLEREAD]]></category>
		<category><![CDATA[ROWLOCK]]></category>
		<category><![CDATA[SERIALIZABLE]]></category>
		<category><![CDATA[SQL Locks]]></category>
		<category><![CDATA[SQL Tips]]></category>
		<category><![CDATA[SQL Tricks]]></category>
		<category><![CDATA[Table Hints (Transact-SQL)]]></category>
		<category><![CDATA[TABLOCK]]></category>
		<category><![CDATA[TABLOCKX]]></category>
		<category><![CDATA[UPDLOCK]]></category>
		<category><![CDATA[XLOCK]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=236</guid>

					<description><![CDATA[Table Hints (Transact-SQL) Table hints override the default behavior of the query optimizer for the duration of the data manipulation language (DML) statement by specifying a locking method, one or more indexes, a query processing operation such as a table scan or index seek, or other options. WITH ( &#60;table_hint&#62; [ [ , ]...n ] [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Table Hints (Transact-SQL)</strong></p>
<p>Table hints override the default behavior of the query optimizer for the duration of the data manipulation language (DML) statement by specifying a locking method, one or more indexes, a query processing operation such as a table scan or index seek, or other options.</p>
<pre>WITH ( &lt;table_hint&gt; [ [ , ]...n ] )

&lt;table_hint&gt; ::=
[ NOEXPAND ] {
    INDEX ( index_value [ ,...n ] ) | INDEX = ( index_value )
  | FASTFIRSTROW
  | FORCESEEK
  | HOLDLOCK
  | NOLOCK
  | NOWAIT
  | PAGLOCK
  | READCOMMITTED
  | READCOMMITTEDLOCK
  | READPAST
  | READUNCOMMITTED
  | REPEATABLEREAD
  | ROWLOCK
  | SERIALIZABLE
  | TABLOCK
  | TABLOCKX
  | UPDLOCK
  | XLOCK
} 

&lt;table_hint_limited&gt; ::=
{
    KEEPIDENTITY
  | KEEPDEFAULTS
  | FASTFIRSTROW
  | HOLDLOCK
  | IGNORE_CONSTRAINTS
  | IGNORE_TRIGGERS
  | NOWAIT
  | PAGLOCK
  | READCOMMITTED
  | READCOMMITTEDLOCK
  | READPAST
  | REPEATABLEREAD
  | ROWLOCK
  | SERIALIZABLE
  | TABLOCK
  | TABLOCKX
  | UPDLOCK
  | XLOCK
}</pre>
<p>The following table hints are allowed with and without the WITH<br />
keyword: NOLOCK, READUNCOMMITTED, UPDLOCK, REPEATABLEREAD,<br />
SERIALIZABLE, READCOMMITTED, FASTFIRSTROW, TABLOCK, TABLOCKX, PAGLOCK,<br />
ROWLOCK, NOWAIT, READPAST, XLOCK, and NOEXPAND. When these table hints<br />
are specified without the WITH keyword, the hints should be specified<br />
alone.</p>
<p><strong>For example:</strong><br />
<code><br />
Select * FROM table1 (TABLOCK)</code></p>
<p><code>Select * FROM table1 WITH (TABLOCK, INDEX(myindex))</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/01/13/table-hints-transact-sql/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">236</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Reducing SQL Server Deadlocks</title>
		<link>https://sqlhelp.wordpress.com/2009/01/13/reducing-sql-server-deadlocks/</link>
					<comments>https://sqlhelp.wordpress.com/2009/01/13/reducing-sql-server-deadlocks/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Tue, 13 Jan 2009 11:00:18 +0000</pubDate>
				<category><![CDATA[SQL Deadlocking]]></category>
		<category><![CDATA[MS SQL Deadlocks]]></category>
		<category><![CDATA[NOLOCK]]></category>
		<category><![CDATA[PAGLOCK]]></category>
		<category><![CDATA[ROWLOCK]]></category>
		<category><![CDATA[Solve Deadlocks]]></category>
		<category><![CDATA[SQL Best practices and tips]]></category>
		<category><![CDATA[SQL Deadlocking refers to the condition]]></category>
		<category><![CDATA[SQL Deadlocks]]></category>
		<category><![CDATA[SQL Locks]]></category>
		<category><![CDATA[SQL Tips]]></category>
		<category><![CDATA[SQL Tricks]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=230</guid>

					<description><![CDATA[Deadlocking and SQL best practices: Deadlocking refers to the condition in which one resource is waiting on the action of a second, while that second action is waiting on the first. This is different from being blocked, or having to wait for a resource. Using the locks above, if a transaction had a shared lock, [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Deadlocking and SQL best practices:</strong></p>
<p>Deadlocking refers to the condition in which one resource is waiting on the action of a second, while that second action is waiting on the first. This is different from being blocked, or having to wait for a resource. Using the locks above, if a transaction had a shared lock, then you issued a delete on those same records held by the first lock, you would not be deadlocked. Instead, you would be blocked. When the shared lock was released, your delete statement would complete. Blocking implies some performance hit, but the transaction will complete. It simply has to wait for something else to finish first. A deadlock on the other hand, means there is no way to finish. Your transaction is stuck in a loop with some other transaction. At this point, the database system will usually pick one transaction to be killed so the other can complete.</p>
<p><strong>Here are some tips on how to avoid deadlocking on your SQL Server:</strong></p>
<ul>
<li>Esure the database design is properly normalized.</li>
<li>Have the application access server objects in the same order each time.</li>
<li>During transactions, don&#8217;t allow any user input. Collect it before the transaction begins.</li>
<li>Avoid cursors.</li>
<li>Keep transactions as short as possible. One way to help accomplish this is to reduce the number of round trips between your application and SQL Server by using stored procedures or keeping transactions with a single batch. Another way of reducing the time a transaction takes to complete is to make sure you are not performing the same reads over and over again. If your application does need to read the same data more than once, cache it by storing it in a variable or an array, and then re-reading it from there, not from SQL Server.</li>
<li>Reduce lock time. Try to develop your application so that it grabs locks at the latest possible time, and then releases them at the very earliest time.</li>
<li>If appropriate, reduce lock escalation by using the ROWLOCK or PAGLOCK.</li>
<li>Consider using the NOLOCK hint to prevent locking if the data being locked is not modified often.</li>
<li>If appropriate, use as low of an isolation level as possible for the user connection running the transaction.</li>
<li>Consider using bound connections</li>
<li>Remember to SET NOCOUNT ON at the beginning of your SQL bataches, stored procedures, triggers to avoid network traffic. This will also reduct the chances of error on linked server.</li>
<li>Index should be created on highly selective columns, which are used in JOINS, WHERE and ORDER BY clause.</li>
<li>Use Column name in ORDER BY clause instead of numbers.</li>
<li>Do not use TEXT or NTEXT if possible. In SQL Server 2005 use VARCHAR(MAX) or NVARCHAR(MAX).</li>
<li>Do not use SELECT *, use proper column names to decrease network traffic and fewer locks on table.</li>
</ul>
<blockquote><p>
Use SQL Server Profiler to identify the cause of a deadlock. A deadlock occurs when there is a cyclic dependency between two or more threads, or processes, for some set of resources within SQL Server. Using SQL Server Profiler, you can create a trace that records, replays, and displays deadlock events for analysis.</p>
<p>To trace deadlock events, add the Deadlock graph event class to a trace. This event class populates the TextData data column in the trace with XML data about the process and objects that are involved in the deadlock. SQL Server Profiler can extract the XML document to a deadlock XML (.xdl) file which you can view later in SQL Server Management Studio. You can configure SQL Server Profiler to extract Deadlock graph events to a single file that contains all Deadlock graph events, or to separate files. This extraction can be done in any of the following ways:</p></blockquote>
<ul>
<li>At trace configuration time, using the Events Extraction Settings tab. Note that this tab does not appear until you select the Deadlock graph event on the Events Selection tab.</li>
<li>Using the Extract SQL Server Events option on the File menu.</li>
<li>Individual events can also be extracted and saved by right-clicking a specific event and choosing Extract Event Data.</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/01/13/reducing-sql-server-deadlocks/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">230</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>HOW TO USE  ROLLUP and CUBE</title>
		<link>https://sqlhelp.wordpress.com/2009/01/07/how-to-use-rollup/</link>
					<comments>https://sqlhelp.wordpress.com/2009/01/07/how-to-use-rollup/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Wed, 07 Jan 2009 08:42:51 +0000</pubDate>
				<category><![CDATA[SQL rollup/cube]]></category>
		<category><![CDATA[How to use Rollup in SQL]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MSSQL server]]></category>
		<category><![CDATA[Query sum option]]></category>
		<category><![CDATA[Running total generate]]></category>
		<category><![CDATA[SQL cube]]></category>
		<category><![CDATA[SQL Rollup]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[The differences between CUBE and ROLLUP]]></category>
		<category><![CDATA[What is CUBE]]></category>
		<category><![CDATA[What is Rollup]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=224</guid>

					<description><![CDATA[HOW TO USE CUBE: The CUBE operator generates a result set that is a multidimensional cube. A multidimensional cube is an expansion of fact data, or data that records individual events. The expansion is based on columns that the user wants to analyze. These columns are called dimensions. The cube is a result set containing [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>HOW TO USE  CUBE:</strong></p>
<p>The CUBE operator generates a result set that is a multidimensional cube. A multidimensional cube is an expansion of fact data, or data that records individual events. The expansion is based on columns that the user wants to analyze. These columns are called dimensions. The cube is a result set containing a cross tabulation of all the possible combinations of the dimensions.</p>
<p>The CUBE operator is specified in the GROUP BY clause of a SELECT statement. The select list contains the dimension columns and aggregate function expressions. The GROUP BY specifies the dimension columns and the keywords WITH CUBE. The result set contains all possible combinations of the values in the dimension columns, along with the aggregate values from the underlying rows that match that combination of dimension values.</p>
<p><strong>For example, a simple table Inventory contains:</strong></p>
<pre><code>Item                 Color                Quantity
-------------------- -------------------- --------------------------
Table                Blue                 124
Table                Red                  223
Chair                Blue                 101
Chair                Red                  210</code></pre>
<p>This query returns a result set that contains the Quantity subtotal for all possible combinations of Item and Color:</p>
<p><code>SELECT Item, Color, SUM(Quantity) AS QtySum<br />
FROM Inventory<br />
GROUP BY Item, Color WITH CUBE</code></p>
<p><strong>Here is the result set:</strong></p>
<pre><code>Item                 Color                QtySum
-------------------- -------------------- --------------------------
Chair                Blue                 101.00
Chair                Red                  210.00
Chair                (null)               311.00
Table                Blue                 124.00
Table                Red                  223.00
Table                (null)               347.00
(null)               (null)               658.00
(null)               Blue                 225.00
(null)               Red                  433.00</code></pre>
<p>The following rows from the result set are of special interest:</p>
<p>Chair                (null)               311.00</p>
<p>This row reports a subtotal for all rows having the value Chair in the Item dimension. The value NULL is returned for the Color dimension to show that aggregate reported by the row includes rows with any value of the Color dimension.</p>
<p><code>Table                (null)               347.00</code></p>
<p>This row is similar, but reports the subtotal for all rows having Table in the Item dimension.<br />
<code><br />
(null)               (null)               658.00</code></p>
<p>This row reports the grand total for the cube. Both the Item and Color dimensions have the value NULL showing that all values of both dimensions are summarized in the row.</p>
<p><code>(null)               Blue                 225.00<br />
(null)               Red                  433.00</code></p>
<p>These two rows report the subtotals for the Color dimension. Both have NULL in the Item dimension to show that the aggregate data came from rows having any value for the Item dimension.</p>
<p>Using GROUPING to Distinguish Null Values<br />
The null values generated by the CUBE operation present a problem: How can a NULL generated by the CUBE operation be distinguished from a NULL returned in the actual data? This is achieved using the GROUPING function. The GROUPING function returns 0, if the column value came from the fact data, and 1 if the column value is a NULL generated by the CUBE operation. In a CUBE operation, a generated NULL represents all values. The SELECT statement can be written to use the GROUPING function to substitute the string ALL in place of any generated NULL. Because a NULL from the fact data indicates the data value is unknown, the SELECT can also be coded to return the string UNKNOWN in place of any NULL from the fact data. For example:</p>
<p><code>SELECT CASE WHEN (GROUPING(Item) = 1) THEN 'ALL'<br />
ELSE ISNULL(Item, 'UNKNOWN')<br />
END AS Item,<br />
CASE WHEN (GROUPING(Color) = 1) THEN 'ALL'<br />
ELSE ISNULL(Color, 'UNKNOWN')<br />
END AS Color,<br />
SUM(Quantity) AS QtySum<br />
FROM Inventory<br />
GROUP BY Item, Color WITH CUBE</code></p>
<p>Multidimensional Cubes<br />
The CUBE operator can be used to generate n-dimensional cubes, or cubes with any number of dimensions. A single dimension cube can be used to generate a total, for example:</p>
<p><code>SELECT CASE WHEN (GROUPING(Item) = 1) THEN 'ALL'<br />
ELSE ISNULL(Item, 'UNKNOWN')<br />
END AS Item,<br />
SUM(Quantity) AS QtySum<br />
FROM Inventory<br />
GROUP BY Item WITH CUBE<br />
GO</code></p>
<p>This SELECT statement returns a result set showing both the subtotals for each value of Item and the grand total for all values of Item:</p>
<pre><code>Item                 QtySum
-------------------- --------------------------
Chair                311.00
Table                347.00
ALL                  658.00</code></pre>
<p>SELECT statements that contain a CUBE with many dimensions can generate large result sets, because these statements generate rows for all combinations of the values in all the dimensions. These large result sets may contain too much data to be easily read and understood. One solution to this problem is to put the SELECT statement into a view:<br />
<code><br />
CREATE VIEW InvCube AS<br />
SELECT CASE WHEN (GROUPING(Item) = 1) THEN 'ALL'<br />
ELSE ISNULL(Item, 'UNKNOWN')<br />
END AS Item,<br />
CASE WHEN (GROUPING(Color) = 1) THEN 'ALL'<br />
ELSE ISNULL(Color, 'UNKNOWN')<br />
END AS Color,<br />
SUM(Quantity) AS QtySum<br />
FROM Inventory<br />
GROUP BY Item, Color WITH CUBE</code></p>
<p>The view can then be used to query only the dimension values of interest:</p>
<p><code>SELECT *<br />
FROM InvCube<br />
WHERE Item = 'Chair'<br />
AND Color = 'ALL'</code></p>
<pre>Item                 Color                QtySum
-------------------- -------------------- --------------------------
Chair                ALL                  311.00</pre>
<p><strong>HOW TO USE  ROLLUP:</strong></p>
<p>The ROLLUP operator is useful in generating reports that contain subtotals and totals. The ROLLUP operator generates a result set that is similar to the result sets generated by the CUBE operator. For more information, see Summarizing Data Using CUBE.</p>
<p>The differences between CUBE and ROLLUP are:</p>
<p>CUBE generates a result set showing aggregates for all combinations of values in the selected columns.</p>
<p>ROLLUP generates a result set showing aggregates for a hierarchy of values in the selected columns.<br />
For example, a simple table Inventory contains:</p>
<pre><code>Item                 Color                Quantity</code>
<code>-------------------- -------------------- --------------------------</code>
<code>Table                Blue                 124</code>
<code>Table                Red                  223</code>
<code>Chair                Blue                 101</code>
<code>Chair                Red                  210</code></pre>
<p><strong>This query generates a subtotal report:</strong></p>
<p><code>SELECT CASE WHEN (GROUPING(Item) = 1) THEN 'ALL'<br />
ELSE ISNULL(Item, 'UNKNOWN')<br />
END AS Item,<br />
CASE WHEN (GROUPING(Color) = 1) THEN 'ALL'<br />
ELSE ISNULL(Color, 'UNKNOWN')<br />
END AS Color,<br />
SUM(Quantity) AS QtySum<br />
FROM Inventory<br />
GROUP BY Item, Color WITH ROLLUP</code></p>
<pre><code>Item                 Color                QtySum
-------------------- -------------------- --------------------------
Chair                Blue                 101.00
Chair                Red                  210.00
Chair                ALL                  311.00
Table                Blue                 124.00
Table                Red                  223.00
Table                ALL                  347.00
ALL                  ALL                  658.00</code></pre>
<pre>(7 row(s) affected)</pre>
<p>If the ROLLUP keyword in the query is changed to CUBE, the CUBE result set is the same, except these two additional rows are returned at the end:</p>
<p><code>ALL                  Blue                 225.00<br />
ALL                  Red                  433.00</code></p>
<p>The CUBE operation generated rows for possible combinations of values from both Item and Color. For example, not only does CUBE report all possible combinations of Color values combined with the Item value Chair (Red, Blue, and Red + Blue), it also reports all possible combinations of Item values combined with the Color value Red (Chair, Table, and Chair + Table).</p>
<p>For each value in the columns on the right in the GROUP BY clause, the ROLLUP operation does not report all possible combinations of values from the column (or columns) on the left. For example, ROLLUP does not report all the possible combinations of Item values for each Color value.</p>
<p>The result set of a ROLLUP operation has functionality similar to that returned by a COMPUTE BY; however, ROLLUP has these advantages:</p>
<p>ROLLUP returns a single result set; COMPUTE BY returns multiple result sets that increase the complexity of application code.</p>
<p>ROLLUP can be used in a server cursor; COMPUTE BY cannot.</p>
<p>The query optimizer can sometimes generate more efficient execution plans for ROLLUP than it can for COMPUTE BY.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2009/01/07/how-to-use-rollup/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">224</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL running serial generating tips</title>
		<link>https://sqlhelp.wordpress.com/2008/12/31/sql-running-serial-generating-tips/</link>
					<comments>https://sqlhelp.wordpress.com/2008/12/31/sql-running-serial-generating-tips/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Wed, 31 Dec 2008 07:48:41 +0000</pubDate>
				<category><![CDATA[SQL ROW_NUMBER]]></category>
		<category><![CDATA[Generate Row number]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MSSQL server]]></category>
		<category><![CDATA[ROW_NUMBER()]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[SQL running serial]]></category>
		<category><![CDATA[SQL running serial generating]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tricks]]></category>
		<category><![CDATA[sqlhelp]]></category>
		<category><![CDATA[SQLtips]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=221</guid>

					<description><![CDATA[SQL running serial generating tips: Traditionally developers and Database administrators used temporary tables and co-related sub-queries to generate calculated row numbers in a query. Now SQL Server 2005 provides a function, which replaces all of the additional resources we used to generate row numbers. Returns the sequential number of a row within a partition of [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>SQL running serial generating tips</strong>:</p>
<p><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><span style="font-family:Verdana,Arial,Helvetica,sans-serif;">Traditionally developers and Database administrators used temporary tables and co-related sub-queries to generate calculated row numbers in a query. Now SQL Server 2005 provides a function, which replaces all of the additional resources we used to generate row numbers.</span></span></p>
<blockquote><p>Returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition.</p></blockquote>
<p><strong>Example:</strong></p>
<p><code>select ROW_NUMBER() OVER(ORDER BY CLM1),* from Table1</code></p>
<p><strong>Remark: </strong></p>
<div id="ctl00_rs1_mainContentContainer_cpe52969_c" class="MTPS_CollapsibleSection" style="overflow:visible;display:block;height:auto;width:982.7px;">
<div class="MTPS_CollapsibleSection" style="display:block;"><a id="remarksToggle"></a>The ORDER BY clause determines the sequence in which the rows are assigned their unique<br />
ROW_NUMBER within a specified partition.</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2008/12/31/sql-running-serial-generating-tips/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">221</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Enable remote connection SQL Server</title>
		<link>https://sqlhelp.wordpress.com/2008/12/26/enable-remote-connection-sql-server/</link>
					<comments>https://sqlhelp.wordpress.com/2008/12/26/enable-remote-connection-sql-server/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Fri, 26 Dec 2008 11:50:30 +0000</pubDate>
				<category><![CDATA[SQL remote connection]]></category>
		<category><![CDATA[An error has occurred while establishing a connection to the server]]></category>
		<category><![CDATA[connection SQL Server]]></category>
		<category><![CDATA[Enable remote connection SQL Server]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MSSQL server]]></category>
		<category><![CDATA[problem in remote connection SQL Server]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips]]></category>
		<category><![CDATA[SQL Tricks]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=217</guid>

					<description><![CDATA[Error Description :: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 &#8211; Could not open a connection to SQL Server) [&#8230;]]]></description>
										<content:encoded><![CDATA[<blockquote>
<h3><strong>Error Description ::</strong></h3>
<p>An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 &#8211; Could not open a connection to SQL Server)</p></blockquote>
<h3>Enable remote connections for SQL Server 2005 Express or SQL Server 2005 Developer Edition</h3>
<p>You must enable remote connections for each instance of SQL Server 2005 that you want to connect to from a remote computer. To do this, follow these steps:</p>
<ol>
<li>Click <strong class="uiterm">Start</strong>, point to <strong class="uiterm">Programs</strong>, point to <strong class="uiterm">Microsoft SQL Server 2005</strong>, point to <strong class="uiterm">Configuration Tools</strong>, and then click <strong class="uiterm">SQL Server Surface Area Configuration</strong>.</li>
<li>On the <strong class="uiterm">SQL Server 2005 Surface Area Configuration</strong> page, click <strong class="uiterm">Surface Area Configuration for Services and Connections</strong>.</li>
<li>On the <strong class="uiterm">Surface Area Configuration for Services and Connections</strong> page, expand <strong class="uiterm">Database Engine</strong>,  click <strong class="uiterm">Remote Connections</strong>, click <strong class="uiterm">Local and remote connections</strong>, click the appropriate protocol to enable for your environment, and then click <strong class="uiterm">Apply</strong>.<strong>Note</strong> Click <strong class="uiterm">OK</strong> when you receive the following message:
<div class="message">Changes to Connection Settings will not take effect until you restart the Database Engine service.</div>
</li>
<li>On the <strong class="uiterm">Surface Area Configuration for Services and Connections</strong> page, expand <strong class="uiterm">Database Engine</strong>,  click <strong class="uiterm">Service</strong>, click <strong class="uiterm">Stop</strong>, wait until the MSSQLSERVER service stops, and then click <strong class="uiterm">Start</strong> to restart the MSSQLSERVER service.</li>
</ol>
<h3>Enable the SQL Server Browser service:</h3>
<ol>
<li>Click <strong class="uiterm">Start</strong>, point to <strong class="uiterm">Programs</strong>, point to <strong class="uiterm">Microsoft SQL Server 2005</strong>, point to <strong class="uiterm">Configuration Tools</strong>, and then click <strong class="uiterm">SQL Server Surface Area Configuration</strong>.</li>
<li>On the <strong class="uiterm">SQL Server 2005 Surface Area Configuration</strong> page, click <strong class="uiterm">Surface Area Configuration for Services and Connections</strong>.</li>
<li>On the <strong class="uiterm">Surface Area Configuration for Services and Connections</strong> page, click <strong class="uiterm">SQL Server Browser</strong>, click <strong class="uiterm">Automatic</strong> for <strong class="uiterm">Startup type</strong>, and then click <strong class="uiterm">Apply</strong>.<strong>Note</strong> When you click the <strong class="uiterm">Automatic</strong> option, the SQL Server Browser service starts automatically every time that you start Microsoft Windows.</li>
<li>Click <strong class="uiterm">Start</strong>, and then click <strong class="uiterm">OK</strong>.</li>
</ol>
<h3>Create exceptions in Windows Firewall:</h3>
<ol>
<li>Click <strong class="uiterm">Start</strong>, point to <strong class="uiterm">Programs</strong>, point to <strong class="uiterm">Microsoft SQL Server 2005</strong>, point to <strong class="uiterm">Configuration Tools</strong>, and then click <strong class="uiterm">SQL Server Configuration Manager</strong>.</li>
<li>In SQL Server Configuration Manager, click the SQL Server Browser service in the right pane, right-click the instance name in the main window, and then click <strong class="uiterm">Properties</strong>.</li>
<li>On the <strong class="uiterm">SQL Server Browser Properties</strong> page, click the <strong class="uiterm">Advanced</strong> tab, locate the instance ID in the property list, and then click <strong class="uiterm">OK</strong>.</li>
</ol>
<p>To open Windows Firewall, click <strong class="uiterm">Start</strong>, click <strong class="uiterm">Run</strong>, type <span class="userInput">firewall.cpl</span>, and then click <strong class="uiterm">OK</strong></p>
<h4>Create an exception for SQL Server 2005 in Windows Firewall</h4>
<p>To create an exception for SQL Server 2005 in Windows Firewall, follow these steps:</p>
<ol>
<li>In Windows Firewall, click the <strong class="uiterm">Exceptions</strong> tab, and then click <strong class="uiterm">Add Program</strong>.</li>
<li>In the Add a Program window, click <strong class="uiterm">Browse</strong>.</li>
<li> Click the C:Program FilesMicrosoft SQL Server<var>MSSQL.1</var>MSSQLBinnsqlservr.exe executable program, click <strong class="uiterm">Open</strong>, and then click <strong class="uiterm">OK</strong>.<strong>Note</strong> The path may be different depending on where SQL Server 2005 is installed. <var>MSSQL.1</var> is a placeholder for the instance ID that you obtained in step 3  of the previous procedure.</li>
<li>Repeat steps 1 through 3 for each instance of SQL Server 2005 that needs an exception.</li>
</ol>
<h4>Create an exception for the SQL Server Browser service in Windows Firewall</h4>
<p>To create an exception for the SQL Server Browser service in Windows Firewall, follow these steps:</p>
<ol>
<li>In Windows Firewall, click the <strong class="uiterm">Exceptions</strong> tab, and then click <strong class="uiterm">Add Program</strong>.</li>
<li>In the Add a Program window, click <strong class="uiterm">Browse</strong>.</li>
<li>Click the C:Program FilesMicrosoft SQL Server90Sharedsqlbrowser.exe executable program, click <strong class="uiterm">Open</strong>, and then click <strong class="uiterm">OK</strong>.</li>
</ol>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2008/12/26/enable-remote-connection-sql-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">217</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Case sensitive comparisons in SQL</title>
		<link>https://sqlhelp.wordpress.com/2008/12/24/case-sensitive-comparisons-in-sql/</link>
					<comments>https://sqlhelp.wordpress.com/2008/12/24/case-sensitive-comparisons-in-sql/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Wed, 24 Dec 2008 08:52:53 +0000</pubDate>
				<category><![CDATA[SQL String comparisons]]></category>
		<category><![CDATA[BINARY_CHECKSUM]]></category>
		<category><![CDATA[Case sensitive comparisons in SQL]]></category>
		<category><![CDATA[comparisons in SQL]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MSSQL BINARY_CHECKSUM]]></category>
		<category><![CDATA[MSSQL server]]></category>
		<category><![CDATA[MSSQL string compare]]></category>
		<category><![CDATA[MSSQL String comparisons tips]]></category>
		<category><![CDATA[SQL  best way to compare string]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL varbinary method]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=211</guid>

					<description><![CDATA[Case sensitive comparisons in SQL Server Some time we need to compare some data in binary see the examples: SELECT *  FROM TABLE1 WITH (NOLOCK) WHERE convert(varbinary(255), PASS) = convert(varbinary(255), 'RAGHU') Normal comparison: SELECT *  FROM TABLE1 WITH (NOLOCK) WHERE convert(varbinary(255), PASS) = convert(varbinary(255), 'Raghu') AND PASS= 'TEST' Uuse the BINARY_CHECKSUM function: SELECT *  FROM [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Case sensitive comparisons in SQL Server</strong></p>
<p>Some time we need to compare some data in binary see the examples:</p>
<p><code>SELECT *  FROM TABLE1 WITH (NOLOCK) WHERE convert(varbinary(255), PASS) = convert(varbinary(255), 'RAGHU')</code></p>
<p><strong>Normal comparison:</strong></p>
<p><code>SELECT *  FROM TABLE1 WITH (NOLOCK)</code><code> WHERE convert(varbinary(255), </code><code>PASS</code><code>) = convert(varbinary(255), 'Raghu</code><code>') AND </code><code>PASS</code><code>= '</code><code>TEST</code><code>'</code></p>
<p><strong>Uuse the BINARY_CHECKSUM function:<br />
</strong></p>
<p><code>SELECT *  FROM TABLE1 WITH (NOLOCK)</code><code> WHERE BINARY_CHECKSUM(answer) = BINARY_CHECKSUM('</code><code>TEST</code><code>')</code><strong><br />
</strong></p>
<p><strong>Use SQL Server case insensitive collation:</strong></p>
<p><code>SELECT *  FROM TABLE1 WITH (NOLOCK)</code><code> WHERE PASSWORD COLLATE SQL_Latin1_General_CP1_CS_AS = 'RAGHU</code><code>' COLLATE SQL_Latin1_General_CP1_CS_AS</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2008/12/24/case-sensitive-comparisons-in-sql/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">211</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Sub Query Update</title>
		<link>https://sqlhelp.wordpress.com/2008/12/19/sub-query-update/</link>
					<comments>https://sqlhelp.wordpress.com/2008/12/19/sub-query-update/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Fri, 19 Dec 2008 10:33:48 +0000</pubDate>
				<category><![CDATA[SQL Subquery]]></category>
		<category><![CDATA[Stored Procedures]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MSSQL server]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL update with join]]></category>
		<category><![CDATA[Sub Query Update]]></category>
		<category><![CDATA[tow table update]]></category>
		<category><![CDATA[UPDATE statement using a join]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=208</guid>

					<description><![CDATA[Sub Query Update: if you want to run update query in join or by comparing other table then here is the example. UPDATE Table1 SET Price = Price * 2 WHERE ProductID IN (SELECT ID FROM Table2 WHERE ID= 51); GO Here is an equivalent UPDATE statement using a join: USE AdventureWorks; GO UPDATE Table1 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Sub Query Update:</strong><br />
if you want to run update query in join or by comparing other table then here is the example.</p>
<pre class="libCScode" style="white-space:pre-wrap;">UPDATE Table1
SET Price = Price * 2
WHERE ProductID IN
    (SELECT ID
     FROM Table2
     WHERE ID= 51);
GO</pre>
<p><strong>Here is an equivalent UPDATE statement using a join:</strong></p>
<pre class="libCScode" style="white-space:pre-wrap;">USE AdventureWorks;
GO
UPDATE Table1
SET Price = Price * 2
FROM Table1 AS t1
INNER JOIN Table2 AS t2
    ON t1.ProductID = t2.ProductID AND t2.ID= 51;
GO</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2008/12/19/sub-query-update/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">208</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>BEGIN TRANSACTION (Transact-SQL)</title>
		<link>https://sqlhelp.wordpress.com/2008/12/19/begin-transaction-transact-sql/</link>
					<comments>https://sqlhelp.wordpress.com/2008/12/19/begin-transaction-transact-sql/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Fri, 19 Dec 2008 06:23:57 +0000</pubDate>
				<category><![CDATA[BEGIN TRANSACTION]]></category>
		<category><![CDATA[Author Raghunath Bhandari]]></category>
		<category><![CDATA[COMMIT TRANSACTION]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MSSQL server]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[SQL roll back]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=203</guid>

					<description><![CDATA[BEGIN TRANSACTION represents a point at which the data referenced by a connection is logically and physically consistent. If errors are encountered, all data modifications made after the BEGIN TRANSACTION can be rolled back to return the data to this known state of consistency. Each transaction lasts until either it completes without errors and COMMIT [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>BEGIN TRANSACTION represents a point at which the data referenced by a connection is logically and physically consistent. If errors are encountered, all data modifications made after the BEGIN TRANSACTION can be rolled back to return the data to this known state of consistency. Each transaction lasts until either it completes without errors and COMMIT TRANSACTION is issued to make the modifications a permanent part of the database, or errors are encountered and all modifications are erased with a ROLLBACK TRANSACTION statement.</p>
<p><strong>Syntax:</strong></p>
<pre class="libCScode">BEGIN { TRAN | TRANSACTION }
    [ { transaction_name | @tran_name_variable }
      [ WITH MARK [ 'description' ] ]
    ]
[ ; ]</pre>
<p><strong>Example:</strong></p>
<p>You can catch your error in T-SQL as per my experience</p>
<pre>-- Exec spa_begintrnExample 'a'

<code>Create Proc spa_begintrnExample
@flag char(1)

AS
if @flag='a'
begin

BEGIN TRANSACTION

Update table set clm1='test'
IF (@@ERROR &lt;&gt; 0) GOTO QuitWithRollback 

Update table2 set clm12='test'
IF (@@ERROR &lt;&gt; 0) GOTO QuitWithRollback 

Delete from table3 where clm1='test'
IF (@@ERROR &lt;&gt; 0) GOTO QuitWithRollback 

Delete from table4 set clm1='test'
IF (@@ERROR &lt;&gt; 0) GOTO QuitWithRollback 

COMMIT TRANSACTION

GOTO  EndSave

QuitWithRollback:
  IF (@@TRANCOUNT &gt; 0) ROLLBACK TRANSACTION
EndSave: 

end</code></pre>
<p><strong>Remarks:<br />
</strong><br />
The local transaction started by the BEGIN TRANSACTION statement is escalated to a distributed transaction if the following actions are performed before the statement is committed or rolled back:</p>
<ul>
<li> An INSERT, DELETE, or UPDATE statement that references a remote table on a linked server is executed. The INSERT, UPDATE, or DELETE statement fails if the OLE DB provider used to access the linked server does not support the <strong>ITransactionJoin</strong> interface.</li>
<li> A call is made to a remote stored procedure when the REMOTE_PROC_TRANSACTIONS option is set to ON.</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2008/12/19/begin-transaction-transact-sql/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">203</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL RAND Function</title>
		<link>https://sqlhelp.wordpress.com/2008/12/14/sql-rand-function/</link>
					<comments>https://sqlhelp.wordpress.com/2008/12/14/sql-rand-function/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Sun, 14 Dec 2008 05:12:02 +0000</pubDate>
				<category><![CDATA[SQL RAND Function]]></category>
		<category><![CDATA[Advance SQL tips and tricks]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Database Optimization Tips]]></category>
		<category><![CDATA[dba]]></category>
		<category><![CDATA[Introduction to SQL]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MSSQL server]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Database Optimization Tricks]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[SQL Optimization]]></category>
		<category><![CDATA[SQL Optimization Tips]]></category>
		<category><![CDATA[SQL Programming]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL server tips]]></category>
		<category><![CDATA[SQL technology]]></category>
		<category><![CDATA[SQL Tips]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQL tips for programmer]]></category>
		<category><![CDATA[sqlhelp]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[what is SQL]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=196</guid>

					<description><![CDATA[SQL RAND Function The SQL RAND() function is used to generate some random numbers at run time. Here is the syntax: Syntax RAND ( [ seed ] ) Repetitive calls of RAND() with the same seed value return the same results. For one connection, if RAND() is called with a specified seed value, all subsequent [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong> SQL RAND Function</strong></p>
<p>The SQL RAND() function is used to generate some random numbers at run time. Here is the syntax:</p>
<p><strong>Syntax</strong></p>
<pre>RAND <strong>(</strong> [ <em>seed </em>] <strong>)</strong></pre>
<p>Repetitive calls of RAND() with the same seed value return the same results.</p>
<p>For one connection, if RAND() is called with a specified seed value, all   subsequent calls of RAND() produce results based on the seeded RAND() call. For example,   the following query will always return the same sequence of numbers.</p>
<pre>SELECT RAND(100), RAND(), RAND()</pre>
<p><strong>Examples</strong>:</p>
<p>The following example produces four different random numbers that   are generated by the RAND function.</p>
<pre>DECLARE @counter smallint
SET @counter = 1
WHILE @counter &lt; 5
BEGIN
SELECT RAND() Random_Number
SET @counter = @counter + 1
END
GO</pre>
<p>The following example returns random float numbers based on three   different seed values.</p>
<pre>CREATE TABLE Random (Seed1 float, Seed5 float, Seed10 float)
INSERT INTO Random Values (RAND(1), RAND(5), RAND(10))
SELECT * FROM Random</pre>
<p>The RAND   function is a pseudorandom number generator that operates in a manner similar to   the C run-time library <strong>rand</strong> function. If no seed is provided, the system   generates its own variable seed numbers. If you call RAND with a seed value,   you must use variable seed values to generate random numbers. If you call RAND multiple times with   the same seed value, it returns the same generated value. The following script   returns the same value for the calls to RAND because they all use the same seed value:</p>
<pre>SELECT RAND(159784)
SELECT RAND(159784)
SELECT RAND(159784)</pre>
<p>A common way to generate random numbers from RAND is to include   something relatively variable as the seed value, such as adding several parts of   a GETDATE:</p>
<pre>SELECT RAND( (DATEPART(mm, GETDATE()) * 100000 )
+ (DATEPART(ss, GETDATE()) * 1000 )
+ DATEPART(ms, GETDATE()) )</pre>
<blockquote><p>When you use an algorithm based on GETDATE to generate seed values, RAND can still generate   duplicate values if the calls to RAND are made within the interval of the smallest datepart   used in the algorithm. This is especially likely when the calls to RAND are included in a   single batch. Multiple calls to RAND in a single batch can be executed within the same   millisecond. This is the smallest increment of DATEPART. In this case,   incorporate a value based on something other than time to generate the seed   values.</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2008/12/14/sql-rand-function/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">196</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>How to use Bulk Insert</title>
		<link>https://sqlhelp.wordpress.com/2008/12/12/how-to-use-bulk-insert/</link>
					<comments>https://sqlhelp.wordpress.com/2008/12/12/how-to-use-bulk-insert/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Fri, 12 Dec 2008 05:14:38 +0000</pubDate>
				<category><![CDATA[Bulk Insert]]></category>
		<category><![CDATA[Advance SQL tips and tricks]]></category>
		<category><![CDATA[BCP T-SQL]]></category>
		<category><![CDATA[BCP Utility in SQL server]]></category>
		<category><![CDATA[Bulk Insert in SQL]]></category>
		<category><![CDATA[DBA help]]></category>
		<category><![CDATA[How to use BCP in SQL]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MSSQL server]]></category>
		<category><![CDATA[SQL Database Settings Optimization Tips]]></category>
		<category><![CDATA[SQL developer tips]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[SQL Indexing Service]]></category>
		<category><![CDATA[SQL Optimization]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL server tips]]></category>
		<category><![CDATA[SQL Tips]]></category>
		<category><![CDATA[sqlhelp]]></category>
		<category><![CDATA[upload CSV file in SQL]]></category>
		<category><![CDATA[upload text file in SQL]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=192</guid>

					<description><![CDATA[Introduction Bulk Insert: The Bulk Insert task provides the quickest way to copy large amounts of data into a SQL Server table or view. For example, suppose your company stores its million-row product list on a mainframe system, but the company&#8217;s e-commerce system uses SQL Server 2005 to populate Web pages. You must update the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong><span>Introduction Bulk Insert:<br />
</span></strong><br />
The Bulk Insert task provides the quickest way to copy large amounts of data   into a SQL Server table or view. For example, suppose your company stores its   million-row product list on a mainframe system, but the company&#8217;s e-commerce   system uses SQL Server 2005 to populate Web pages. You must update the SQL   Server product table nightly with the master product list from the mainframe. To   update the table, you save the product list in a tab-delimited format and use   the Bulk Insert task to copy the data directly into the SQL Server table.</p>
<p>To ensure high-speed data copying, transformations cannot be performed on the   data while it is moving from the source file to the table or view.</p>
<p>You can configure the Bulk Insert task in the following ways:</p>
<ul>
<li>Specify the OLE DB connection manager to connect to the destination SQL   Server database and the table or view into which data is inserted.</li>
<li>Specify the File or Flat File connection manager to access the source file   and provide information about the source data file, such as the code page and   file type.</li>
<li>Define the format used by the Bulk Insert task, either by using a format   file or by defining the column and row delimiters of the source data. If using a   format file, specify the File connection manager to access the format   file.</li>
<li>Specify actions to perform on the destination table or view when inserting   the data. The options include whether to check constraints, enable identity   inserts, keep nulls, fire triggers, or lock the table.</li>
<li>Provide information about the batch of data to insert, such as the batch   size, the first and last row from the file to insert, the number of insert   errors that can occur before the task stops inserting rows, and the names of the   columns that will be sorted.</li>
</ul>
<blockquote><p>If the Bulk Insert task uses a Flat File connection manager to access the   source file, the task does not use the format specified in the Flat File   connection manager. Instead, the Bulk Insert task uses either the format   specified in a format file, or the values of the <strong>RowDelimiter</strong> and <strong>ColumnDelimiter</strong> properties of the task.</p></blockquote>
<p><strong>BULK INSERT (Transact-SQL)</strong></p>
<pre>BULK INSERT
   [ database_name . [ schema_name ] . | schema_name . ] [ table_name | view_name ]
      FROM 'data_file'
     [ WITH
    (
   [ [ , ] BATCHSIZE = batch_size ]
   [ [ , ] CHECK_CONSTRAINTS ]
   [ [ , ] CODEPAGE = { 'ACP' | 'OEM' | 'RAW' | 'code_page' } ]
   [ [ , ] DATAFILETYPE  =
      { 'char' | 'native'| 'widechar' | 'widenative' } ]
   [ [ , ] FIELDTERMINATOR = 'field_terminator' ]
   [ [ , ] FIRSTROW  =first_row ]
   [ [ , ] FIRE_TRIGGERS ]
   [ [ , ] FORMATFILE = 'format_file_path' ]
   [ [ , ] KEEPIDENTITY ]
   [ [ , ] KEEPNULLS ]
   [ [ , ] KILOBYTES_PER_BATCH =kilobytes_per_batch ]
   [ [ , ] LASTROW = last_row ]
   [ [ , ] MAXERRORS = max_errors ]
   [ [ , ] ORDER ( { column [ ASC | DESC ] } [ ,...n ] ) ]
   [ [ , ] ROWS_PER_BATCH = rows_per_batch ]
   [ [ , ] ROWTERMINATOR = 'row_terminator' ]
   [ [ , ] TABLOCK ]
   [ [ , ] ERRORFILE = 'file_name' ]
    )]</pre>
<p><strong>Examples</strong></p>
<p><strong> A. Using pipes to import data from a file</strong>:</p>
<p>This example imports order detail information into the   AdventureWorks.Sales.SalesOrderDetail table from the specified data   file by using a pipe (|) as the field terminator and |n as the row terminator.</p>
<pre>BULK INSERT AdventureWorks.Sales.SalesOrderDetail     
FROM 'f:orderslineitem.txt'     
WITH         
(           
FIELDTERMINATOR =' |',           
ROWTERMINATOR =' |n'        
)</pre>
<p><strong>B. Using the FIRE_TRIGGERS argument</p>
<p></strong>This example specifies the FIRE_TRIGGERS argument.</p>
<pre>BULK INSERT AdventureWorks.Sales.SalesOrderDetail     
FROM 'f:orderslineitem.txt'     
WITH       
(          
FIELDTERMINATOR =' |',          
ROWTERMINATOR = ':n',          
FIRE_TRIGGERS        )</pre>
<p><strong>C. Using line feed as a row terminator </strong></p>
<p>This example loads a file that uses the line feed as a row terminator such as a UNIX output:</p>
<pre>DECLARE @bulk_cmd varchar(1000)  
SET @bulk_cmd = 'BULK INSERT AdventureWorks.Sales.SalesOrderDetail  
FROM ''&lt;drive&gt;:&lt;path&gt;&lt;filename&gt;''   
WITH (ROWTERMINATOR = '''+CHAR(10)+''')'  
EXEC(@bulk_cmd)</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2008/12/12/how-to-use-bulk-insert/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">192</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>What is BCP Utility in SQL server?</title>
		<link>https://sqlhelp.wordpress.com/2008/12/12/what-is-bcp-utility-in-sql-server/</link>
					<comments>https://sqlhelp.wordpress.com/2008/12/12/what-is-bcp-utility-in-sql-server/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Fri, 12 Dec 2008 05:09:12 +0000</pubDate>
				<category><![CDATA[BCP Utility]]></category>
		<category><![CDATA[Advance SQL tips and tricks]]></category>
		<category><![CDATA[BCP T-SQL]]></category>
		<category><![CDATA[BCP Utility in SQL server]]></category>
		<category><![CDATA[DBA help]]></category>
		<category><![CDATA[How to use BCP in SQL]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MSSQL server]]></category>
		<category><![CDATA[SQL Database Settings Optimization Tips]]></category>
		<category><![CDATA[SQL developer tips]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[SQL Indexing Service]]></category>
		<category><![CDATA[SQL Optimization]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL server tips]]></category>
		<category><![CDATA[SQL Tips]]></category>
		<category><![CDATA[sqlhelp]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=188</guid>

					<description><![CDATA[Introduction BCP Utility: The bcp utility bulk copies data between an instance of Microsoft SQL Server 2005 and a data file in a user-specified format. The bcp utility can be used to import large numbers of new rows into SQL Server tables or to export data out of tables into data files. Except when used [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Introduction BCP Utility:</strong></p>
<p>The bcp utility bulk copies data between an instance of Microsoft SQL Server 2005 and a   data file in a user-specified format. The bcp utility can be   used to import large numbers of new rows into SQL Server tables or to export   data out of tables into data files. Except when used with the queryout option, the utility requires no knowledge of Transact-SQL. To import data into a   table, you must either use a format file created for that table or understand   the structure of the table and the types of data that are valid for its columns.</p>
<p><strong>Syntax</strong>:</p>
<pre>bcp {[[database_name.][owner].]{table_name | view_name} | "query"}
    {in | out | queryout | format} data_file
    [-mmax_errors] [-fformat_file] [-x] [-eerr_file]
    [-Ffirst_row] [-Llast_row] [-bbatch_size]
    [-n] [-c] [-w] [-N] [-V (60 | 65 | 70 | 80)] [-6]
    [-q] [-C { ACP | OEM | RAW | code_page } ] [-tfield_term]
    [-rrow_term] [-iinput_file] [-ooutput_file] [-apacket_size]
    [-Sserver_name[instance_name]] [-Ulogin_id] [-Ppassword]
    [-T] [-v] [-R] [-k] [-E] [-h"hint [,...n]"]</pre>
<p><strong>Examples</strong>:</p>
<p><strong>Copying Table Rows into a Data File (with a   Trusted Connection)</strong></p>
<p>The following example illustrates the out option on the   AdventureWorks.Sales.Currency table. This example creates a data   file named Currency.dat and copies the table data into it using   character format. The example assumes that you are using Windows Authentication   and have a trusted connection to the server instance on which you are running   the bcp command.</p>
<p>At a command prompt, enter the following command:</p>
<pre>bcp AdventureWorks.Sales.Currency out Currency.dat -T -c</pre>
<p><strong><br />
Copying Table Rows into a Data File (with   Mixed-Mode Authentication)</strong></p>
<p>The following example illustrates the out option on the   AdventureWorks.Sales.Currency table. This example creates a data   file named Currency.dat and copies the table data into it using   character format.</p>
<blockquote><p>he example assumes that you are using mixed-mode authentication, you   must use the -U switch to specify your login ID. Also, unless you are   connecting to the default instance of SQL Server on the local computer, use the -S switch to specify the system name and, optionally, an instance   name.</p></blockquote>
<pre>bcp AdventureWorks.Sales.Currency out 
Currency.dat -c -U<em>&lt;login_id&gt; -S&lt;server_nameinstance_name&gt;</em></pre>
<p>The system will prompt you for your password.</p>
<p><strong>Copying Data from a File to a Table</strong></p>
<p>The following example illustrates the in option by using the   file created in the preceding example (Currency.dat). First,   however, this example creates an empty copy of the AdventureWorks   Sales.Currency table, Sales.Currency2, into which the data   is copied. The example assumes that you are using Windows Authentication and   have a trusted connection to the server instance on which you are running the bcp command.</p>
<p>To create the empty table, in Query Editor, enter the following   command:</p>
<pre>USE AdventureWorks;
GO
SELECT * INTO AdventureWorks.Sales.Currency2
FROM AdventureWorks.Sales.Currency WHERE 1=2</pre>
<p>To bulk copy the character data into the new table&#8211;that is, to   import the data&#8211;enter the following command at a command prompt:</p>
<pre>bcp AdventureWorks.Sales.Currency2 
in Currency.dat -T -c</pre>
<p>To verify that the command succeeded, display the contents of the   table in Query Editor, and enter</p>
<pre>USE AdventureWorks;
GO
SELECT * FROM Sales.Currency2</pre>
<p><strong><br />
Copying a Specific Column into a Data File</strong></p>
<p>To copy a specific column, you can use the queryout option.   The following example copies only the Name column of the   Sales.Currency table into a data file. The example assumes that you   are using Windows Authentication and have a trusted connection to the server   instance on which you are running the bcp command.</p>
<p>At the Windows command prompt, enter:</p>
<pre>bcp "SELECT Name FROM AdventureWorks.Sales.Currency" 
queryout Currency.Name.dat -T -c</pre>
<p><strong><br />
</strong></p>
<p><strong>Copying Data From a Query to a Data File</strong></p>
<p>To copy the result set from a Transact-SQL statement to a data file,   use the queryout option. The following example copies the names from the   AdventureWorks.Person.Contact table, ordered by last name then   first name, into the Contacts.txt data file. The example assumes   that you are using Windows Authentication and have a trusted connection to the   server instance on which you are running the bcp command.</p>
<p>At the Windows command prompt, enter:</p>
<pre>bcp "SELECT FirstName, LastName FROM 
AdventureWorks.Person.Contact 
ORDER BY LastName, Firstname" 
queryout Contacts.txt -c -T</pre>
<p><strong><br />
Creating a Non-XML Format File</strong></p>
<p>a non-XML format file, Currency.fmt, for the   Sales.Currency table in the AdventureWorks database.   The example assumes that you are using Windows Authentication and have a trusted   connection to the server instance on which you are running the bcp command.</p>
<p>At the Windows command prompt, enter:</p>
<pre>bcp AdventureWorks.Sales.Currency 
format nul -T -c  -f Currency.fmt</pre>
<p><strong></strong></p>
<p><strong>Creating an XML Format File</strong></p>
<p>The following example creates an XML format file named   Currency.xml for the Sales.Currency table in the   AdventureWorks database. The example assumes that you are using   Windows Authentication and have a trusted connection to the server instance on   which you are running the bcp command.</p>
<p>At the Windows command prompt, enter:</p>
<pre>bcp AdventureWorks.Sales.Currency 
format nul -T -c -x -f Currency.xml</pre>
<p><strong></strong></p>
<p><strong>Using a Format File to Bulk Import with bcp</strong></p>
<p>To use a previously created format file when importing data into an   instance of SQL Server, use the -f switch with the in option. For   example, the following command bulk copies the contents of a data file,   Currency.dat, into a copy of the Sales.Currency table   (Sales.Currency2) by using the previously created format file   (Currency.xml). The example assumes that you are using Windows   Authentication and have a trusted connection to the server instance on which you   are running the bcp command.</p>
<p>At the Windows command prompt, enter:</p>
<pre>bcp AdventureWorks.Sales.Currency2 
in Currency.dat -T -f Currency.xml</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2008/12/12/what-is-bcp-utility-in-sql-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">188</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Tips And Tricks For Advanced MS SQL Server Developers</title>
		<link>https://sqlhelp.wordpress.com/2008/12/01/tips-and-tricks-for-advanced-ms-sql-server-developers/</link>
					<comments>https://sqlhelp.wordpress.com/2008/12/01/tips-and-tricks-for-advanced-ms-sql-server-developers/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Mon, 01 Dec 2008 10:03:28 +0000</pubDate>
				<category><![CDATA[SQL Tricks]]></category>
		<category><![CDATA[Advance SQL tips and tricks]]></category>
		<category><![CDATA[Author Raghunath Bhandari]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Database Optimization Tips]]></category>
		<category><![CDATA[dba]]></category>
		<category><![CDATA[DBA help]]></category>
		<category><![CDATA[MCP]]></category>
		<category><![CDATA[Microsoft Certified Professional]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSDN Help]]></category>
		<category><![CDATA[MSDN SQL News]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MSSQL server]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Database Optimization Tricks]]></category>
		<category><![CDATA[SQL Database Settings Optimization Tips]]></category>
		<category><![CDATA[SQL developer tips]]></category>
		<category><![CDATA[SQL Documentation]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[SQL Indexing Service]]></category>
		<category><![CDATA[SQL Optimization]]></category>
		<category><![CDATA[SQL Optimization Tips]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL server tips]]></category>
		<category><![CDATA[SQL technology]]></category>
		<category><![CDATA[SQL Tips]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQL tips for programmer]]></category>
		<category><![CDATA[sqlhelp]]></category>
		<category><![CDATA[sqlhelp news]]></category>
		<category><![CDATA[sqlhelp WebSite Review]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[Technology News]]></category>
		<category><![CDATA[Tips And Tricks For Advanced MS SQL Server Developers]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=114</guid>

					<description><![CDATA[Tips And Tricks For Advanced MS SQL Server Developers: Use “TRUNCATE TABLE” statement instead of “DELETE” clause if you want to delete all rows from a table. It is much faster then “DELETE” statement without any conditions. “TRUNCATE TABLE” frees all the space occupied by that table&#8217;s data and indexes, without logging the individual row [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Tips And Tricks For Advanced MS SQL Server Developers:</strong></p>
<ol>
<li> Use “TRUNCATE TABLE” statement instead of “DELETE” clause if you  want to delete all rows from a table. It is much faster then “DELETE”  statement without any conditions. “TRUNCATE TABLE” frees all the space  occupied by that table&#8217;s data and indexes, without logging the  individual row deletes.</li>
<li>Always use owner prefix in T-SQL  queries:<code><br />
</code></p>
<pre>SELECT mycolumn FROM dbo.mytable</pre>
<p>In this case query optimizer does not have to decide whether to  retrieve from dbo.mytable or other owner’s table and avoids  recompilation.  Recompilation results in no performance advantages of  stored procedures usage.</li>
<li> Don&#8217;t use “sp_“ as your prefix for stored procedures – it is a  reserved prefix in MS SQL server! MS SQL server searches for a stored  procedure with “sp_” prefix in the system procedures first, and only  after that looks for them in client procedures.</li>
<li> If you are unable to install MSDE at home because of unknown error –  check that you did not stop “Server” system service on you PC…</li>
<li> There are thousands of examples, when developers use “SELECT  COUNT(*)” statement. But there is another, much faster way to  accomplish the task:<code> </code>
<pre>SELECT rows FROM sysindexes WHERE id = OBJECT_ID('Table_Name') AND indid &lt; 2</pre>
</li>
<li> Include &#8220;SET NOCOUNT ON” statement in your stored procedures to greatly reduce network traffic.</li>
<li> Use the “BETWEEN” clause instead of “IN” for greater performance:<code><br />
SELECT productId FROM customer<br />
WHERE productId BETWEEN 1 AND 9</code></p>
<p>Instead of:</p>
<pre>SELECT productId
FROM customer
WHERE productId IN (1, 2, 3, 4,5,6,7,8,9)</pre>
</li>
<li>
<blockquote><p>Use Table variables &#8211; new feature of MS SQL 2000 instead of temp  tables. Table variables are created in memory, not written to the  tempdb database, and therefore they are much faster. However, be  careful to use them only with not very huge amount of data that you  want to allocate in temp tables, otherwise you can easily get the  server down.</p></blockquote>
</li>
</ol>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2008/12/01/tips-and-tricks-for-advanced-ms-sql-server-developers/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">114</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>Database Settings Optimization Tips</title>
		<link>https://sqlhelp.wordpress.com/2008/12/01/90/</link>
					<comments>https://sqlhelp.wordpress.com/2008/12/01/90/#respond</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Mon, 01 Dec 2008 06:18:19 +0000</pubDate>
				<category><![CDATA[Database Settings]]></category>
		<category><![CDATA[Advance SQL tips and tricks]]></category>
		<category><![CDATA[Database Optimization Tips]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MSSQL server]]></category>
		<category><![CDATA[SQL Database Optimization Tricks]]></category>
		<category><![CDATA[SQL Database Settings Optimization Tips]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[SQL Optimization Tips]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL server tips]]></category>
		<category><![CDATA[SQL Tips]]></category>
		<category><![CDATA[SQL tips for programmer]]></category>
		<category><![CDATA[sqlhelp]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/2008/12/01/90/</guid>

					<description><![CDATA[Database Settings Optimization Tips You can turn off the &#8216;auto create statistics&#8217; database option.When this database option is set to true, statistics are automatically created on columns used in a predicate. By default, this database option is set to true. Because auto creation statistics results in some performance degradation, you can turn off this database [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span style="color:#008000;"><strong>Database Settings Optimization Tips</strong></span></p>
<ul>
<li><strong>You can turn off the &#8216;auto create statistics&#8217; database option.</strong>When this database option is set to true, statistics are automatically created on columns used in a predicate. By default, this database option is set to true. Because auto creation statistics results in some performance degradation, you can turn off this database option and create statistics manually during off-peak times by using the CREATE STATISTICS statement. By the way, in most cases, it will not provide some performance benefits.</li>
<li><strong>You can turn off the &#8216;auto update statistics&#8217; database option.</strong>When this database option is set to true, existing statistics are automatically updated when the statistics become out-of-date. By default, this database option is set to true. Because auto update statistics results in some performance degradation, you can turn off this database option and update statistics manually during off-peak times by using the UPDATE STATISTICS statement. By the way, in most cases, it will not provide some performance benefits.</li>
<li><strong>Turn off the &#8216;autoclose&#8217; database option.</strong>When this option is turned on, the database&#8217;s resources are freed after the last user exits. When the new user will connect to database, the database should be reopened, which takes some time. So, do hot set this database option to true on your production server. By default, this database option is set to true when using SQL Server Desktop Edition, and set to false for all other editions.</li>
<li><strong>Turn off the &#8216;autoshrink&#8217; database option.</strong>When this database option is set to true, the database files will be periodically shrink. Autoshrinking results in some performance degradation, therefore you should shrink the database manually or create a scheduled task to shrink the database periodically during off-peak times, rather than set Autoshrink feature to on. By default, this database option is set to true when using SQL Server Desktop Edition, and set to false for all other editions.</li>
<li><strong>You can turn on the &#8216;read-only&#8217; database option to prevent users to modify the database&#8217;s data.</strong>By default, this database option is set to false. If you have data that should not be modified, you can place it into another database and set for this database the &#8216;read-only&#8217; option to true. It can increase the speed of your queries. If you need to allow permissions management (for example, prevent some users to select data from some tables), you should create another filegroup and make only this filegroup read-only, because when the &#8216;read-only&#8217; database option is set to true, the database&#8217;s system tables will be also read-only and this will prevent the permissions management.</li>
<li><strong>You can turn on the &#8216;select into/bulkcopy&#8217; database option to allow SELECT INTO statements and nonlogged bulk copies.</strong>The nonlogged bulk copy is		 	much faster than logged one, but to use it you must provide all the following conditions:1. The database option &#8216;select into/bulkcopy&#8217; is set to true.<br />
<blockquote><p>2. The target table is not being replicated.<br />
3. The TABLOCK hint is specified.<br />
4. The target table has no indexes, or if the table has indexes, it is empty when the bulk copy starts.<br />
By default, this database option is set to false.</p></blockquote>
</li>
<li><strong>You can turn off the &#8216;trunc. log on chkpt.&#8217; database option to prevent the transaction log from truncating on checkpoint.</strong>This option can be set if the transaction log grows very quickly to prevent the transaction log from filling rapidly and running out of disk space. If you set the &#8216;trunc. log on chkpt.&#8217; database option to true, the transaction log cannot be backed up, so you cannot restore your data to the point of failure (only to the time when the last full backup was made). So, the general recommendation about this option is allow it to be turned off, and make the transaction log backup periodically to truncate the log. By default, this database option is set to true when using SQL Server Desktop Edition, and set to false for all other editions.</li>
</ul>
<blockquote><p><strong> Note. You can set the above database options by using the sp_dboption system stored procedure or Enterprise Manager. If you want to set the above database options for the newly created database, you should set these options for the model database.</strong></p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2008/12/01/90/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">90</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server Settings Optimization Tips</title>
		<link>https://sqlhelp.wordpress.com/2008/12/01/sql-server-settings-optimization-tips/</link>
					<comments>https://sqlhelp.wordpress.com/2008/12/01/sql-server-settings-optimization-tips/#comments</comments>
		
		<dc:creator><![CDATA[Raghunath Bhandari]]></dc:creator>
		<pubDate>Mon, 01 Dec 2008 05:27:26 +0000</pubDate>
				<category><![CDATA[SQL Optimization]]></category>
		<category><![CDATA[Advance SQL tips and tricks]]></category>
		<category><![CDATA[Database Optimization Tips]]></category>
		<category><![CDATA[Microsoft SQL server]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MSSQL server]]></category>
		<category><![CDATA[SQL Database Optimization Tricks]]></category>
		<category><![CDATA[SQL Database Settings Optimization Tips]]></category>
		<category><![CDATA[SQL help]]></category>
		<category><![CDATA[SQL Optimization Tips]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL server tips]]></category>
		<category><![CDATA[SQL Tips]]></category>
		<category><![CDATA[SQL tips for programmer]]></category>
		<category><![CDATA[sqlhelp]]></category>
		<guid isPermaLink="false">http://sqlhelp.wordpress.com/?p=75</guid>

					<description><![CDATA[SQL Server Settings Optimization Tips: You can increase the &#8216;min memory per query&#8217; option to improve the performance of queries that use hashing or sorting operations, if your SQL Server has a lot of memory available and there are many queries running concurrently on the server. The SQL Server will automatically allocate, at a minimum, [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span style="color:#008000;"><strong>SQL Server Settings Optimization Tips:</strong></span></p>
<ol>
<li> <strong>You can increase the &#8216;min memory per query&#8217; option to improve the performance of queries that use hashing or sorting operations, if your SQL Server has a lot of memory available and there are many queries running concurrently on the server.</strong><br />
The SQL Server will automatically allocate, at a minimum, the amount of memory set in this configuration setting. The default &#8216;min memory per query&#8217; option is equal to 1024 Kb.</li>
<li><strong>You can increase the &#8216;max async IO&#8217; option if your SQL Server works on a high performance server with high-speed intelligent disk subsystem (such as hardware-based RAID with more than 10 disks).</strong><br />
This option specifies the maximum number of outstanding asynchronous disk I/O requests that the entire server can issue against a file. By the way, the &#8216;max async IO&#8217; SQL Server option is no longer supported in SQL Server 2000.</li>
<li><strong>You can change the &#8216;network packet size&#8217; option to the appropriate value.</strong><br />
This option can improve performance on networks whose base topology supports larger packets than TCP/IP&#8217;s default of 4096 bytes. For example, if client sends or receives large amounts of data, a larger packet size can improve performance, because it results in fewer network reads and writes. The default value for the &#8216;network packet size&#8217; option is 4096 bytes. Microsoft does not recommend changing this option, because for most applications, the default packet size of 4096 bytes is best.</li>
<li><strong>You can change the &#8216;fill factor&#8217; option to the appropriate value.</strong><br />
<blockquote><p>The &#8216;fill factor&#8217; option specifies how full SQL Server will make each index page. When there is no free space to insert new row on the index page, SQL Server will create new index page and transfer some rows from the previous page to the new one. This operation is called page splits. You can reduce the number of page splits by setting the appropriate fill factor option to reserve free space on each index page. The fill factor is a value from 1 through 100 that specifies the percentage of the index page to be left empty. The default value for fill factor is 0. It is treated similarly to a fill factor value of 100, the difference in that SQL Server leaves some space within the upper level of the index tree for FILLFACTOR = 0. The fill factor percentage is used only at the time the index is created. If the table contains read-only data (or data that very rarely changed), you can set the &#8216;fill factor&#8217; option to 100. When the table&#8217;s data modified very often, you can decrease the &#8216;fill factor&#8217; option to 70 percent, for example.</p></blockquote>
</li>
<li><strong>You can increase the &#8216;recovery interval&#8217; value.</strong><br />
The &#8216;recovery interval&#8217; option specifies the maximum number of minutes per database that SQL Server needs to complete its recovery procedures. The default value of this option is 0. It means that SQL Server will automatically configure this option. SQL Server issues a checkpoint using the &#8216;recovery interval&#8217; option. Microsoft does not recommend changing this option in general case, but sometimes you can improve performance by changing this option. You can monitor disk-write activity on the data files, and if you see periodic spikes that send disk utilization to 100 percent, you can increase the recovery interval. In this case, Microsoft suggests setting the &#8216;recovery interval&#8217; option to 5 and continuing monitoring.<br />
<strong></strong></li>
<li><strong>You can set the &#8216;priority boost&#8217; SQL Server options to 1.</strong><br />
You can set this option to 1, if you want from SQL Server to work with a higher priority than other processes on the same computer. The default value is 0. Setting &#8216;priority boost&#8217; to 1 can degrade the performance of other applications running on the same computer with SQL Server. So, you should set the &#8216;priority boost&#8217; SQL Server options to 1 only if you have dedicated server to SQL Server. In other case, do not change this option.</li>
<li><strong>Set the &#8216;max worker threads&#8217; options to the maximum number of the user connections to your SQL Server box.</strong><br />
The default setting for the &#8216;max worker threads&#8217; option is 255. If the number of user connections will be less than the &#8216;max worker threads&#8217; value, a separate operating system thread will be created for each client connection, but if the number of user connections will exceed this value the thread pooling will be used. For example, if the maximum number of the user connections to your SQL Server box is equal to 50, you can set the &#8216;max worker threads&#8217; options to 50, this frees up resources for SQL Server to use elsewhere. If the maximum number of the user connections to your SQL Server box is equal to 500, you can set the &#8216;max worker threads&#8217; options to 500, this can improve SQL Server performance because thread pooling will not be used.</li>
<li><strong>You can specify the &#8216;min server memory&#8217; and &#8216;max server memory&#8217; options.</strong><br />
These options can be used to specify the fixed amount of memory to allocate to SQL Server. In this case, you should set the &#8216;min server memory&#8217; and &#8216;max server memory&#8217; to the same value (equal to the maximum amount of physical memory that SQL Server will use), and set the &#8216;set working set size&#8217; SQL Server option to 1. This can improve performance because SQL Server will not dynamically allocate memory. You can also change these options when SQL Server works on the same computer with other applications. In this case, the &#8216;min server memory&#8217; options is used to allow SQL Server works when other applications pretend to use all available memory, and the &#8216;max server memory&#8217; options is used to allow other applications work when SQL Server tried to use all available resources.</li>
<li><strong>You can specify the &#8216;set working set size&#8217; SQL Server option to reserve the amount of physical memory space for SQL Server.</strong><br />
Unlike SQL Server 6.5, SQL Server 7.0/2000 can automatically allocate memory (can take more memory if SQL Server need it, and can give memory back to operation system). This is one of the main advantages in comparison with previous versions, but dynamic memory allocation takes some time. If you know the maximum amount of physical memory that SQL Server will use, you can specify this amount by setting &#8216;min server memory&#8217; and &#8216;max server memory&#8217; to the same value (equal to the maximum amount of physical memory that SQL Server will use) and set the &#8216;set working set size&#8217;</li>
</ol>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlhelp.wordpress.com/2008/12/01/sql-server-settings-optimization-tips/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">75</post-id>
		<media:content url="https://0.gravatar.com/avatar/3d158c1f962465433174863dd1536fcef4e5944b60c62f929656acf92add8b43?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Raghunath Bhandari</media:title>
		</media:content>
	</item>
	</channel>
</rss>
