<?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>TechBlog &#187; SQL</title>
	<atom:link href="http://techblog.byllemos.com/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://techblog.byllemos.com</link>
	<description>Accelerating into the Future with Wisdom about Technology! Ingrid Byllemos</description>
	<lastBuildDate>Tue, 05 Jan 2010 00:04:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>How to transfer user logins between to SQL Servers</title>
		<link>http://techblog.byllemos.com/2009/06/how-to-transfer-user-logins-between-to-sql-servers/</link>
		<comments>http://techblog.byllemos.com/2009/06/how-to-transfer-user-logins-between-to-sql-servers/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 13:24:23 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[Commands]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Logins]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=307</guid>
		<description><![CDATA[<p>Hi !</p>
<p>If you are installing a new SQL Server and would like to transfer the logins from an old SQL Server, without doing a SQL restore, then you can do it with a script.</p>
<p>Take a look on this&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Hi !</p>
<p>If you are installing a new SQL Server and would like to transfer the logins from an old SQL Server, without doing a SQL restore, then you can do it with a script.</p>
<p>Take a look on this article <a href="http://support.microsoft.com/kb/246133/">How to transfer logins and passwords between instances of SQL Server</a>; here Microsoft describes how to do it.<span id="more-307"></span></p>
<p>Basically it is a 2 part step. First you export the current user informations from the old server and then afterwards you run a create script on the new server. The detailed scripts can be found in the article from Microsoft <img src='http://techblog.byllemos.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2009/06/how-to-transfer-user-logins-between-to-sql-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trace Flag 4616</title>
		<link>http://techblog.byllemos.com/2008/06/trace-flag-4616/</link>
		<comments>http://techblog.byllemos.com/2008/06/trace-flag-4616/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 19:32:19 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Navision]]></category>
		<category><![CDATA[Trace flag 4616]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=70</guid>
		<description><![CDATA[<p>When using Navision (Dynamics NAV 5.0 or higher) with SQL 2005 (express or full) &#8211; you will receive a trace flag error, when trying to create a new database, unless you already has changed your SQL Server configuration.</p>
<p>So what&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>When using Navision (Dynamics NAV 5.0 or higher) with SQL 2005 (express or full) &#8211; you will receive a trace flag error, when trying to create a new database, unless you already has changed your SQL Server configuration.</p>
<p>So what to do when receiving this error? That&#8217;s simple &#8211; add the trace flag <img src='http://techblog.byllemos.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
<span id="more-70"></span><br />
First go into your configuration manager. Usually it is located here:</p>
<blockquote><p>Start<br />
-&gt; Programs<br />
-&gt; Microsoft SQL Server 2005<br />
-&gt; Configuration Tools<br />
-&gt; SQL Server Configuration Manager</p></blockquote>
<p>Next go into properties for your SQL Server Instance:</p>
<blockquote>
<ul>
<li> Select SQL Server 2005 Services</li>
<li>In the right window, you will now see your SQL Server</li>
<li>Right click on your server on select properties</li>
</ul>
</blockquote>
<p>Now all that is to do &#8211; is adding the trace flag</p>
<blockquote>
<ul>
<li> In the open window select Advanced</li>
<li>Find Startup Parameters</li>
<li>Add -T 4616 to the end</li>
</ul>
<p>Example:<br />
-dc:\Programmer\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf;-ec:\Programmer\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG;-lc:\Programmer\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\mastlog.ldf;<strong>-T 4616</strong></p></blockquote>
<p>Now select OK &#8211; restart you SQL Server Service, hereafter you will be able to create/use databases with Navision <img src='http://techblog.byllemos.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2008/06/trace-flag-4616/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sorting of a Code field in SQL vs. Native</title>
		<link>http://techblog.byllemos.com/2008/05/sorting-of-a-code-field-in-sql-vs-native/</link>
		<comments>http://techblog.byllemos.com/2008/05/sorting-of-a-code-field-in-sql-vs-native/#comments</comments>
		<pubDate>Sun, 18 May 2008 17:33:53 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[Native]]></category>
		<category><![CDATA[Navision]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=68</guid>
		<description><![CDATA[<p>Did you know that a Code field is sorted different depending of you are using Native or SQL?</p>
<p>SQL will sort the Code field as a Varchar &#8211; which means it will sort the Code field as text!</p>
<p>In the&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Did you know that a Code field is sorted different depending of you are using Native or SQL?</p>
<p>SQL will sort the Code field as a Varchar &#8211; which means it will sort the Code field as text!</p>
<p>In the following sorting example you can see the sorting Native vs. SQL<br />
<span id="more-68"></span></p>
<blockquote>
<table>
<tr>
<td width="70px">Native</td>
<td width="70px">SQL</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>10</td>
</tr>
<tr>
<td>3</td>
<td>2</td>
</tr>
<tr>
<td>10</td>
<td>3</td>
</tr>
<tr>
<td>A</td>
<td>A</td>
</tr>
<tr>
<td>AA</td>
<td>B</td>
</tr>
<tr>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>C</td>
<td>AA</td>
</tr>
</table>
</blockquote>
<p>So what to do if you are using SQL and still want a code field to be sorted in the same way as in Native? Use temporary tables!</p>
<p>Temporary tables acts in the same way as a Native table <img src='http://techblog.byllemos.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2008/05/sorting-of-a-code-field-in-sql-vs-native/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using SQL Views in Navision</title>
		<link>http://techblog.byllemos.com/2008/05/using-sql-views-in-navision/</link>
		<comments>http://techblog.byllemos.com/2008/05/using-sql-views-in-navision/#comments</comments>
		<pubDate>Wed, 14 May 2008 20:52:35 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[Navision]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[View]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=67</guid>
		<description><![CDATA[<p>Did you know that it is possible to use views in Navision?</p>
<p>If you often are collecting/viewing data from several tables it can be usefull to use a SQL View. Created SQL Views can then afterwards be used from Navision.&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Did you know that it is possible to use views in Navision?</p>
<p>If you often are collecting/viewing data from several tables it can be usefull to use a SQL View. Created SQL Views can then afterwards be used from Navision.</p>
<p>First you have to create the SQL View. This is can be done in 2 ways on the SQL Server.</p>
<p>One way is to use the Microsoft SQL Server Management. Here you right click on View select New where you afterwards can select tables, joins, fields etc.</p>
<p><span id="more-67"></span><br />
A second ways is by using T-SQL. Here you can use the command CREATE VIEW.</p>
<blockquote><p><!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">Ex.
CREATE VIEW dbo.<span class="br0">&#91;</span>MyCompany$Contact Customer<span class="br0">&#93;</span> AS
SELECT <span class="br0">&#91;</span>dbo<span class="br0">&#93;</span>.<span class="br0">&#91;</span>MyCompany$Contact<span class="br0">&#93;</span>.<span class="br0">&#91;</span>No_<span class="br0">&#93;</span> as <span class="br0">&#91;</span>Contact No_<span class="br0">&#93;</span>,
           <span class="br0">&#91;</span>dbo<span class="br0">&#93;</span>.<span class="br0">&#91;</span>MyCompany$Contact<span class="br0">&#93;</span>.<span class="br0">&#91;</span>Name<span class="br0">&#93;</span> as <span class="br0">&#91;</span>Contact Name<span class="br0">&#93;</span>,
           <span class="br0">&#91;</span>dbo<span class="br0">&#93;</span>.<span class="br0">&#91;</span>MyCompany$Customer<span class="br0">&#93;</span>.<span class="br0">&#91;</span>No_<span class="br0">&#93;</span> as <span class="br0">&#91;</span>Customer No_<span class="br0">&#93;</span>,
           <span class="br0">&#91;</span>dbo<span class="br0">&#93;</span>.<span class="br0">&#91;</span>MyCompany$Customer<span class="br0">&#93;</span>.<span class="br0">&#91;</span>Name<span class="br0">&#93;</span> as <span class="br0">&#91;</span>Customer Name<span class="br0">&#93;</span>
FROM <span class="br0">&#91;</span>dbo<span class="br0">&#93;</span>.<span class="br0">&#91;</span>MyCompany$Customer<span class="br0">&#93;</span>
INNER JOIN <span class="br0">&#91;</span>dbo<span class="br0">&#93;</span>.<span class="br0">&#91;</span>MyCompany$Contact<span class="br0">&#93;</span>
ON <span class="br0">&#91;</span>dbo<span class="br0">&#93;</span>.<span class="br0">&#91;</span>MyCompany$Customer<span class="br0">&#93;</span>.<span class="br0">&#91;</span>Contact<span class="br0">&#93;</span> = <span class="br0">&#91;</span>dbo<span class="br0">&#93;</span>.<span class="br0">&#91;</span>MyCompany$Contact<span class="br0">&#93;</span>.<span class="br0">&#91;</span>No_<span class="br0">&#93;</span>
</div></pre><!--END_DEVFMTCODE--></p></blockquote>
<p>This will create a view with the fields:</p>
<blockquote><p>Contact No_, Contact Name, Customer No_, Customer Name</p></blockquote>
<p>Now that you got the view its time to make Navision use it. This is done by creating a table.</p>
<p>In the table, the fields must be called the same as in the View.</p>
<p>In the view created in the above example the fields was called Contact No_, Contact Name, Customer No_, Customer Name. This means that in Navision, the fields must be called:</p>
<blockquote><p>Contact No., Contact Name, Customer No., Customer Name</p></blockquote>
<p>On the table the property LinkedObject must be set to Yes.  This will open the link to the SQL View.</p>
<p>Next you have to store the table &#8211; when saving the table, remember it must be given the same name as the View. Which means in our example case the table must be called Contact Customer.</p>
<p>That&#8217;s all &#8211; now you have created a table based on a SQL View <img src='http://techblog.byllemos.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>If you want the View to be global &#8211; then created it without the company name and when creating the table set the property DataPerCompany to No.</p>
<p>So in short terms, these are the steps for using SQL Views in Navision:</p>
<blockquote><p>1. Create the View on the SQL Server</p>
<p>2. Save it as either [Company$View Name] (company specific) or [View Name] (global)</p>
<p>3. Create a new table in Navision (dont save it yet)</p>
<p>4. Create Fields &#8211; the Fields must be Name exactly like in the View</p>
<p>5. Set the Table property LinkedObject to Yes</p>
<p>6. Set the Table property DataPerCompany<br/></p>
<p>- If it is a Company Specific view &#8211; then set it to Yes<br/></p>
<p>- If it is a global view &#8211; then set it to No</p>
<p>7. Save the table with same Name as the View &#8211; [View Name]</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2008/05/using-sql-views-in-navision/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Importing Image from a non Navision table to a Navision blob field</title>
		<link>http://techblog.byllemos.com/2008/05/importing-image-from-a-non-navision-table-to-blob-field/</link>
		<comments>http://techblog.byllemos.com/2008/05/importing-image-from-a-non-navision-table-to-blob-field/#comments</comments>
		<pubDate>Mon, 12 May 2008 19:33:33 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[ADO]]></category>
		<category><![CDATA[Automations]]></category>
		<category><![CDATA[Navision]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=66</guid>
		<description><![CDATA[<p>In SQL it is possible to define tables with a column, which is of type image. This field type is not known by Navision or by ADO and can thereby not be extracted like other fields.<br /><br /></p>
<p>There exists 2 ways&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>In SQL it is possible to define tables with a column, which is of type image. This field type is not known by Navision or by ADO and can thereby not be extracted like other fields.<br/><br/></p>
<p>There exists 2 ways to get this fields value.<br/></p>
<p>1) One way is to stream the image to a file and then afterwards import it into the blob.<br/><br/><br />
<span id="more-66"></span><br />
In this example I assume you already have the ADO Connection and thereby already got the ADORecordSet.<br/><br/><br />
<!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">ADOStream.Type := <span style="">1</span>; //1 = Binary
ADOStream.Open;
ADOStream.Write<span class="br0">&#40;</span>ADORecordSet.Fields.Item<span class="br0">&#40;</span>FieldName<span class="br0">&#41;</span>.Value<span class="br0">&#41;</span>;
ADOStream.SaveToFile<span class="br0">&#40;</span>'c:\tmp.bmp',2<span class="br0">&#41;</span>; //2 = SaveCreateOverWrite
ReturnTable.Picture.IMPORT<span class="br0">&#40;</span>'c:\tmp.bmp'<span class="br0">&#41;</span>;
ADOStream.Close;
CLEAR<span class="br0">&#40;</span>ADOStream<span class="br0">&#41;</span>;
&nbsp;
Where ADOStream is 'Microsoft ActiveX Data Objects <span style="">2.8</span> Library'.Stream
and ADORecordSet is 'Microsoft ActiveX Data Objects <span style="">2.8</span> Library'.Recordset
</div></pre><!--END_DEVFMTCODE--><br />
<br/><br />
This method works for compressed and uncompressed Blob fields.<br />
<br/><br/><br />
2) Another way is to move/insert the image into your table by using ADO RecordSet.<br />
<br/><br/><br />
Create 2 connections, one to your image table (ADOConn) and one to the table in Navision (NAVconn) where you want the picture to be inserted. Then &#8220;transfer&#8221; the Value from one RecordSet to another and add it.<br/><br/></p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">FromRecSet := ADOConn.Execute<span class="br0">&#40;</span>'SELECT image FROM tableX','',0<span class="br0">&#41;</span>;
FromRecSet.MoveFirst;
&nbsp;
//The following query is used to get a &quot;blank&quot; recordset, just like a INIT in Navision
MyQuery := 'SELECT <span class="br0">&#91;</span>EntryNo<span class="br0">&#93;</span>, <span class="br0">&#91;</span>Picture<span class="br0">&#93;</span> FROM <span class="br0">&#91;</span>MyTable<span class="br0">&#93;</span> WHERE <span class="br0">&#91;</span>EntryNo<span class="br0">&#93;</span> = 0';
&nbsp;
NewRecSet.Open<span class="br0">&#40;</span>MyQuery,NAVconn,1,3,1<span class="br0">&#41;</span>;
NewRecSet.AddNew;
NewRecSet.Fields.Item<span class="br0">&#40;</span>'Picture'<span class="br0">&#41;</span>.Value := FromRecSet.Fields.Item<span class="br0">&#40;</span>'image'<span class="br0">&#41;</span>.Value;
NewRecSet.Update;
&nbsp;
</div></pre><!--END_DEVFMTCODE--><br />
<br/><br />
This method does not work for compressed Blob fields!<br />
<br/><br/><br />
If you need to know more about <a href="http://techblog.byllemos.com/?p=38">ADO Connection</a> or <a href="http://techblog.byllemos.com/?p=40">ADO RecordSet</a>, then please read my previous posts on <a title="ADO" href="http://techblog.byllemos.com/?s=ADO">ADO</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2008/05/importing-image-from-a-non-navision-table-to-blob-field/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ADORecordSet</title>
		<link>http://techblog.byllemos.com/2008/02/ado-properties-adorecordset/</link>
		<comments>http://techblog.byllemos.com/2008/02/ado-properties-adorecordset/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 22:36:12 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[ADO]]></category>
		<category><![CDATA[Automations]]></category>
		<category><![CDATA[Navision]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=40</guid>
		<description><![CDATA[<p>Hi !</p>
<p>This is a detailed description for the used ADORecordSet command mentioned in the articles <a href="http://techblog.byllemos.com//?p=29" target="_blank" title="Stored Procedures and Navision"><em>Stored Procedures and Navision</em></a> and <a href="http://techblog.byllemos.com//?p=28" target="_blank" title="ADO in Navision"><em>ADO in Navision</em></a>.</p>
<h2>ADORecordSet</h2>
<p>The ADO RecordSet is&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Hi !</p>
<p>This is a detailed description for the used ADORecordSet command mentioned in the articles <a href="http://techblog.byllemos.com//?p=29" target="_blank" title="Stored Procedures and Navision"><em>Stored Procedures and Navision</em></a> and <a href="http://techblog.byllemos.com//?p=28" target="_blank" title="ADO in Navision"><em>ADO in Navision</em></a>.</p>
<h2>ADORecordSet</h2>
<p>The ADO RecordSet is defined by the automation &#8216;Microsoft ActiveX Data Objects Recordset 2.8 Library&#8217;.Recordset or by &#8216;Microsoft ActiveX Data Objects 2.8 Library&#8217;.Recordset</p>
<p>It is used to hold a set of records from a from a database table or a defined query. The Recordset object contains rows and columns (fields).<br />
<span id="more-40"></span><br />
In the mentioned articles we are using the following ADORecordSet methods:</p>
<h3>ADORecordset.ActiveConnection</h3>
<p>Sets the definition for the current connection.</p>
<h3>ADORecordSet.Close</h3>
<p>Closes a RecordSet.</p>
<h3>ADORecordSet.EOF</h3>
<p>Returns true if the recordset is at the end of the buffered response (after the last record), otherwise it is false.</p>
<h3>ADORecordSet.Fields.Item(&#8216;Name&#8217;).Value</h3>
<p>Returns a specific Items value. Fields are a collection of Items.</p>
<h3>ADORecordSet.MoveFirst</h3>
<p>Go to the first Record in the RecordSet.</p>
<h3>ADORecordSet.MoveNext</h3>
<p>Go the next record in the RecordSet.</p>
<h3>ADORecordset.Open</h3>
<p>Opens a connection to a database element, which gives access to records in a table, query results or saved recordsets.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2008/02/ado-properties-adorecordset/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

