<?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/"
	>

<channel>
	<title>ODLAN</title>
	<atom:link href="http://www.odlan.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.odlan.com/blog</link>
	<description>Code is art too! White space, please! ... also, use comments!</description>
	<lastBuildDate>Mon, 12 Sep 2011 01:55:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Upgraded Photoshop to CS5&#8230; Now I Cannot Scan!</title>
		<link>http://www.odlan.com/blog/technical/upgraded-photoshop-to-cs5-now-i-cannot-scan/</link>
		<comments>http://www.odlan.com/blog/technical/upgraded-photoshop-to-cs5-now-i-cannot-scan/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 01:54:58 +0000</pubDate>
		<dc:creator>naldope</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.odlan.com/blog/?p=165</guid>
		<description><![CDATA[After upgrading my Mac OS to Lion, I realized I just shot myself in the foot when I tried to open Photoshop CS2&#8230; and it failed to open. I had tried to figure a way to get my CS2 working on Lion, but finally I just gave in and decided to upgrade to CS5. Once [...]]]></description>
			<content:encoded><![CDATA[<p>After upgrading my Mac OS to Lion, I realized I just shot myself in the foot when I tried to open Photoshop CS2&#8230; and it failed to open. I had tried to figure a way to get my CS2 working on Lion, but finally I just gave in and decided to upgrade to CS5.</p>
<p>Once I upgraded and Photoshop was working again, I wanted to scan something in. But when I went to Import from my scanner, the option to Import wasn&#8217;t listed in the menu. I couldn&#8217;t believe it!</p>
<p>I figured I just needed to update my drivers for my Canon MP470 and it would return. But after upgrading the software, it still didn&#8217;t show up. Soon, I saw a reference in a forum posting mentioning that Photoshop may be running in x64-bit mode.</p>
<p>To make Photoshop run in 32-bit mode:</p>
<ol>
<li>Highlight the application in Finder (located in your Applications/ folder)</li>
<li>Get Info (Command-I)</li>
<li>Check the box &#8220;Open in 32-bit mode&#8221;</li>
<li>Then re-start Photoshop.</li>
</ol>
<p>That did the trick for me&#8230; Now, back in business!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.odlan.com/blog/technical/upgraded-photoshop-to-cs5-now-i-cannot-scan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>To Print a Secure PDF</title>
		<link>http://www.odlan.com/blog/technical/to-print-a-secure-pdf/</link>
		<comments>http://www.odlan.com/blog/technical/to-print-a-secure-pdf/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 16:42:45 +0000</pubDate>
		<dc:creator>naldope</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.odlan.com/blog/?p=161</guid>
		<description><![CDATA[Download Gimp or another GNU PDF viewer-type of application. Open the PDF document. (I usually like to import as layers) Then Print. (You have to hide each layer to display the next so you can print each one.)]]></description>
			<content:encoded><![CDATA[<ol>
<li>Download Gimp or another GNU PDF viewer-type of application.</li>
<li>
<div>Open the PDF document. (I usually like to import as layers)</div>
</li>
<li>
<div>Then Print. (You have to hide each layer to display the next so you can print each one.)</div>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.odlan.com/blog/technical/to-print-a-secure-pdf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Macbook Cannot Connect</title>
		<link>http://www.odlan.com/blog/technical/macbook-cannot-connect/</link>
		<comments>http://www.odlan.com/blog/technical/macbook-cannot-connect/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 18:51:45 +0000</pubDate>
		<dc:creator>naldope</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.odlan.com/blog/?p=151</guid>
		<description><![CDATA[This morning my Macbook Pro could not connect to my wireless network, but all my other wireless devices (i.e. Macbook, PC, iPhone&#8230;) could connect fine. I tried several things to fix the issue, such as creating a new Location in the Network pane in the System Preferences area. I even tried to re-naming my network [...]]]></description>
			<content:encoded><![CDATA[<p>This morning my Macbook Pro could not connect to my wireless network, but all my other wireless devices (i.e. Macbook, PC, iPhone&#8230;) could connect fine. I tried several things to fix the issue, such as creating a new Location in the Network pane in the System Preferences area. I even tried to re-naming my network SSID and password (which meant updating all my other wireless devices &#8212; such a pain).</p>
<p>But still, no connection! I read about deleting the &#8220;SystemConfiguration&#8221; folder within the &#8220;/Library/Preferences/&#8221; folder and re-booting and I tried that &#8212; again, no connection. Then I tried removing all password and keychain records regarding my wireless network through the KeyChain Access app in the Utilities folder.</p>
<p>Finally, I read about someone resetting their PRAM and re-booting. After re-booting and attempting to connect to the wireless network, it worked!</p>
<p>So, the steps I did to fix my wireless connection on my Macbook Pro were as follows:</p>
<ol>
<li>Go to &#8220;Macintosh HD/Library/Preferences/SystemConfiguration/&#8221; folder and remove it. (Maybe you should back it up first.)</li>
<li>Open KeyChain app from &#8220;Applications &gt; Utilities &gt; Keychain&#8221; and remove all instances where your wireless network passwords exist.</li>
<li>Open System Preferences pane and select Network. Nothing should exist because of your actions in Step 1 above. From Location dropdown, select &#8220;Edit Locations&#8230;&#8221;</li>
<li>And create a new location called &#8220;Automatic&#8221; by clicking the + button. Then select &#8220;Done&#8221;.</li>
<li>Finally, the PRAM needs to be reset by performing the following actions:
<ul>
<li>Shut down the computer</li>
<li>Find the following keys: Command, Option, P, and R.</li>
<li>The above keys must be pressed at the same time before the gray screen appears. Do this upon re-starting the computer.</li>
<li>Now, re-start the computer.</li>
<li>Immediately, press all the keys (Command, Option, P and R) at the same time.</li>
<li>Hold these keys until the computer restarts again and you hear the startup sound for the second time.</li>
<li>Release the keys and let it start up normally.</li>
</ul>
</li>
<li>After successfully re-booting, try to connect again to your wireless network. It may prompt you again for your password, but should now work.</li>
</ol>
<p>The above worked for me. You should backup your data before attempting the above. Also, my wireless security is WPA2 Personal. Your setup may work by just using WEP, but that isn&#8217;t as secure as WPA.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.odlan.com/blog/technical/macbook-cannot-connect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding www automatically</title>
		<link>http://www.odlan.com/blog/technical/adding-www-automatically/</link>
		<comments>http://www.odlan.com/blog/technical/adding-www-automatically/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 04:39:25 +0000</pubDate>
		<dc:creator>naldope</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.odlan.com/blog/?p=148</guid>
		<description><![CDATA[I noticed when I go to some sites like google.com, it automatically adds the &#8220;www&#8221; to it. However, with my site, it never did that. So, I figured I should change that for consistency. If you are running your website on Apache and you want to automatically add &#8220;www&#8221; to the domain, then you can [...]]]></description>
			<content:encoded><![CDATA[<p>I noticed when I go to some sites like google.com, it automatically adds the &#8220;www&#8221; to it. However, with my site, it never did that. So, I figured I should change that for consistency.</p>
<p>If you are running your website on Apache and you want to automatically add &#8220;www&#8221; to the domain, then you can do the following:</p>
<ol>
<li>Create an .htaccess file</li>
<li>Within the .htaccess file, add the following
<pre># force www in url
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomainnamehere.com
RewriteRule ^(.*)$ http://www.yourdomainnamehere.com/$1 [R=301]
# END force www in url</pre>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.odlan.com/blog/technical/adding-www-automatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Killing Database Users (Maybe Not the Elegant Way)</title>
		<link>http://www.odlan.com/blog/technical/killing-database-users-maybe-not-the-elegant-way/</link>
		<comments>http://www.odlan.com/blog/technical/killing-database-users-maybe-not-the-elegant-way/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 22:35:46 +0000</pubDate>
		<dc:creator>naldope</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.odlan.com/blog/?p=143</guid>
		<description><![CDATA[Today, during an application release, one of our DBAs (who is a novice) was trying to do a database restore from a backup copy. An error kept appearing during his attempts to perform the store stating &#8220;Exclusive access could not be obtained because the database is in use.&#8221; He tried several different ways to &#8220;kill&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Today, during an application release, one of our DBAs (who is a novice) was trying to do a database restore from a backup copy. An error kept appearing during his attempts to perform the store stating &#8220;Exclusive access could not be obtained because the database is in use.&#8221; He tried several different ways to &#8220;kill&#8221; these current db connections.</p>
<p>After googling somewhat, there was a forum post about killing all connections by just detaching the database. One would perform this via the SQL Server Management Studio.</p>
<p>First, right-click the database name, and select Tasks &gt; Detach… Once the dialog window pops up, you can see in Message column the number of active connections to the database. Upon clicking the link, it will display the Activity Monitor which includes info on db users currently connecting and their statuses (and their respective process IDs).</p>
<p>Within the Activity Monitor, you can can right-click each process and kill them manually. This worked for us since there were less than a handful connections active. If there were a ton, then this may not have been the ideal solution.</p>
<p>I also did come across <a href="http://www.mssqltips.com/tip.asp?tip=1407">another way</a> that used SQL to issue commands that would place the db into single user mode, thus killing the other connections and providing exclusive access to the db.</p>
<p>Below, is a set of commands a DBA can issue that may be another solution. (I still have to try this.)</p>
<p><code>ALTER DATABASE [Test4] SET SINGLE_USER WITH ROLLBACK IMMEDIATE<br />
OR<br />
ALTER DATABASE [Test4] SET SINGLE_USER WITH ROLLBACK AFTER 30<br />
OR<br />
ALTER DATABASE [Test4] SET SINGLE_USER WITH NO_WAIT</code></p>
<ul>
<li>WITH ROLLBACK IMMEDIATE &#8211; this option doesn&#8217;t wait for transactions to complete it just begins rolling back all open transactions</li>
<li>WITH ROLLBACK AFTER nnn &#8211; this option will rollback all open transactions after waiting nnn seconds for the open transactions to complete.  In our example we are specifying that the process should wait 30 seconds before rolling back any open transactions.</li>
<li>WITH NO_WAIT &#8211; this option will only set the database to single user mode if all transactions have been completed.  It waits for a specified period of time and if the transactions are not complete the process will fail.  This is the cleanest approach, because it doesn&#8217;t rollback any transactions, but it will not always work if there are open transactions.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.odlan.com/blog/technical/killing-database-users-maybe-not-the-elegant-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Carriage Returns in Title Attributes</title>
		<link>http://www.odlan.com/blog/web-dev/carriage-returns-in-title-attributes/</link>
		<comments>http://www.odlan.com/blog/web-dev/carriage-returns-in-title-attributes/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 06:36:22 +0000</pubDate>
		<dc:creator>naldope</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Web Dev]]></category>

		<guid isPermaLink="false">http://www.odlan.com/blog/?p=122</guid>
		<description><![CDATA[Since I&#8217;m always forgetting how to add carriage returns in my title attributes, I&#8217;d thought I&#8217;d add it here. The original HTML looked like the following: which produced the following mouseover toolip. So, to add carriage returns (line feeds) to your tooltips, you just need to add the &#38;#013; entity. Now the code would be: [...]]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;m always forgetting how to add carriage returns in my title attributes, I&#8217;d thought I&#8217;d add it here.</p>
<p>The original HTML looked like the following:<br />
<img src="http://www.odlan.com/blog/gfx/carr_return1.gif" alt="Original HTML Code" /><br />
which produced the following mouseover toolip.<br />
<img src="http://www.odlan.com/blog/gfx/carr_return2.gif" alt="Original Mouseover Tooltip with NO Carriage Returns" /></p>
<p>So, to add carriage returns (line feeds) to your tooltips, you just need to add the &amp;#013; entity. Now the code would be:<br />
<img src="http://www.odlan.com/blog/gfx/carr_return3.gif" alt="New HTML Code" /><br />
&#8230; and the new tooltip would look like:<br />
<img src="http://www.odlan.com/blog/gfx/carr_return4.gif" alt="With Carriage Returns" /></p>
<p><strong>Note:</strong> Please make sure to test across all platforms; I&#8217;m not sure if it works on every browser &#8212; and right now, I&#8217;m too pooped to test.</p>
<p><strong>Update:</strong> This tip doesn&#8217;t seem to work in FF3.6.3 on Mac. However, I used this tip on an intranet site where IE is only supported.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.odlan.com/blog/web-dev/carriage-returns-in-title-attributes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Right-Clicking in Parallels on Mac OS X</title>
		<link>http://www.odlan.com/blog/technical/right-clicking-in-parallels-on-mac-os-x/</link>
		<comments>http://www.odlan.com/blog/technical/right-clicking-in-parallels-on-mac-os-x/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 18:37:56 +0000</pubDate>
		<dc:creator>naldope</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.odlan.com/blog/?p=118</guid>
		<description><![CDATA[Since I am always forgetting how to right click in Windows XP on my Parallels VM, I decided to keep it in my blog. To right click, use the following keystroke combination: Ctrl-Shift-Click Also, if you are in Full Screen mode and cannot exit, you can try the following: Alt-Command-Enter (Return) Hope that helps someone [...]]]></description>
			<content:encoded><![CDATA[<p>Since I am always forgetting how to right click in Windows XP on my Parallels VM, I decided to keep it in my blog.</p>
<p>To right click, use the following keystroke combination:</p>
<p><code>Ctrl-Shift-Click</code></p>
<p>Also, if you are in Full Screen mode and cannot exit, you can try the following:</p>
<p><code>Alt-Command-Enter (Return)</code></p>
<p>Hope that helps someone else out there.</p>
<p><strong>Note:</strong> I am using Parallels Desktop 4.0 for Mac.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.odlan.com/blog/technical/right-clicking-in-parallels-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Illustrator CS2 Hanging&#8230; When Reading Fonts</title>
		<link>http://www.odlan.com/blog/technical/illustrator-cs2-hanging-when-reading-fonts/</link>
		<comments>http://www.odlan.com/blog/technical/illustrator-cs2-hanging-when-reading-fonts/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 08:21:32 +0000</pubDate>
		<dc:creator>naldope</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.odlan.com/blog/?p=114</guid>
		<description><![CDATA[One day after upgrading my Adobe products via the Adobe Updater, I decided to start Illustrator to work on some diagrams. To my dismay, the program was hanging; it displayed &#8220;Reading fonts&#8230;&#8221; for several minutes. I forced quit the app, then it hung at &#8220;Initializing&#8230;&#8221;. Initially, I thought I had a problem font so I [...]]]></description>
			<content:encoded><![CDATA[<p>One day after upgrading my Adobe products via the Adobe Updater, I decided to start Illustrator to work on some diagrams. To my dismay, the program was hanging; it displayed &#8220;Reading fonts&#8230;&#8221; for several minutes. I forced quit the app, then it hung at &#8220;Initializing&#8230;&#8221;.</p>
<p>Initially, I thought I had a problem font so I disabled all my fonts except the usual culprits, ie. Arial, Helvetica, etc. That didn&#8217;t work either. So, I re-installed Illustrator &#8212; and that didn&#8217;t work. Ugh!</p>
<p>I googled some more to see if other users had similar issues. Luckily, I used more-specific words, like &#8220;Adobe Illustrator CS2 hanging reading fonts&#8221;, for my search and I located this article, &#8220;<a href="http://kb2.adobe.com/cps/534/cpsid_53468.html">InDesign and Illustrator CS or CS2 fail to launch after applying the Mac OS X Acrobat 8.2 update.</a>&#8221;</p>
<p>After performing the steps listed under Solution 1, I tried to start the program again. Lo and behold, the program was starting right up! Success! *Happy dance*</p>
<p>Below are the steps, if the above link fails&#8230;</p>
<p>Replace the corresponding files present in the “ /Library/Application Support/Adobe/TypeSpt/Unicode/Mappings/” folder with the one attached to this document.</p>
<ol type="1">
<li>Download the attached <a href="http://kb2.adobe.com/cps/534/cpsid_53468/attachments/Mac.dmg">Mac.dmg</a> file (another <a href="/tmp/app/Mac.dmg">location</a>) to a machine where the issue is seen.</li>
<li>Close all Adobe applications</li>
<li>Double Click the Mac.dmg file to mount it.</li>
<li>Copy Mac folder from mounted image. Paste it to /Library/ApplicationSupport/Adobe/TypeSpt/Unicode/Mappings/.</li>
<li>A message appears to confirm to replace the existing &#8216;Mac&#8217; folder. Replace the &#8216;Mac&#8217; folder.</li>
<li>Launch Illustrator or InDesign CS or CS 2.<strong><em> </em></strong></li>
</ol>
<p><strong>Update:</strong> [13-April-2010] This tip seems to work whenever Acrobat is being updated lately. My Acrobat was updated yesterday and Illustrator hung once again, but the above fix worked again.</p>
<p><strong>Update:</strong> [09-July-2010] This tip also seemed to fix my Photoshop after an update as well. Whew!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.odlan.com/blog/technical/illustrator-cs2-hanging-when-reading-fonts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE8&#8242;s Compatibility View&#8230; Why oh why?</title>
		<link>http://www.odlan.com/blog/web-dev/ie8s-compatibility-view-why-oh-why/</link>
		<comments>http://www.odlan.com/blog/web-dev/ie8s-compatibility-view-why-oh-why/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 01:41:56 +0000</pubDate>
		<dc:creator>naldope</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Web Dev]]></category>

		<guid isPermaLink="false">http://www.odlan.com/blog/?p=109</guid>
		<description><![CDATA[After spending much time hacking my webpage&#8217;s CSS to render well in IE6, there were decisions made that we would drop IE6 support and focus on the new IE8. I thought this was wonderful news since the page tested wonderfully in IE8. Anyone who knows IE, knows that wasn&#8217;t the end of the story. As [...]]]></description>
			<content:encoded><![CDATA[<p>After spending much time hacking my webpage&#8217;s CSS to render well in IE6, there were decisions made that we would drop IE6 support and focus on the new IE8. I thought this was wonderful news since the page tested wonderfully in IE8.</p>
<p>Anyone who knows IE, knows that wasn&#8217;t the end of the story. As I relayed the test URL to my peers, who also had IE8, they were pinging me to let me know that it looks terrible in their browsers. I thought they were kidding until receiving screenshots.</p>
<p>After much research, it seemed liked IE8 was making the page appear in Compatibility View for my co-workers &#8212; which makes the page render like it was being viewed in an older version, ie. IE7. I clicked on the &#8220;Compatibility View&#8221; button on the browser toolbar and lo and behold, I saw what they were seeing. Ugh!</p>
<p>After spending countless hours trying to modify my css, I wondered if I could force IE8 to make users view the page according to IE8 standards only. I googled a bit and located a <a href="http://social.msdn.microsoft.com/Forums/en/iewebdevelopment/thread/00c84ef7-4832-a2af-fa4b6147bf8d" target="_blank">forums thread on the MSDN site</a>.</p>
<p>Within this thread, it linked my to an <a href="http://msdn.microsoft.com/en-us/library/cc817574.aspx" target="_blank">article</a> that allows developers to specify compatibility modes on a per-page basis by using a simple META tag, which looks like:</p>
<p><code>&lt;meta http-equiv="X-UA-Compatible" content="IE=8" /&gt;</code><br />
You can specify other browser versions from IE5 on up.</p>
<p>Now, it forces users to view the page in IE8 based only on IE8 standards. Whew!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.odlan.com/blog/web-dev/ie8s-compatibility-view-why-oh-why/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bulk Insert and Problem Characters</title>
		<link>http://www.odlan.com/blog/technical/bulk-insert-and-problem-characters/</link>
		<comments>http://www.odlan.com/blog/technical/bulk-insert-and-problem-characters/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 08:34:08 +0000</pubDate>
		<dc:creator>naldope</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.odlan.com/blog/?p=90</guid>
		<description><![CDATA[One of my latest projects involves bulk inserting data from a flat-file into a database table (SQL Server 2005 Database). The data file is provided by another third-party application and FTP&#8217;d over to a server that I have access to via batch script and SFTP2. I use a stored procedure to execute the bulk insert [...]]]></description>
			<content:encoded><![CDATA[<p>One of my latest projects involves bulk inserting data from a flat-file into a database table (SQL Server 2005 Database). The data file is provided by another third-party application and FTP&#8217;d over to a server that I have access to via batch script and SFTP2.</p>
<p>I use a stored procedure to execute the bulk insert command. The following is the basic syntax to run the bulk insert.</p>
<p><code>DECLARE @BulkSQL varchar(2000)<br />
SET @SQL = 'BULK INSERT DestinationTable FROM ''//UNC/Path/To/Server/flatfile.dat'' WITH (ROWTERMINATOR=''\n'', FIELDTERMINATOR = ''|'' , FIRSTROW=2)'<br />
EXEC (@BulkSQL)<br />
</code></p>
<p>A little bit of explanation may be necessary. The flat file format is as follows:</p>
<ul>
<li> 1st row is the header row where each column is delimited by a pipe (|)</li>
<li>The remainer of the rows contain data also delimited by pipes.</li>
</ul>
<p><code>NAME|ADDRESS|CITY|STATE|PHONE<br />
John Doe|123 Main St|San Francisco|CA|415-234-2344<br />
Jim Smith|33 Elm St|Oakland|CA|510-542-4562<br />
</code></p>
<p>The bulk insert statement has some attributes that you can customize. The field terminator attribute describes how the fields are delimited. The row terminator defines what character will symbolize the end of row marker. The firstrow attribute states which row to start importing from. Since there is a header row, firstrow should be set to 2 (second row).</p>
<p>When I tested the stored procedure containing the bulk insert command, I received the following error:</p>
<p><code>Server: Msg 4863, Level 16, State 1, Line 1<br />
Bulk insert data conversion error (truncation) for row 1, column 5 (PHONE).</code></p>
<p>The problem was that it would work sometimes and sometimes it would fail. I had no clue what the deal was. I would switch between flat-files; some worked and some failed. I realized that the truncation error was happening only on column 5, the last column, which was a fixed size of 12 characters. But all the files had a last column of 12 characters! Argh!</p>
<p>I opened up the flat-file.dat in Notepad++ (a free source code editor) as seen below<br />
<img src="/blog/gfx/np1.gif" alt="" /></p>
<p>Then I noticed the &#8220;Show All Characters&#8221; icon in the toolbar, which looks like symbol for a paragraph mark (or backwards &#8220;P&#8221;).<br />
<img src="/blog/gfx/np2.gif" alt="" /></p>
<p>Then lo and behold, I saw the problem characters, the CR (carriage return) and LF(line feed) characters.  I read somewhere that</p>
<ul>
<li>Windows uses <strong><span>carriage return &#8211; line feed</span></strong>.</li>
<li>UNIX uses <strong><span>line feed</span></strong>.</li>
<li>Macintosh uses <strong><span>carriage return</span></strong>.</li>
</ul>
<p>But the bulk insert looks for a newline &#8220;\n&#8221; character to mark end of rows in the data file. Note: sometimes, people consider newline and linefeed the same thing. So, the file was using CR+LF as row terminator, but the bulk statement was looking for &#8220;\n&#8221; as it&#8217;s row terminator (or LF).  So, the bulk insert was considering the CR character as part of column 5, thus, creating a truncation error.</p>
<p>Before I changed any of my code, I wanted to be certain what end-of-row marker a fresh data file coming from the other application uses. What I discovered was that it used only LF (line feed) markers.</p>
<p>So, to convert my current data file from CR+LF to just LF, I just selected Format &gt; Convert to Unix as seen here.<br />
<img src="/blog/gfx/np3.gif" alt="" /></p>
<p>And now, I get<br />
<img src="/blog/gfx/np4.gif" alt="" /></p>
<p>Since I changed to row terminator symbol to use line feed, I had to modify the bulk insert statement to the following:</p>
<p><code>DECLARE @BulkSQL varchar(2000)<br />
SET @SQL = 'BULK INSERT DestinationTable FROM ''//UNC/Path/To/Server/flatfile.dat'' WITH (ROWTERMINATOR='''+ CHAR(10) +''', FIELDTERMINATOR = ''|'' , FIRSTROW=2)'<br />
EXEC (@BulkSQL)<br />
</code></p>
<p>So, I tested the stored procedure again, and it worked perfectly.</p>
<p>Below is a table defining control characters and their  ASCII equivalent.<br />
<img src="/blog/gfx/controlchars.gif" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.odlan.com/blog/technical/bulk-insert-and-problem-characters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.237 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-04 20:16:04 -->

