<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5216553291715844463</id><updated>2026-06-20T09:37:37.463+07:00</updated><category term="ASP.Net Debugging Problems"/><category term="ASP.Net Deploying Problems"/><category term="SQL Tips"/><category term="Visual Basic"/><category term="Crystal Report"/><category term="Java Script"/><category term="SQL Errors"/><category term="ASP.Net"/><category term="Blogging Awards"/><category term="Tableau"/><category term="Ms. Office"/><category term="Visual Basic Error"/><category term="Assembly Language"/><category term="Others"/><category term="Playing with Query"/><category term="Virus"/><category term="jQuery"/><category term="Duwamish"/><category term="Linked Server"/><category term="Pentaho"/><category term="SSRS"/><category term="Unsolved Problems"/><category term="VB.Net Error"/><category term="XML"/><title type='text'>Programmer&#39;s Laboratory</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>125</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-4765387461673630988</id><published>2024-03-19T14:49:00.004+07:00</published><updated>2024-03-22T15:37:45.108+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linked Server"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Errors"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Tips"/><category scheme="http://www.blogger.com/atom/ns#" term="XML"/><title type='text'>Updating Table Containing Xml Column via LinkedServer</title><content type='html'>&lt;p&gt;If you are trying to update a table containing XML column via Linked Server in SQL Server, and you are not able to, you are not alone.&lt;/p&gt;&lt;p&gt;There are 2 main issues in this scenario:&lt;br /&gt;1. Accessing a table containing XML column via Linked Server&lt;br /&gt;2. Updating the XML value&lt;/p&gt;&lt;p&gt;When trying to select the XML column of a table via linked server:&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 646.984px;&quot;&gt;&lt;pre&gt;&lt;code&gt;&lt;xxx&gt;&lt;yyy&gt;SELECT col1, col2, XmlColumn
FROM [LinkedServer].[DatabaseName].dbo.TableName&lt;/yyy&gt;&lt;/xxx&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Error encountered:&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 646.984px;&quot;&gt;&lt;pre&gt;&lt;code&gt;&lt;span style=&quot;color: red;&quot;&gt;Xml data type is not supported in distributed queries. Remote object &#39;[LinkedServer].[DatabaseName].dbo.TableName&#39; has xml column(s).&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There are a few workarounds to resolve this (we will focus on using view in this post):&lt;/p&gt;&lt;p&gt;1. Use OPENQUERY&lt;/p&gt;&lt;p&gt;2. Create a view that selects a converted non-XML value from the XML column in the destination DB.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 646.984px;&quot;&gt;&lt;pre&gt;&lt;code&gt;--In destination DB
CREATE VIEW vw_NonXmlColumn
AS
SELECT col1, col2,
&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;XmlColumn = CONVERT(NVARCHAR(MAX), XmlColumn)
&lt;/span&gt;FROM TableName WITH(NOLOCK)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, on the source DB where you create the Linked Server, you can access the view instead:&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 646.984px;&quot;&gt;&lt;pre&gt;&lt;code&gt;--In source DB
select col1, col2, XmlColumn
from [LinkedServer].[DatabaseName].dbo.&lt;/code&gt;vw_NonXmlColumn&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This resolves our first issue: accessing a table containing XML column via Linked Server.&lt;/p&gt;&lt;span&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;p&gt;If you try to perform an update of the converted XML column:&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 646.984px;&quot;&gt;&lt;pre&gt;&lt;code&gt;--In source DB
UPDATE [LinkedServer].[DatabaseName].dbo.&lt;/code&gt;vw_NonXmlColumn
SET XmlColumn = &#39;&amp;lt;new XML value&amp;gt;&#39;
WHERE &amp;lt;condition&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You will encounter another error:&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 646.984px;&quot;&gt;&lt;pre&gt;&lt;code&gt;&lt;span style=&quot;color: red;&quot;&gt;Statement(s) could not be prepared.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;&lt;span style=&quot;color: red;&quot;&gt;Update or insert of view or function &#39;[DatabaseName].dbo.view&#39; failed because it contains a derived or constant field.&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To resolve this, we can use &quot;Instead of Update&quot; trigger.&lt;/p&gt;&lt;p&gt;On source DB, create a trigger when the view update is executed:&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 646.984px;&quot;&gt;&lt;pre&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;--In source DB
CREATE TRIGGER TR_TableName_InsteadOfUpdate ON vw_NonXmlColumn
INSTEAD OF UPDATE
AS
BEGIN
&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;SET NOCOUNT ON

    UPDATE TableName
    SET XmlColumn = i.XmlColumn
    FROM TableName t
    INNER JOIN inserted i
        ON i.ID = t.ID --Unique identifier of the table
&lt;/span&gt;&lt;/span&gt;END&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;You can now use back the same query used to update the XML column via Linked Server successfully:&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 646.984px;&quot;&gt;&lt;pre&gt;&lt;code&gt;--In source DB
UPDATE [LinkedServer].[DatabaseName].dbo.&lt;/code&gt;vw_NonXmlColumn
SET XmlColumn = &#39;&amp;lt;new XML value&amp;gt;&#39;
WHERE &amp;lt;condition&amp;gt;&lt;/pre&gt;&lt;/div&gt;

&lt;b&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;PS: Try to simplify the update statement by using variables if necessary, if there is any issue encountered when performing the update to the view.&lt;/span&gt;&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/4765387461673630988/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2024/03/updating-table-containing-xml-column.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/4765387461673630988'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/4765387461673630988'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2024/03/updating-table-containing-xml-column.html' title='Updating Table Containing Xml Column via LinkedServer'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-8639289268461109306</id><published>2021-05-12T15:49:00.002+07:00</published><updated>2021-05-12T15:49:38.765+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Tips"/><title type='text'>Creating Dynamic Pivot Table using SQL</title><content type='html'>&lt;p&gt;&amp;nbsp;In this post, I want to share SQL tips on how to create dynamic pivot table in SQL.&lt;/p&gt;&lt;p&gt;The columns in the pivot table is not fixed in this case. Hence, there is a need to use dynamic SQL to achieve this.&lt;/p&gt;&lt;p&gt;In this example, we will be forming a pivot table containing spending by outlet from spending data.&lt;/p&gt;&lt;p&gt;SQL Query:&lt;/p&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;
  &lt;pre&gt;&lt;code&gt;--prepare data source
create table #TmpSpending
(
	MemberID nvarchar(100),
	Outlet nvarchar(100),
	TransactDate date,
	Spending numeric(18,4)
)

insert into #TmpSpending values (&#39;M0001&#39;, &#39;Outlet A&#39;, &#39;2021/01/05&#39;, 100)
insert into #TmpSpending values (&#39;M0001&#39;, &#39;Outlet B&#39;, &#39;2021/01/15&#39;, 200)
insert into #TmpSpending values (&#39;M0002&#39;, &#39;Outlet A&#39;, &#39;2021/02/09&#39;, 300)
insert into #TmpSpending values (&#39;M0003&#39;, &#39;Outlet B&#39;, &#39;2021/01/10&#39;, 400)
insert into #TmpSpending values (&#39;M0003&#39;, &#39;Outlet B&#39;, &#39;2021/02/15&#39;, 500)

select * from #tmpspending

--temporary table for output
create table #tmpOutput (
	Outlet nvarchar(100)
)

--initial insert into #tmpOutput
insert into #tmpOutput
select distinct outlet
from #TmpSpending
order by outlet

--store the list of [month year] first
select distinct [Year] = year(transactdate), 
	[Month] = month(transactdate),
	MonthYear = left(datename(month, transactdate), 3) + &#39; &#39; + convert(varchar, year(transactdate))
into #tmpDates
from #tmpspending

--construct the table with dynamic columns using cursor
declare @year int, @month int
declare @monthyear nvarchar(8)
declare @sql nvarchar(max) = &#39;&#39; --dynamic sql for columns addition

declare cur1 cursor for
select [year], [month], MonthYear
from #tmpDates
order by [year], [month]

open cur1

fetch next from cur1
into @year, @month, @monthyear

while @@FETCH_STATUS = 0
begin
	
	--add column to #tmpOutput
	set @sql = &#39;alter table #tmpOutput add [&#39; + @monthyear + &#39;] numeric(18,4)&#39;
	exec (@sql)

	--update #tmpOutput
	set @sql = &#39;update o &#39;
	set @sql += &#39;set [&#39; + @monthyear + &#39;] = s.spending &#39;
	set @sql += &#39;from #tmpOutput o &#39;
	set @sql += &#39;inner join (	select outlet, spending = sum(spending) &#39;
	set @sql += &#39;				from #tmpspending &#39;
	set @sql += &#39;				where year(transactdate) = &#39; + convert(varchar, @year) + &#39; &#39;
	set @sql += &#39;				and month(transactdate) = &#39; + convert(varchar, @month) + &#39; &#39;
	set @sql += &#39;				group by outlet &#39;
	set @sql += &#39;) s on s.outlet = o.outlet &#39;
	exec(@sql)

	--fetch next record
	fetch next from cur1
	into @year, @month, @monthyear
end

close cur1
deallocate cur1

select * from #tmpOutput

drop table #tmpDates
drop table #TmpSpending
drop table #tmpOutput&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;
First, we prepare the data source which looks like this.&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7ml8lPud4_Fzja6iO6NBZJVqibTAGGfpjopGIwxHXj3AC2T8mKKF5H36ocwY5K4A1gpPEWThuLAkx31iKBoWRMXRO3ZKaALon1CdfhuzB687vZx00LFbi6fE-EfDQcix-qUZ9tNHiCCii/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;148&quot; data-original-width=&quot;352&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7ml8lPud4_Fzja6iO6NBZJVqibTAGGfpjopGIwxHXj3AC2T8mKKF5H36ocwY5K4A1gpPEWThuLAkx31iKBoWRMXRO3ZKaALon1CdfhuzB687vZx00LFbi6fE-EfDQcix-qUZ9tNHiCCii/s16000/image.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Afterwards, we use cursor (or you can use while loop) to create additional columns on the table on the fly, to form up the pivot table.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;This is the end result of the pivot table.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuTHn-T3aBX9DNkU6a3NcR4H6DuPzQNjqKySHjblNLCNEFAL1pH-vuQQjZ6JJsV603FOQE4WaZ-6YAaUO40gZnEjjTrzoJlt3-2maU7qboxJsz3m4OnXp7HwBs5bM2d-8bR52kOxGmDeU-/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;100&quot; data-original-width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuTHn-T3aBX9DNkU6a3NcR4H6DuPzQNjqKySHjblNLCNEFAL1pH-vuQQjZ6JJsV603FOQE4WaZ-6YAaUO40gZnEjjTrzoJlt3-2maU7qboxJsz3m4OnXp7HwBs5bM2d-8bR52kOxGmDeU-/s16000/image.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Happy querying! :)&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/8639289268461109306/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2021/05/creating-dynamic-pivot-table-using-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/8639289268461109306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/8639289268461109306'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2021/05/creating-dynamic-pivot-table-using-sql.html' title='Creating Dynamic Pivot Table using SQL'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7ml8lPud4_Fzja6iO6NBZJVqibTAGGfpjopGIwxHXj3AC2T8mKKF5H36ocwY5K4A1gpPEWThuLAkx31iKBoWRMXRO3ZKaALon1CdfhuzB687vZx00LFbi6fE-EfDQcix-qUZ9tNHiCCii/s72-c/image.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-1060527267611639550</id><published>2021-03-17T13:51:00.004+07:00</published><updated>2021-03-17T16:07:35.693+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tableau"/><title type='text'>Activate Tableau Server Offline</title><content type='html'>&lt;p&gt;If you are doing Tableau server license activation offline, it may be a bit problematic, and confusing.&lt;/p&gt;&lt;p&gt;There is already an article published by Tableau showing &lt;a href=&quot;https://help.tableau.com/current/server-linux/en-us/activate_off_install.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;how to do Tableau server license activation offline&lt;/a&gt;. However, the last part about how to process the activation.tlf is not mentioned.&lt;/p&gt;&lt;p&gt;Hence, I am creating some guide on how to do that.&lt;/p&gt;&lt;p&gt;After you upload the offline.tlf file on Tableau site, and get the activation.tlf back, you need to:&lt;/p&gt;&lt;p&gt;1. Place the activation.tlf file somewhere in the server where you have your Tableau server installed. e.g. D:\activation.tlf&lt;/p&gt;&lt;p&gt;2. Open command prompt as Administrator from Start menu.&lt;/p&gt;&lt;p&gt;3. Go to the Tableau server directory where tabadmin.bat is located. Usually it is located at&amp;nbsp;C:\Program Files\Tableau\Tableau Server\&amp;lt;version&amp;gt;\bin.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #0044ff; font-family: courier;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;span style=&quot;color: #0044ff; font-family: courier;&quot;&gt;&lt;b&gt;cd\Program Files\Tableau\Tableau Server\&amp;lt;version&amp;gt;\bin&lt;/b&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;4. Use this command to activate using the activation.tlf file:&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #002fff; font-family: courier;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;span style=&quot;color: #002fff; font-family: courier;&quot;&gt;&lt;b&gt;tabadmin activate -tlf D:\activation.tlf&lt;/b&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;5. That&#39;s all, folks.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/1060527267611639550/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2021/03/activate-tableau-server-offline.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/1060527267611639550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/1060527267611639550'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2021/03/activate-tableau-server-offline.html' title='Activate Tableau Server Offline'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-6656583035797164791</id><published>2021-02-05T16:31:00.002+07:00</published><updated>2022-01-07T12:59:06.050+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Others"/><title type='text'>Using Macro in Notepad++</title><content type='html'>&lt;p&gt;&amp;nbsp;Sometimes, you need to bulk-edit text with the same patterns. However, you can&#39;t simply use text editor to find and replace the content. In this case, you can try using macro in Notepad++ to achieve that.&lt;/p&gt;&lt;p&gt;This is a simple video on how you can do that using Notepad++:&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/fSC1gkg7CLM&quot; width=&quot;320&quot; youtube-src-id=&quot;fSC1gkg7CLM&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/6656583035797164791/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2021/02/you-need-to-bulk-edit-text-with-same.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/6656583035797164791'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/6656583035797164791'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2021/02/you-need-to-bulk-edit-text-with-same.html' title='Using Macro in Notepad++'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/fSC1gkg7CLM/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-3815586080828585761</id><published>2020-11-04T13:27:00.001+07:00</published><updated>2020-11-04T13:27:11.046+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Tips"/><title type='text'>Split Comma-Delimited Column into Multiple Rows</title><content type='html'>We had post about&lt;a href=&quot;http://programmerslab.blogspot.com/2014/09/combine-rows-into-column.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt; combining multiple rows into a column&lt;/a&gt; in the past. Sometimes, on the contrary, we would want to split character-delimited column into multiple rows.

In this post, we will see try to split comma-delimited column into multiple rows.
Sample Data:
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQJu9sj0LmzLfCApDuzlkaa3DajitTn2-Ynfe3jPGa50-26ny2gJ05zOUm-Rfv8voxtYH69N1sEcfcG1jx9HEjC1XAMZ-wVGpZ-vCrSb51P0Qtgi2AQKUU0UdouTjMbJQ4XusAqaJTMqC7/s288/a.png&quot; style=&quot;display: block; padding: 1em 0px; text-align: center;&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; data-original-height=&quot;80&quot; data-original-width=&quot;288&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQJu9sj0LmzLfCApDuzlkaa3DajitTn2-Ynfe3jPGa50-26ny2gJ05zOUm-Rfv8voxtYH69N1sEcfcG1jx9HEjC1XAMZ-wVGpZ-vCrSb51P0Qtgi2AQKUU0UdouTjMbJQ4XusAqaJTMqC7/s16000/a.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

End result after split into rows:
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8QvK3kcn4892h0touZnMtk_Em9bBowbRskunxPn3VJLYxK3lm1udEqbZVc82KtcMAh6cRmgztqLo25niiswYCKGHsW0SlmKaPeXShtaVqIUJAUpqrFK6U0s54PjTe6ujLd4nQlqUJFld1/s225/b.png&quot; style=&quot;display: block; padding: 1em 0px; text-align: center;&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; data-original-height=&quot;142&quot; data-original-width=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8QvK3kcn4892h0touZnMtk_Em9bBowbRskunxPn3VJLYxK3lm1udEqbZVc82KtcMAh6cRmgztqLo25niiswYCKGHsW0SlmKaPeXShtaVqIUJAUpqrFK6U0s54PjTe6ujLd4nQlqUJFld1/s16000/b.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

Query:
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;
  &lt;pre&gt;&lt;code&gt;
-- Create temporary table to store UserGroup
create table #UserGroup (GroupID int, UserGroup nvarchar(1000), Users nvarchar(1000))
insert into #UserGroup values (1, &#39;Group 1&#39;, &#39;Himura,Selvi,Superman&#39;)
INSERT INTO #UserGroup VALUES ( 2, &#39;Group 2&#39;, &#39;Luck,Smarty&#39;)
INSERT INTO #UserGroup VALUES ( 3, &#39;Group 3&#39;, &#39;Lucky&#39;)

--Display the sample data
select * from #UserGroup

--Split comma-delimited column into multiple rows
;WITH tmp(GroupID, UserGroup, Username, Users) AS
(
	SELECT GroupID, 
		UserGroup,
		convert(nvarchar(1000), LEFT(Users, CHARINDEX(&#39;,&#39;, Users + &#39;,&#39;) - 1)),
		convert(nvarchar(1000), STUFF(Users, 1, CHARINDEX(&#39;,&#39;, Users + &#39;,&#39;), &#39;&#39;))
	FROM #UserGroup
	where Users is not null
	UNION all

	SELECT GroupID, 
		UserGroup,
		convert(nvarchar(1000), LEFT(Users, CHARINDEX(&#39;,&#39;, Users + &#39;,&#39;) - 1)),
		convert(nvarchar(1000), STUFF(Users, 1, CHARINDEX(&#39;,&#39;, Users + &#39;,&#39;), &#39;&#39;))
	FROM tmp
	WHERE
		Users &amp;gt; &#39;&#39;
)
select GroupID, UserGroup, Username
from tmp
order by GroupID, UserGroup
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/3815586080828585761/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2020/11/split-comma-delimited-column-into.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/3815586080828585761'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/3815586080828585761'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2020/11/split-comma-delimited-column-into.html' title='Split Comma-Delimited Column into Multiple Rows'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQJu9sj0LmzLfCApDuzlkaa3DajitTn2-Ynfe3jPGa50-26ny2gJ05zOUm-Rfv8voxtYH69N1sEcfcG1jx9HEjC1XAMZ-wVGpZ-vCrSb51P0Qtgi2AQKUU0UdouTjMbJQ4XusAqaJTMqC7/s72-c/a.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-1600114228616694697</id><published>2019-09-19T15:03:00.000+07:00</published><updated>2019-09-19T15:03:29.545+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Tips"/><title type='text'>Using SQL Cursor for Looping</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;If you ever heard of SQL &lt;i&gt;cursor&lt;/i&gt;, this is probably not a new thing to you. If you never heard or use &lt;i&gt;cursor&lt;/i&gt; in SQL before, we usually use &lt;i&gt;cursor&lt;/i&gt; to replace the ordinary looping in SQL. The performance is generally better compared to using &lt;i&gt;WHILE&lt;/i&gt; or ordinary looping method, depending on how it is implemented. Reason being, &lt;i&gt;cursor&lt;/i&gt; is stored in memory.&lt;br /&gt;
&lt;br /&gt;
I have a good example on usage of &lt;i&gt;cursor&lt;/i&gt; in SQL.&lt;br /&gt;
In CRM &amp;amp; loyalty, we are looking at membership and loyalty points. Customers earn points when they transact or purchase something.&lt;br /&gt;
In this scenario, there is a points cap for members transactions, in which customers can only earn x number of points from their purchase.&lt;br /&gt;
&lt;br /&gt;
We want to retrospectively calculate the correct points earned given customer&#39;s transactions and the points they earned.&lt;br /&gt;
&lt;br /&gt;
Example of the records:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdy-uBymnlbEav64crKppVXudajfpSh76HTWz5mWoPEk3nd-jWjFHpHKkTGwn7LflUpRuLmqpP_QwYLmen_fiIqDeICx5xm9TGTr3_jkZQ1PQFSDf8rv5aux7ltZQjbbqTZezrh01vYxSt/s1600/cursor_1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;291&quot; data-original-width=&quot;439&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdy-uBymnlbEav64crKppVXudajfpSh76HTWz5mWoPEk3nd-jWjFHpHKkTGwn7LflUpRuLmqpP_QwYLmen_fiIqDeICx5xm9TGTr3_jkZQ1PQFSDf8rv5aux7ltZQjbbqTZezrh01vYxSt/s1600/cursor_1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Points is capped at member-level. This means, different customer / member can have different points cap, denoted in the last column in the example above.&lt;br /&gt;
Since we are looking at member-level, we will look at the re-arranged version of the records.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidMgkSL_pxJyjwDwlSXoXbzjhJ1167W0l376O_Cm-DiuqE8kD3_geUNDctDXM4l4s4UvW5mhccffgrK5x6_FCO3rmtgrSszw9_Iy5IVBaMDJCfTyCXk9JEa2eoUwdOYp67Kgq3qpXtojYL/s1600/cursor_2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;294&quot; data-original-width=&quot;439&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidMgkSL_pxJyjwDwlSXoXbzjhJ1167W0l376O_Cm-DiuqE8kD3_geUNDctDXM4l4s4UvW5mhccffgrK5x6_FCO3rmtgrSszw9_Iy5IVBaMDJCfTyCXk9JEa2eoUwdOYp67Kgq3qpXtojYL/s1600/cursor_2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;br /&gt;
This is the end result we are looking at. Observe the last field in the table. The content in the Correct_PointsEarned is always within the points cap for each member, in the order of the transaction sequence. Once the points cap has been met, the Correct_PointsEarned will be 0 for that member.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9k9bsxF43EElWf2L1RkcXYq-Hw0ioRD_MiLW9SIlXhDoEImsptO7zyylR1W75pUqXtg3N6Im9HkrcoW12mOSr5e84ih24ursZsqs8hFQ7iYldHgMfxr7ut42LlSCNm6huE0xK0HhA5IR4/s1600/cursor_3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;295&quot; data-original-width=&quot;579&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9k9bsxF43EElWf2L1RkcXYq-Hw0ioRD_MiLW9SIlXhDoEImsptO7zyylR1W75pUqXtg3N6Im9HkrcoW12mOSr5e84ih24ursZsqs8hFQ7iYldHgMfxr7ut42LlSCNm6huE0xK0HhA5IR4/s1600/cursor_3.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
You should familiarize yourself with how to create a &lt;i&gt;cursor &lt;/i&gt;first.&lt;br /&gt;
This is a template of how a &lt;i&gt;cursor &lt;/i&gt;looks like:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;pre&gt;&lt;code&gt;--START CURSOR
declare cur1 cursor for
select *
from &lt;xxx&gt;
order by &lt;yyy&gt;

open cur1

fetch next from cur1
into @zzz, @sss, ......

while @@FETCH_STATUS = 0
BEGIN
 --do the necessary processing here
 
 
 --fetch next record
 fetch next from cur1
 into @zzz, @sss, ......
END

close cur1
deallocate cur1
--END CURSOR
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This is the script to create temp table to populate the data:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;pre&gt;&lt;code&gt;create table #TmpPointsCap (
 TransactAutoID bigint identity(1,1),
 MemberID nvarchar(100),
 TransactDate date,
 TransactPoints numeric(18,4),
 PointsCap numeric(18,4),
 Correct_PointsEarned numeric(18,4) default(0.00),
 AddedOn datetime default(getdate())
)

insert into #TmpPointsCap (MemberID, TransactDate, TransactPoints, PointsCap)
values (&#39;M0001&#39;, &#39;2019/01/01&#39;, 100, 700)

insert into #TmpPointsCap (MemberID, TransactDate, TransactPoints, PointsCap)
values (&#39;M0002&#39;, &#39;2019/01/02&#39;, 200, 500)

insert into #TmpPointsCap (MemberID, TransactDate, TransactPoints, PointsCap)
values (&#39;M0004&#39;, &#39;2019/01/02&#39;, 400, 300)

insert into #TmpPointsCap (MemberID, TransactDate, TransactPoints, PointsCap)
values (&#39;M0001&#39;, &#39;2019/01/03&#39;, 500, 700)

insert into #TmpPointsCap (MemberID, TransactDate, TransactPoints, PointsCap)
values (&#39;M0003&#39;, &#39;2019/01/03&#39;, 700, 1000)

insert into #TmpPointsCap (MemberID, TransactDate, TransactPoints, PointsCap)
values (&#39;M0001&#39;, &#39;2019/01/05&#39;, 200, 700)

insert into #TmpPointsCap (MemberID, TransactDate, TransactPoints, PointsCap)
values (&#39;M0002&#39;, &#39;2019/01/06&#39;, 100, 500)

insert into #TmpPointsCap (MemberID, TransactDate, TransactPoints, PointsCap)
values (&#39;M0003&#39;, &#39;2019/01/06&#39;, 300, 1000)

insert into #TmpPointsCap (MemberID, TransactDate, TransactPoints, PointsCap)
values (&#39;M0002&#39;, &#39;2019/01/06&#39;, 400, 500)

insert into #TmpPointsCap (MemberID, TransactDate, TransactPoints, PointsCap)
values (&#39;M0002&#39;, &#39;2019/01/08&#39;, 200, 500)

insert into #TmpPointsCap (MemberID, TransactDate, TransactPoints, PointsCap)
values (&#39;M0003&#39;, &#39;2019/01/08&#39;, 100, 1000)

insert into #TmpPointsCap (MemberID, TransactDate, TransactPoints, PointsCap)
values (&#39;M0004&#39;, &#39;2019/01/09&#39;, 100, 300)

insert into #TmpPointsCap (MemberID, TransactDate, TransactPoints, PointsCap)
values (&#39;M0005&#39;, &#39;2019/01/10&#39;, 200, 200)

--Original table content
select * from #Tmppointscap

--The data sorted in the order we want
select TransactAutoID, MemberID, TransactDate, TransactPoints, PointsCap, Correct_PointsEarned = 0
from #TmpPointsCap
order by MemberID, TransactDate, AddedOn
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
And this is how we use &lt;i&gt;cursor &lt;/i&gt;to achieve the correct point earned in the last column:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;pre&gt;&lt;code&gt;--Temporary variables to store the table fields
declare @MemberID nvarchar(100), @TransactAutoID bigint, @TransactPoints numeric(18,4), @PointsCap numeric(18,4)
declare @PrevMemberID nvarchar(100) = &#39;&#39;
declare @RunningPoints numeric(18,4) = 0


--START CURSOR
declare cur1 cursor for
select MemberID, TransactAutoID, TransactPoints, PointsCap
from #TmpPointsCap
order by MemberID, TransactDate, AddedOn

open cur1

fetch next from cur1
into @MemberID, @TransactAutoID, @TransactPoints, @PointsCap

while @@FETCH_STATUS = 0
BEGIN
 --do the necessary processing here
 if @MemberID &lt;&gt; @PrevMemberID
 begin
  --set initial running points as the 1st TransactPoints
  set @RunningPoints = 0
 end
 
 if @RunningPoints &lt; @PointsCap and (@RunningPoints + @TransactPoints) &gt; @PointsCap
 begin
  --if after adding the TransactPoints, it is bigger than the pointscap
  --only earn at most, as much as the pointscap
  update #TmpPointsCap
  set Correct_PointsEarned = @PointsCap - @RunningPoints
  where TransactAutoID = @TransactAutoID

  --Update RunningPoints = PointsCap
  set @RunningPoints += @TransactPoints
 end
 else if (@RunningPoints + @TransactPoints) = @PointsCap
 begin
  --earning all the transactpoints just good
  update #TmpPointsCap
  set Correct_PointsEarned = @TransactPoints
  where TransactAutoID = @TransactAutoID
  
  set @RunningPoints += @TransactPoints
 end
 else if @RunningPoints &lt; @PointsCap
 begin
  --update the running points
  set @RunningPoints += @TransactPoints
  
  --update the correct points earned in the table
  update #TmpPointsCap
  set Correct_PointsEarned = TransactPoints
  where TransactAutoID = @TransactAutoID
 end
 else
 begin
  --not earning any points anymore
  update #TmpPointsCap
  set Correct_PointsEarned = 0
  where TransactAutoID = @TransactAutoID
 end
 
 set @PrevMemberID = @MemberID

 --fetch next record
 fetch next from cur1
 into @MemberID, @TransactAutoID, @TransactPoints, @PointsCap
END

close cur1
deallocate cur1
--END CURSOR

--Check the temp table again after updated
select TransactAutoID, MemberID, TransactDate, TransactPoints, PointsCap, Correct_PointsEarned
from #TmpPointsCap
order by MemberID, TransactDate, AddedOn
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
Good Luck, and Happy Query-ing!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/1600114228616694697/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2019/09/using-sql-cursor-for-looping.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/1600114228616694697'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/1600114228616694697'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2019/09/using-sql-cursor-for-looping.html' title='Using SQL Cursor for Looping'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdy-uBymnlbEav64crKppVXudajfpSh76HTWz5mWoPEk3nd-jWjFHpHKkTGwn7LflUpRuLmqpP_QwYLmen_fiIqDeICx5xm9TGTr3_jkZQ1PQFSDf8rv5aux7ltZQjbbqTZezrh01vYxSt/s72-c/cursor_1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-5527030526764361833</id><published>2019-09-10T06:28:00.000+07:00</published><updated>2019-09-10T06:28:17.578+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Pentaho"/><title type='text'>Connecting to SQL Instance with Non-Default Port on Pentaho</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
If you are trying to connect to SQL instance on Pentaho, and your SQL instance is using non-default port, then you need to fill in the connection string a bit differently.&lt;br /&gt;
&lt;br /&gt;
This is how we normally fill in the connection to SQL instance, when connecting to default port.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU9yEJVikPILp65G9YEG7jMCx-f6wbJ-nEtJ5iceh3LMkaTe1YYfjc-9QWaoxeDnnFMJM7vC0Pqi8Bi_2cisGxAN6FRxuVOnqiYoiuh7IKzxiayU5dn9vtdfu_QSdXelKX8yVf6jRkkk0l/s1600/Pentaho_NormalConnect.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;513&quot; data-original-width=&quot;746&quot; height=&quot;440&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU9yEJVikPILp65G9YEG7jMCx-f6wbJ-nEtJ5iceh3LMkaTe1YYfjc-9QWaoxeDnnFMJM7vC0Pqi8Bi_2cisGxAN6FRxuVOnqiYoiuh7IKzxiayU5dn9vtdfu_QSdXelKX8yVf6jRkkk0l/s640/Pentaho_NormalConnect.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
If you are connecting to some other ports, you need to explicitly type in the connection parameters inside the IP field.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDKwdu4rfa5pUed0rcCg09QdULEWC8MNRcZ5ZCTu3G5Of50mhVTtP3Pd-C7IJE-18kafp9DUCvpWgIlLWkoOaeSFfnahDfSWQNu-k3coRJC9g7ClY6_Qvix1d2Mb44AkjTjQESdzTOxbCf/s1600/Pentaho_WithPort.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;519&quot; data-original-width=&quot;865&quot; height=&quot;384&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDKwdu4rfa5pUed0rcCg09QdULEWC8MNRcZ5ZCTu3G5Of50mhVTtP3Pd-C7IJE-18kafp9DUCvpWgIlLWkoOaeSFfnahDfSWQNu-k3coRJC9g7ClY6_Qvix1d2Mb44AkjTjQESdzTOxbCf/s640/Pentaho_WithPort.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/5527030526764361833/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2019/09/connecting-to-sql-instance-with-non.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/5527030526764361833'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/5527030526764361833'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2019/09/connecting-to-sql-instance-with-non.html' title='Connecting to SQL Instance with Non-Default Port on Pentaho'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU9yEJVikPILp65G9YEG7jMCx-f6wbJ-nEtJ5iceh3LMkaTe1YYfjc-9QWaoxeDnnFMJM7vC0Pqi8Bi_2cisGxAN6FRxuVOnqiYoiuh7IKzxiayU5dn9vtdfu_QSdXelKX8yVf6jRkkk0l/s72-c/Pentaho_NormalConnect.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-7705246583369499288</id><published>2017-12-19T10:36:00.001+07:00</published><updated>2017-12-19T10:36:16.181+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tableau"/><title type='text'>Dual Axis not Working in Tableau</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Problem&lt;/b&gt;:&lt;br /&gt;
When creating chart with Dual Axis, Synchronize Axis is disabled and cannot be clicked.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi51_Y21WOUTZ8M3rDKzjIcbxCARJeaSj0hgB7JBH0WZ1PceF0BQ8pWpIZrQyGnySHftESbkvGzqG72Awg2BwBK5Ua-WOIIjTD5Pe-4UP3Ly1zOV7K2anHQFWLw_nF_qqUlJPGK5gwRJjo4/s1600/Dual_Axis_1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;563&quot; data-original-width=&quot;1367&quot; height=&quot;257&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi51_Y21WOUTZ8M3rDKzjIcbxCARJeaSj0hgB7JBH0WZ1PceF0BQ8pWpIZrQyGnySHftESbkvGzqG72Awg2BwBK5Ua-WOIIjTD5Pe-4UP3Ly1zOV7K2anHQFWLw_nF_qqUlJPGK5gwRJjo4/s640/Dual_Axis_1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Cause&lt;/b&gt;:&lt;br /&gt;
Tableau identified this as a bug, though it is supposed to have been fixed on later version, but it somehow still happens.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Solution&lt;/b&gt;:&lt;br /&gt;
1. To enable Synchronize Axis, make sure that the &lt;b&gt;data type&lt;/b&gt; of both the measures &lt;b&gt;are the same&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
2. If you are using Integer data type, problem persists even if the data types are the same. You should convert the measures to &lt;b&gt;float&lt;/b&gt;.&lt;br /&gt;
Notice that now the Synchronize Axis is enabled after we convert the data type to float.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8BvyT5rs8HdNyuSBqaA3zHk78PQOPO49ekWfp5zaVoWO180p6K8uWWI6ccUxYVCnxqcTmCCIa4pe0KPI6f7tlRxhc_ksKX4PVGK0OcpgNglEZ6GHwXhlWyyE9MgxfhRRoX8c8LhyphenhyphenKaO-n/s1600/Dual_Axis_2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;574&quot; data-original-width=&quot;1394&quot; height=&quot;262&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8BvyT5rs8HdNyuSBqaA3zHk78PQOPO49ekWfp5zaVoWO180p6K8uWWI6ccUxYVCnxqcTmCCIa4pe0KPI6f7tlRxhc_ksKX4PVGK0OcpgNglEZ6GHwXhlWyyE9MgxfhRRoX8c8LhyphenhyphenKaO-n/s640/Dual_Axis_2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
Format it with 0 decimal points if you want it to appear as integer.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglhc_-Wkc4mdtfCVCd5uCTdBL0XAYNOXhetmeGSPx9mbsJZY4K3bJ5KBZp7r7ZvJ-jHIb6IsWmgoh4_psxZxuryRYREtGZW3n_AuMgCqPNRZYAxmOynBqZtsQw-bc0QwmVr4Kph7RTenrz/s1600/Dual_Axis_3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;552&quot; data-original-width=&quot;853&quot; height=&quot;410&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglhc_-Wkc4mdtfCVCd5uCTdBL0XAYNOXhetmeGSPx9mbsJZY4K3bJ5KBZp7r7ZvJ-jHIb6IsWmgoh4_psxZxuryRYREtGZW3n_AuMgCqPNRZYAxmOynBqZtsQw-bc0QwmVr4Kph7RTenrz/s640/Dual_Axis_3.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
And this is how the end result looks like.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGk5YMNj4nzl8P36HnnQC5QG3qiOdDk4XKTgH-YKZkp_yMXtm3DO8ncAsf2vEW4ObJsJQov4gZyl_nrxovrSuMsHs7xg3yiiUDDynK6t1qoQ0ptbUvOAmMhCQTNmftPuMAe3dgEw4iBzTR/s1600/Dual_Axis_4.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;897&quot; data-original-width=&quot;1218&quot; height=&quot;470&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGk5YMNj4nzl8P36HnnQC5QG3qiOdDk4XKTgH-YKZkp_yMXtm3DO8ncAsf2vEW4ObJsJQov4gZyl_nrxovrSuMsHs7xg3yiiUDDynK6t1qoQ0ptbUvOAmMhCQTNmftPuMAe3dgEw4iBzTR/s640/Dual_Axis_4.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
PS: I know the graph is ugly, but I hope you get what you need :)&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/7705246583369499288/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2017/12/dual-axis-not-working-in-tableau.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/7705246583369499288'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/7705246583369499288'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2017/12/dual-axis-not-working-in-tableau.html' title='Dual Axis not Working in Tableau'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi51_Y21WOUTZ8M3rDKzjIcbxCARJeaSj0hgB7JBH0WZ1PceF0BQ8pWpIZrQyGnySHftESbkvGzqG72Awg2BwBK5Ua-WOIIjTD5Pe-4UP3Ly1zOV7K2anHQFWLw_nF_qqUlJPGK5gwRJjo4/s72-c/Dual_Axis_1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-6095529305198499469</id><published>2017-11-23T16:28:00.003+07:00</published><updated>2017-11-23T16:28:49.728+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tableau"/><title type='text'>Tableau Server Unable to Start due to Blocked Ports</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Problem:&lt;br /&gt;
Sometimes you might need to use different (from the default port) port on Tableau. By default, SSL is using port 443. For my case, I use SSL and port 8443 for Tableau Server. After you changed the port, and tried to start Tableau service, you get this error:&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;*** Tableau Server Gateway requires port 443,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;***&amp;nbsp; &amp;nbsp; in use by process 4.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana, sans-serif;&quot;&gt;*** Tableau Server unable to start due to blocked ports.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Solution:&lt;br /&gt;
There are 2 files you need to change:&lt;br /&gt;
1. C:\Tableau\Tableau Server\data\tabsvc\config\httpd.conf&lt;br /&gt;
2. C:\Program Files\Tableau\Tableau Server\10.3\apache\conf\original\extra\httpd-ssl.conf&lt;br /&gt;
&lt;br /&gt;
Change the port to listen to &lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;8443&lt;/span&gt;&lt;/b&gt; (replace 443 to 8443) on these 2 files.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/6095529305198499469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2017/11/tableau-server-unable-to-start-due-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/6095529305198499469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/6095529305198499469'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2017/11/tableau-server-unable-to-start-due-to.html' title='Tableau Server Unable to Start due to Blocked Ports'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-2817075681044424259</id><published>2017-11-08T16:36:00.000+07:00</published><updated>2017-11-23T16:44:16.688+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tableau"/><title type='text'>Frame cannot Load - Content Security Policy Issue</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Problem:&lt;br /&gt;
You are using iframe to load a site from within a website, and the frame does not load.&lt;br /&gt;
In my case, I am using https for both the website and the iframe.&lt;br /&gt;
&lt;br /&gt;
Error:&lt;br /&gt;
If you press F12 on the browser, you will see error similar to:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;
Refused to frame &#39;https://iframe_site&#39; because it violates the following Content Security Policy directive:&amp;nbsp;default-src &#39;self&#39; &#39;unsafe-inline&#39; &#39;unsafe-eval&#39;...... (this can be found in web.config). Note that &#39;script-src&#39; was not explicitly set, so &#39;default-src&#39; is used as a fallback.&lt;/div&gt;
&lt;br /&gt;
Solution:&lt;br /&gt;
Add the iframe_site to content-security-policy on the web.config.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;httpProtocol&amp;gt;
 &amp;lt;customHeaders&amp;gt;
  &amp;lt;add name=&quot;Content-Security-Policy&quot; value=&quot;default-src &#39;self&#39; &#39;unsafe-inline&#39; &#39;unsafe-eval&#39; &lt;b&gt;iframe_site&lt;/b&gt;;&quot; /&amp;gt;
 &amp;lt;/customHeaders&amp;gt;
&amp;lt;/httpProtocol&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;PS&lt;/b&gt;: If you are using port for the iframe site, you would need to include the port when adding into web.config.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/2817075681044424259/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2017/11/frame-cannot-load-content-security.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/2817075681044424259'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/2817075681044424259'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2017/11/frame-cannot-load-content-security.html' title='Frame cannot Load - Content Security Policy Issue'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-8524620864380008947</id><published>2016-10-24T08:57:00.000+07:00</published><updated>2016-10-24T08:57:11.157+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Others"/><title type='text'>Cisco VPN not Working on Windows 10</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Error:&lt;br /&gt;
Cisco VPN is not working (cannot login and connect to VPN connection).&lt;br /&gt;
&lt;br /&gt;
Solution:&lt;br /&gt;
1. Right-click on the VPN client, and Run as Administrator.&lt;br /&gt;
2. Open regedit and go to&amp;nbsp;&lt;span style=&quot;background-color: #fefdfa; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px;&quot;&gt;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CVirtA and rename:&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;background-color: #fefdfa; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 1.4; list-style-image: initial; list-style-position: initial; margin: 0.5em 0px; padding: 0px 2.5em;&quot;&gt;
&lt;li style=&quot;border: none; margin: 0px 0px 0.25em; padding: 0.25em 0px;&quot;&gt;x86 - &quot;@oem8.ifn,%CVirtA_Desc%;Cisco Systems VPN Adapter&quot; to &quot;Cisco Systems VPN Adapter&quot;&lt;/li&gt;
&lt;li style=&quot;border: none; margin: 0px 0px 0.25em; padding: 0.25em 0px;&quot;&gt;x64 -&amp;nbsp;&quot;@oem8.ifn,%CVirtA_Desc%;Cisco Systems VPN Adapter for 64-bit Windows&quot; to &quot;Cisco Systems VPN Adapter for 64-bit Windows&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;background-color: #fefdfa; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: #fefdfa; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px;&quot;&gt;Source partially from:&amp;nbsp;&lt;a href=&quot;https://itthatshouldjustwork.blogspot.sg/2015/07/cisco-64-bit-vpn-client-on-windows-10.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;IT that should just work&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/8524620864380008947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2016/10/cisco-vpn-not-working-on-windows-10.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/8524620864380008947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/8524620864380008947'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2016/10/cisco-vpn-not-working-on-windows-10.html' title='Cisco VPN not Working on Windows 10'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-7025159423111526360</id><published>2016-06-20T13:14:00.000+07:00</published><updated>2016-06-20T13:14:40.821+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Tips"/><title type='text'>Find Maximum Value from Multiple Columns</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;A colleague asked about how to get maximum value from multiple columns. After searching it online, I found a pretty good way to get it, and thought it would be good to share here.&lt;br /&gt;
&lt;br /&gt;
For example, I have a table with MemberID and 3 date fields. I want to get the last date from the 3 date fields for each MemberID.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLyP1r6Br-Dh1a401i3q88-fxVHSPXo9iGJSFq4a0FXlCFhMF_lmKvwaoSPxTOjUFPBY43c-ynKvCwxYxCQ3JAskB1p5gMVv91i_39w5_l09mBShbgKFCxf-QcU9k5EW8PPE26dMwlcq1A/s1600/sample1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;72&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLyP1r6Br-Dh1a401i3q88-fxVHSPXo9iGJSFq4a0FXlCFhMF_lmKvwaoSPxTOjUFPBY43c-ynKvCwxYxCQ3JAskB1p5gMVv91i_39w5_l09mBShbgKFCxf-QcU9k5EW8PPE26dMwlcq1A/s400/sample1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
The expected end result look like:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgF8sUk9CVF-Tv_yPtv29IY3AH0zcoZ9_mq7ITcTkB_nehMUAtGof8WZw_MMxhsGho2IOlNX1y3pRkA6_B2YZgXgG3ZpSntHKbOTjWesrxTdYi9HSj4L4E9SbvzUZ5LbR6HLnHgneK4yheF/s1600/sample2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;126&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgF8sUk9CVF-Tv_yPtv29IY3AH0zcoZ9_mq7ITcTkB_nehMUAtGof8WZw_MMxhsGho2IOlNX1y3pRkA6_B2YZgXgG3ZpSntHKbOTjWesrxTdYi9HSj4L4E9SbvzUZ5LbR6HLnHgneK4yheF/s320/sample2.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Creating the sample data:&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;pre&gt;&lt;code&gt;create table #member ( MemberID nvarchar(100), modifiedon datetime, deletedon datetime, addedon datetime )
insert into #member values (&#39;M1&#39;, GETDATE(), GETDATE(), GETDATE())
insert into #member values (&#39;M2&#39;, GETDATE()-1, GETDATE()-2, GETDATE()-3)
insert into #member values (&#39;M3&#39;, GETDATE()-3, GETDATE()-2, GETDATE()-1)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Query to get the max for multiple columns:&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;pre&gt;&lt;code&gt;SELECT 
 MemberID, 
 LastUpdateDate =
 ( SELECT MAX(LastUpdateDate)
  FROM (VALUES (modifiedon),(deletedon),(addedon)) AS UpdateDate(LastUpdateDate)
 )
FROM #member
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/7025159423111526360/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2016/06/find-maximum-value-from-multiple-columns.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/7025159423111526360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/7025159423111526360'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2016/06/find-maximum-value-from-multiple-columns.html' title='Find Maximum Value from Multiple Columns'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLyP1r6Br-Dh1a401i3q88-fxVHSPXo9iGJSFq4a0FXlCFhMF_lmKvwaoSPxTOjUFPBY43c-ynKvCwxYxCQ3JAskB1p5gMVv91i_39w5_l09mBShbgKFCxf-QcU9k5EW8PPE26dMwlcq1A/s72-c/sample1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-9203331819422728851</id><published>2016-01-22T14:39:00.000+07:00</published><updated>2016-01-22T14:43:12.758+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Tips"/><title type='text'>Calculating Customer&#39;s Latency</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;There were times when I was asked to retrieve the latency of the customers in my work. At first, I was confused about how to retrieve this. After some thought, I find a solution, which is actually pretty simple, and the SQL usage is widely available. Unfortunately, when I tried searching it online, the SQL technique is seldom associated with latency problem in retail industry.&lt;br /&gt;
&lt;br /&gt;
This is an illustration of what we want to achieve.&lt;br /&gt;
Given members and their transaction date. We want to find the average latency of members. To get the average latency, we would need to get the difference in days, between member&#39;s 1st and 2nd visit, 2nd and 3rd visit, 3rd and 4th visit, etc. The average of these differences will be the average latency of the members.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjq-7bwfKp3JMPiIP9-12sypDgLBU8pNsp5kBOcLIHzi-Sxy10hhAGZeS7-Qwo2N1N2vK5A7n5Dmz8LnKLcvkxoWn28PgYF2DW0GhcgnItFmA02LmJ3kWjZX4Nx4YIKJLw3drLGvOYzKZae/s1600/latency.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjq-7bwfKp3JMPiIP9-12sypDgLBU8pNsp5kBOcLIHzi-Sxy10hhAGZeS7-Qwo2N1N2vK5A7n5Dmz8LnKLcvkxoWn28PgYF2DW0GhcgnItFmA02LmJ3kWjZX4Nx4YIKJLw3drLGvOYzKZae/s1600/latency.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;p&gt;&lt;/p&gt;To do this on SQL, we can rank the member&#39;s transaction based on the TransactDate, and then self-join to the same set of records, but shift the ranking by one order. This way, we will get the difference of days between a transaction and the subsequent transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2xVxSX__2d4Zn89G8zkLbFVQt-UP5bFg2_d_oVG8sDffID_ct7zCtqcVCwJWxNmoQ9EUJ4aN3OLdYrJrtgTLsFi-pIBa5BkncszS1l6PEvIabpZ8F_HFbjNCNuMuONvyvzfNavwRqzI6N/s1600/latency2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2xVxSX__2d4Zn89G8zkLbFVQt-UP5bFg2_d_oVG8sDffID_ct7zCtqcVCwJWxNmoQ9EUJ4aN3OLdYrJrtgTLsFi-pIBa5BkncszS1l6PEvIabpZ8F_HFbjNCNuMuONvyvzfNavwRqzI6N/s1600/latency2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;Here are the SQL queries to prepare the data:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;pre&gt;&lt;code&gt;
--Create temp table
CREATE TABLE #Transact
(
 MemberID NVARCHAR(100),
 RecieptNo NVARCHAR(100),
 TransactDate DATE
)

--Insert dummy data
INSERT INTO #Transact VALUES (&#39;M001&#39;, &#39;R001&#39;, &#39;2015/11/20&#39;)
INSERT INTO #Transact VALUES (&#39;M001&#39;, &#39;R002&#39;, &#39;2015/12/30&#39;)
INSERT INTO #Transact VALUES (&#39;M001&#39;, &#39;R003&#39;, &#39;2016/01/05&#39;)

INSERT INTO #Transact VALUES (&#39;M002&#39;, &#39;R004&#39;, &#39;2015/09/12&#39;)
INSERT INTO #Transact VALUES (&#39;M002&#39;, &#39;R005&#39;, &#39;2015/09/15&#39;)
INSERT INTO #Transact VALUES (&#39;M002&#39;, &#39;R006&#39;, &#39;2015/09/25&#39;)
INSERT INTO #Transact VALUES (&#39;M002&#39;, &#39;R007&#39;, &#39;2015/10/30&#39;)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;p&gt;&lt;/p&gt;Here are the SQL queries to get the Latency per member:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;pre&gt;&lt;code&gt;
--Store the ranked transaction into temp table. Alternately, use common table expression
SELECT MemberID, TransactDate, RankNo = ROW_NUMBER() OVER(PARTITION BY MemberID ORDER BY TransactDate)
INTO #1
FROM #Transact

--Get the average latency per member
SELECT MemberID, Latency = AVG(CONVERT(NUMERIC(18,2), Latency))
FROM ( SELECT a.MemberID,
   Latency = DATEDIFF(DAY, a.TransactDate, b.TransactDate)
  FROM #1 a
  INNER JOIN #1 b
   ON b.MemberID = a.MemberID
   AND b.RankNo = (a.RankNo + 1) 
) aa GROUP BY aa.MemberID
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
That&#39;s all folks!&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/9203331819422728851/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2016/01/calculating-customers-latency.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/9203331819422728851'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/9203331819422728851'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2016/01/calculating-customers-latency.html' title='Calculating Customer&#39;s Latency'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjq-7bwfKp3JMPiIP9-12sypDgLBU8pNsp5kBOcLIHzi-Sxy10hhAGZeS7-Qwo2N1N2vK5A7n5Dmz8LnKLcvkxoWn28PgYF2DW0GhcgnItFmA02LmJ3kWjZX4Nx4YIKJLw3drLGvOYzKZae/s72-c/latency.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-7993628881361954820</id><published>2015-08-06T16:01:00.001+07:00</published><updated>2015-08-06T16:01:28.542+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Errors"/><title type='text'>A Severe Error Occurred on The Current Command</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
SQL Error:&lt;br /&gt;
A severe error occurred on the current command. The results, if any, should be discarded.&lt;br /&gt;
&lt;br /&gt;
Solution:&lt;br /&gt;
Disconnect and connect to the SQL database again.&lt;br /&gt;
&lt;br /&gt;
Source:&amp;nbsp;&lt;a href=&quot;http://stackoverflow.com/questions/14808612/what-does-a-severe-error-occurred-on-the-current-command-the-results-if-any&quot; target=&quot;_blank&quot;&gt;Stackoverflow&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/7993628881361954820/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2015/08/a-severe-error-occurred-on-current.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/7993628881361954820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/7993628881361954820'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2015/08/a-severe-error-occurred-on-current.html' title='A Severe Error Occurred on The Current Command'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-725923550781183094</id><published>2015-01-27T15:23:00.001+07:00</published><updated>2015-01-27T15:25:27.067+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Errors"/><title type='text'>XML Data Type is Not Supported in Distributed Queries</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Error&lt;/b&gt;: Xml data type is not supported in distributed queries. Remote object &#39;&lt;b&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;&amp;lt;ServerIP&amp;gt;&lt;/span&gt;&lt;/b&gt;\&lt;b&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;&amp;lt;ServerInstance&amp;gt;&lt;/span&gt;&lt;/b&gt;.&lt;b&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;&amp;lt;DatabaseName&amp;gt;&lt;/span&gt;&lt;/b&gt;.&lt;b&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;&amp;lt;Owner&amp;gt;&lt;/span&gt;&lt;/b&gt;.&lt;b&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;&amp;lt;TableName&amp;gt;&lt;/span&gt;&lt;/b&gt;&#39; has xml column(s).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Problem&lt;/b&gt;:&lt;br /&gt;
This error occurs when trying to select data from table on different server (using linked server) containing XML data type (even though the column with XML data type is not selected).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Solution&lt;/b&gt;:&lt;br /&gt;
Create a view on the remote server, and then select the view instead of directly selecting from the table containing XML data type.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;&amp;lt;ServerInstance&amp;gt;&lt;/span&gt;&lt;/b&gt; = 10.0.0.101&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;&amp;lt;DatabaseName&amp;gt;&lt;/span&gt;&lt;/b&gt; = DB1&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;&amp;lt;Owner&amp;gt;&lt;/span&gt;&lt;/b&gt; = dbo&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #274e13;&quot;&gt;&amp;lt;TableName&amp;gt;&lt;/span&gt;&lt;/b&gt; = Table1&lt;br /&gt;
&lt;br /&gt;
Instead of using:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
SELECT * FROM [10.0.0.101.DB1].dbo.Table1&lt;/blockquote&gt;
&lt;br /&gt;
Create a view on the remote server:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
CREATE VIEW vGetTable1&lt;br /&gt;
AS&lt;br /&gt;
SELECT * FROM dbo.Table1&lt;/blockquote&gt;
&lt;br /&gt;
And call the view:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
SELECT * FROM [10.0.0.101.DB1].dbo.vGetTable1&lt;/blockquote&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/725923550781183094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2015/01/xml-data-type-is-not-supported-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/725923550781183094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/725923550781183094'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2015/01/xml-data-type-is-not-supported-in.html' title='XML Data Type is Not Supported in Distributed Queries'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-3316106169086071325</id><published>2014-11-27T16:00:00.000+07:00</published><updated>2014-11-27T16:00:23.893+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tableau"/><title type='text'>Add Trusted Hosts to Tableau Server</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Problem&lt;/b&gt;: After deploying Tableau dashboards, you are not able to display the dashboard using trusted ticket method. Error returned: &quot;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Could not locate unexpired trusted ticket &amp;lt;&lt;i&gt;ticket_number&lt;/i&gt;&amp;gt;&lt;/span&gt;&lt;/b&gt;&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Solution&lt;/b&gt;: Although there could be various reason for this error, you might want to check if the IP address in which the Tableau dashboard is going to be displayed, is already added to the trusted hosts in the Tableau server. If it is not yet added, add it to the trusted hosts.&lt;br /&gt;
Note: Make sure not to overwrite the existing trusted hosts already added previously.&lt;br /&gt;
&lt;br /&gt;
Assume the host (where the Tableau dashboard is going to be displayed) is: &lt;span style=&quot;color: blue;&quot;&gt;10.0.0.99&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
1. Go to the Tableau server, and look for&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;dataserver.properties&lt;/span&gt;&lt;/b&gt;, located in&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;C:\ProgramData\Tableau\Tableau Server\data\tabsvc\config\&lt;/span&gt;&lt;/b&gt; (location might vary).&lt;br /&gt;
Search for trusted_hosts, and take note of the existing trusted hosts already added previously.&lt;br /&gt;
e.g. &lt;b&gt;&lt;i&gt;trusted_hosts=10.0.0.91, 10.0.100.92&lt;/i&gt;&lt;/b&gt;. We will include these IPs again later.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
2. Add the IP address(es) where Tableau dashboard is going to be displayed. Open Command Prompt, then go to &lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;C:\Program Files (x86)\Tableau\Tableau Server\7.0\bin\&lt;/span&gt;&lt;/b&gt; (location might vary), and use the command&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
tabadmin set wgserver.trusted_hosts &quot;&amp;lt;&lt;i&gt;Trusted IP Addresses&lt;/i&gt;&amp;gt;&quot;&amp;nbsp;&lt;/blockquote&gt;
&lt;div&gt;
to add the trusted hosts. Don&#39;t forget to also include the existing trusted IP addresses previously added, &lt;b&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;separated by comma&lt;/span&gt;&lt;/b&gt; if there is more than 1 IP address.&lt;/div&gt;
&lt;div&gt;
e.g.&amp;nbsp;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
tabadmin set wgserver.trusted_hosts &quot;10.0.0.91, 10.0.100.92, 10.0.0.99&quot;&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
3. Save the configuration by using the command:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
tabadmin config&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
4. Check the file dataserver.properties on step 1 and look for trusted_hosts. Now, the content of the trusted hosts should look like &lt;b&gt;&lt;i&gt;trusted_hosts=10.0.0.91, 10.0.100.92, 10.0.0.99&lt;/i&gt;&lt;/b&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
5. Restart tableau server by using the command:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
tabadmin restart&lt;/blockquote&gt;
&lt;div&gt;
or run services.msc, then look for Tableau Server (tabsvc) service, and then restart the service.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
6. Verify if the Tableau dashboard can be displayed properly (in this case, from 10.0.0.99).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
7. That&#39;s all, folks!&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/3316106169086071325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2014/11/add-trusted-hosts-to-tableau-server.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/3316106169086071325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/3316106169086071325'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2014/11/add-trusted-hosts-to-tableau-server.html' title='Add Trusted Hosts to Tableau Server'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-7487232896978080592</id><published>2014-10-29T16:32:00.001+07:00</published><updated>2014-10-29T16:32:54.134+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.Net Deploying Problems"/><category scheme="http://www.blogger.com/atom/ns#" term="SSRS"/><title type='text'>Report cannot be Displayed</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Error:&lt;br /&gt;
- Event not fired.&lt;br /&gt;
- Microsoft.Reporting.WebForms.HttpHandlerInputException: Missing URL parameter: IterationId&lt;br /&gt;
(This is only part of the long error message).&lt;br /&gt;
- Report loads forever (never stops loading).&lt;br /&gt;
&lt;br /&gt;
Solution:&lt;br /&gt;
On the aspx page, add attribute: EnableEventValidation=&quot;false&quot;&lt;br /&gt;
&lt;br /&gt;
For my particular case, I was trying to display a report (SSRS), and it never stopped loading. However, for my case, it was because of the version of the Internet Explorer (yes, the report is only compatible with IE for mine). After changing the version of the IE through developer tool (F12), I managed to display the report properly. You can also try to display the report from another machine using the intended IE version to see if it displays properly.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/7487232896978080592/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2014/10/report-cannot-be-displayed.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/7487232896978080592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/7487232896978080592'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2014/10/report-cannot-be-displayed.html' title='Report cannot be Displayed'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-9117180377056745938</id><published>2014-09-23T14:43:00.002+07:00</published><updated>2024-03-13T12:49:44.431+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Tips"/><title type='text'>Combine Rows into a Column</title><content type='html'>Happened to find a way to combine rows into a column. I find it quite useful, and it comes in handy.&lt;br /&gt;
&lt;br /&gt;
For illustration, suppose we have UserGroup &amp;amp; Users. We want to list the users belonging to each group.&lt;br /&gt;
&lt;p&gt;&lt;/p&gt;UserGroup:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCAF6dAR3_cAEQLDEjzB43igvVrQQQVnXUQaOObcqFVw-nAZgx8A5d8W6zk2Y1LZz_pMENRg1G8FNMj6ebCWuoouGilrE_T0CgSryspQTXElbZayKi4CrOt7duKP1DqvNSzErh_uCdsVLv/s1600/usergroups.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCAF6dAR3_cAEQLDEjzB43igvVrQQQVnXUQaOObcqFVw-nAZgx8A5d8W6zk2Y1LZz_pMENRg1G8FNMj6ebCWuoouGilrE_T0CgSryspQTXElbZayKi4CrOt7duKP1DqvNSzErh_uCdsVLv/s1600/usergroups.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;p&gt;&lt;/p&gt;Users:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKdIGsu4onZLxCYnqt1pLzS_1-JHoiGYA3IaEoiShY6ukjwihHXVhhIQi_31j4pMn0FUMx9RJXDmopIWANWobw3AY1uZFWMHhmrLCxQjvZeCYnTH3qP5eEVUYI6SqcjqMf6AiVpbWht7zQ/s1600/users.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKdIGsu4onZLxCYnqt1pLzS_1-JHoiGYA3IaEoiShY6ukjwihHXVhhIQi_31j4pMn0FUMx9RJXDmopIWANWobw3AY1uZFWMHhmrLCxQjvZeCYnTH3qP5eEVUYI6SqcjqMf6AiVpbWht7zQ/s1600/users.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;p&gt;&lt;/p&gt;If we do normal joining of the 2 tables, it will look like:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwi7l4CyvQoapnnSGNDGOp4L45RypFAN4tuiU2ecnWMZ70A_GewRftsB29Eg8Q7faH5VZeOWKrSQ0KP-lDPY5MfSnNiLzfyBGnCH10bdyk5aHQO7rYW9xZDZelyAefqw2xRHhb6njrNKsW/s1600/normaljoin.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwi7l4CyvQoapnnSGNDGOp4L45RypFAN4tuiU2ecnWMZ70A_GewRftsB29Eg8Q7faH5VZeOWKrSQ0KP-lDPY5MfSnNiLzfyBGnCH10bdyk5aHQO7rYW9xZDZelyAefqw2xRHhb6njrNKsW/s1600/normaljoin.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;p&gt;&lt;/p&gt;If we combine the values on the rows into a column, it will look like:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjoR1Jd5KZlTx-SAjdduE9_4f34dI9CvFu_KspTLt2wbEB-SFRqXc_O4z36P4iuDSNtrX29zPvtlWWl_b3P1x7IBLCGTZP8Ga4LYE-gxZ__6eqzz_psozKwJ2dBpY3mxIUTAD7RzE8887D/s1600/combined.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjoR1Jd5KZlTx-SAjdduE9_4f34dI9CvFu_KspTLt2wbEB-SFRqXc_O4z36P4iuDSNtrX29zPvtlWWl_b3P1x7IBLCGTZP8Ga4LYE-gxZ__6eqzz_psozKwJ2dBpY3mxIUTAD7RzE8887D/s1600/combined.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;p&gt;&lt;/p&gt;Here is the query to do so:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;pre&gt;&lt;code&gt;-- Create temporary table to store UserGroup
SELECT GroupID = 1, UserGroup = &#39;Group 1&#39; INTO #UserGroup
INSERT INTO #UserGroup VALUES ( 2, &#39;Group 2&#39; )
INSERT INTO #UserGroup VALUES ( 3, &#39;Group 3&#39; )

-- Create temporary table to store Users
SELECT UserID = &#39;Superman&#39;, GroupID = 1 INTO #Users
INSERT INTO #Users VALUES ( &#39;Luck&#39;, 2 )
INSERT INTO #Users VALUES ( &#39;Himura&#39;, 1 )
INSERT INTO #Users VALUES ( &#39;Selvi&#39;, 1 )
INSERT INTO #Users VALUES ( &#39;Smarty&#39;, 2 )
INSERT INTO #Users VALUES ( &#39;Lucky&#39;, 3 )

-- Normal Join
SELECT a.UserGroup, b.UserID
FROM #UserGroup a
LEFT JOIN #Users b
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;ON b.GroupID = a.GroupID
ORDER BY a.UserGroup

-- Combine Rows into Column
SELECT UserGroup, Users = STUFF(( SELECT &#39;, &#39; + UserID FROM #Users a
    WHERE a.GroupID = b.GroupID
    ORDER BY a.UserID
    FOR XML PATH(&#39;&#39;) )
   , 1, 2, &#39;&#39;)
FROM #UserGroup b
ORDER BY UserGroup

-- This is the key query to combine rows into column
SELECT UserID + &#39;, &#39; FROM #Users
WHERE GroupID = 1
FOR XML PATH(&#39;&#39;)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
If you are concatenating a field which contains some HTML tag, it would be automatically encoded. To avoid that, consider using this query:&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 646.984px;&quot;&gt;&lt;pre&gt;&lt;code&gt;-- Combine Rows into Column
SELECT UserGroup, Users = STUFF(( SELECT &#39;, &#39; + UserID FROM #Users a
    WHERE a.GroupID = b.GroupID
    ORDER BY a.UserID
    &lt;span style=&quot;color: red;&quot;&gt;FOR XML PATH,TYPE).value(&#39;.[1]&#39;,&#39;nvarchar(max)&#39;)
   , 1, 2, &#39;&#39;)&lt;/span&gt;
FROM #UserGroup b
ORDER BY UserGroup&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;pre&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;
Update: Looks like I posted something similar quite some time ago, but using different method: &lt;a href=&quot;http://programmerslab.blogspot.sg/2012/07/select-several-rows-into-one-row-in-sql.html&quot; target=&quot;_blank&quot;&gt;Selecting several rows into one row in SQL&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/9117180377056745938/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2014/09/combine-rows-into-column.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/9117180377056745938'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/9117180377056745938'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2014/09/combine-rows-into-column.html' title='Combine Rows into a Column'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCAF6dAR3_cAEQLDEjzB43igvVrQQQVnXUQaOObcqFVw-nAZgx8A5d8W6zk2Y1LZz_pMENRg1G8FNMj6ebCWuoouGilrE_T0CgSryspQTXElbZayKi4CrOt7duKP1DqvNSzErh_uCdsVLv/s72-c/usergroups.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-1447814426193276194</id><published>2013-11-05T12:57:00.001+07:00</published><updated>2013-11-05T12:57:56.265+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Errors"/><title type='text'>Mapping User Login and Database Roles to Existing User</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Error:&lt;br /&gt;
User, group, or role &#39;xxx&#39; already exists in the current database. (.Net SqlClient Data Provider)&lt;br /&gt;
&lt;br /&gt;
Explanation:&lt;br /&gt;
This error happens when you try to add user mapping to the server logins using username which already exists in the database to be assigned.&lt;br /&gt;
&lt;br /&gt;
In my case, the user exists in both server logins and database logins, 
but the user mapping and database roles on the server logins for this 
user cannot be modified although the user mapping is incorrect, because 
it already exists on the database logins.&lt;br /&gt;
&lt;br /&gt;
Solution:&lt;br /&gt;
Run this script to update the user mapping accordingly.&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
USE &amp;lt;&lt;em&gt;database_name&lt;/em&gt;&amp;gt;&lt;br /&gt;EXEC sp_change_Users_login &#39;update_one&#39;, &#39;&amp;lt;&lt;em&gt;login_username&lt;/em&gt;&amp;gt;&#39;, &#39;&amp;lt;&lt;em&gt;login_username&lt;/em&gt;&amp;gt;&#39;&lt;/blockquote&gt;
&lt;br /&gt;This will update the user mapping and database roles on server logins to follow the ones on the database logins.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/1447814426193276194/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2013/11/mapping-user-login-and-database-roles.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/1447814426193276194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/1447814426193276194'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2013/11/mapping-user-login-and-database-roles.html' title='Mapping User Login and Database Roles to Existing User'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-5550962714420765679</id><published>2013-11-05T12:51:00.001+07:00</published><updated>2013-11-05T12:51:18.921+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.Net Debugging Problems"/><title type='text'>Current Transaction Cannot be Committed</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Error:&lt;br /&gt;
The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction.&lt;br /&gt;
&lt;br /&gt;
This error occurs when you try to perform other operations when any transaction fails in try catch section, soon after it goes to catch section.&lt;br /&gt;
&lt;br /&gt;
Solution:&lt;br /&gt;
You have to ROLLBACK first on the catch section before doing any other operations.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/5550962714420765679/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2013/11/current-transaction-cannot-be-committed.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/5550962714420765679'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/5550962714420765679'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2013/11/current-transaction-cannot-be-committed.html' title='Current Transaction Cannot be Committed'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-8121032395363574915</id><published>2013-11-05T12:45:00.001+07:00</published><updated>2013-11-05T12:46:32.622+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Errors"/><title type='text'>Directory Lookup Failed on SQL Server</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
When&amp;nbsp;executing&amp;nbsp;script on SQL server, this error occurs:&lt;br /&gt;
&lt;span id=&quot;yiv9801745155yui_3_7_2_19_1367457466247_67&quot;&gt;Directory lookup
 for the file&amp;nbsp;&amp;lt;&lt;em&gt;filepath&lt;/em&gt;&amp;gt;&lt;em&gt;&lt;filepath&gt;&lt;/filepath&gt;&lt;/em&gt; failed with the operating system error 2(The system cannot find the file specified.)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span id=&quot;yiv9801745155yui_3_7_2_19_1367457466247_67&quot;&gt;Directory lookup for the file &amp;lt;&lt;em&gt;filepath&lt;/em&gt;&amp;gt; failed with the operating system error 3(The system cannot find the path specified.)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Solution:&lt;br /&gt;
Check the directory used in the SQL script. Make sure that the directory used in the SQL script point to the &lt;strong&gt;&lt;span style=&quot;color: red;&quot;&gt;server location&lt;/span&gt;&lt;/strong&gt;, if the script is not directly executed from the server.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/8121032395363574915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2013/11/directory-lookup-fail-on-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/8121032395363574915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/8121032395363574915'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2013/11/directory-lookup-fail-on-sql-server.html' title='Directory Lookup Failed on SQL Server'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-8353624006034850464</id><published>2013-07-03T09:30:00.001+07:00</published><updated>2013-07-03T09:30:48.206+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Errors"/><title type='text'>Parameter Sniffing</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Parameter sniffing has a weird symptom which can take your hours to find out what actually is happening. The stored procedure you created is running on one side, but when you deploy it on another machine or server, it never ends executing despite the fact that everything is the same.&lt;br /&gt;
&lt;br /&gt;
This problem usually occurs when the query contains LIKE condition. However, it is not limited to this case. Query without LIKE condition can also face this problem.&lt;br /&gt;
&lt;br /&gt;
For example, here is the normal stored procedure:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;pre&gt;&lt;code&gt;&lt;span style=&quot;color: blue;&quot;&gt;CREATE PROCEDURE&lt;/span&gt; dbo.spr_GetData
@Parameter1 &lt;span style=&quot;color: blue;&quot;&gt;INT&lt;/span&gt;,
@Parameter2 &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;(200)
&lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt; *
&lt;span style=&quot;color: blue;&quot;&gt;FROM&lt;/span&gt; dbo.Table1
&lt;span style=&quot;color: blue;&quot;&gt;WHERE&lt;/span&gt; Column1 = @Parameter1
&lt;span style=&quot;color: #444444;&quot;&gt;AND&lt;/span&gt; Column2 &lt;span style=&quot;color: #444444;&quot;&gt;LIKE&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;%&#39;&lt;/span&gt; + @Parameter2 + &lt;span style=&quot;color: red;&quot;&gt;&#39;%&#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
To avoid parameter sniffing, there is a need to create new variables to store the values fetched from the parameters.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;pre&gt;&lt;code&gt;&lt;span style=&quot;color: blue;&quot;&gt;CREATE PROCEDURE&lt;/span&gt; dbo.spr_GetData
@Parameter1 &lt;span style=&quot;color: blue;&quot;&gt;INT&lt;/span&gt;,
@Parameter2 &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;(200)
&lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt;

&lt;span style=&quot;color: blue;&quot;&gt;DECLARE&lt;/span&gt;
@DummyParameter1 &lt;span style=&quot;color: blue;&quot;&gt;INT&lt;/span&gt; = @Parameter1,
@DummyParameter2 &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;(200) = @Parameter2

&lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt; *
&lt;span style=&quot;color: blue;&quot;&gt;FROM&lt;/span&gt; dbo.Table1
&lt;span style=&quot;color: blue;&quot;&gt;WHERE&lt;/span&gt; Column1 = @DummyParameter1
&lt;span style=&quot;color: #444444;&quot;&gt;AND&lt;/span&gt; Column2 &lt;span style=&quot;color: #444444;&quot;&gt;LIKE&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;%&#39;&lt;/span&gt; + @DummyParameter2 + &lt;span style=&quot;color: red;&quot;&gt;&#39;%&#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/8353624006034850464/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2013/07/parameter-sniffing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/8353624006034850464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/8353624006034850464'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2013/07/parameter-sniffing.html' title='Parameter Sniffing'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-5545804230221183708</id><published>2013-05-30T16:39:00.001+07:00</published><updated>2013-05-30T16:39:54.000+07:00</updated><title type='text'>Error Converting Data Type Int to Nvarchar</title><content type='html'>Error: Error converting data type int to nvarchar&lt;br /&gt;
&lt;br /&gt;
This error occurs when a stored procedure which returns a value is used.&lt;br /&gt;
&lt;br /&gt;
e.g&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;pre&gt;&lt;code&gt;CREATE PROCEDURE [dbo].[spr_SP1]
@ColA INT,
@AutoID INT OUTPUT
AS
BEGIN
 INSERT INTO TableA ( ColA )
 VALUES ( @ColA )

 SELECT @AutoID = SCOPE_IDENTITY();
END
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
When adding the parameter to the command on the code, usually the code used is:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;pre&gt;&lt;code&gt;command.Parameters.AddWithValue(&quot;@AutoID&quot;, System.DBNull.Value)
command.Parameters(&quot;@AutoID&quot;).Size = 4
command.Parameters(&quot;@AutoID&quot;).Direction = ParameterDirection.Output
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
However, this portion of code would possibly cause error during deployment. To avoid the error, use the code below instead:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;background-color: #ffffcc; clear: both; overflow: auto; width: 97%;&quot;&gt;&lt;pre&gt;&lt;code&gt;Dim param = New System.Data.SqlClient.SqlParameter()
param.ParameterName = &quot;@AutoID&quot;
param.Direction = ParameterDirection.Output
param.Size = 8
command.Parameters.Add(param)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/5545804230221183708/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2013/05/error-converting-data-type-int-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/5545804230221183708'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/5545804230221183708'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2013/05/error-converting-data-type-int-to.html' title='Error Converting Data Type Int to Nvarchar'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-9050106955351096801</id><published>2013-04-08T15:57:00.000+07:00</published><updated>2013-04-09T12:47:19.616+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.Net Deploying Problems"/><title type='text'>An Error Occurred While Parsing EntityName</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b style=&quot;color: blue;&quot;&gt;Error&lt;/b&gt;: &lt;b&gt;An Error occurred while parsing EntityName. Line 17, position 211.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.&lt;br /&gt;
&lt;br /&gt;
Exception Details: System.Xml.XmlException: An error occurred while parsing EntityName. Line 17, position 211.&lt;br /&gt;
&lt;br /&gt;
Source error: responseXml.LoadXml(response)&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #274e13;&quot;&gt;This error occurs because there is an ampersand (&amp;amp;) in the returned XML command.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: blue;&quot;&gt;Solution&lt;/b&gt;: Use “and” or other conjunctions instead of ampersand (&amp;amp;). Another option is to replace the string containing &amp;amp; with &quot;%26&quot;.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/9050106955351096801/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2013/04/an-error-occurred-while-parsing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/9050106955351096801'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/9050106955351096801'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2013/04/an-error-occurred-while-parsing.html' title='An Error Occurred While Parsing EntityName'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5216553291715844463.post-2938525174767906469</id><published>2012-11-29T14:05:00.001+07:00</published><updated>2013-03-20T10:35:59.946+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.Net Deploying Problems"/><title type='text'>Could not Load Type from Assembly</title><content type='html'>Error:&lt;br /&gt;
Could not load type &#39;xxxxxx&#39; from assembly &#39;AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&#39;.&lt;br /&gt;
&lt;br /&gt;
This error occurs when trying to open a webpage. The project is built successfully. However, when accessing particular page, the error pops out. The error message is actually quite long. This is only part of the error message.&lt;br /&gt;
&lt;br /&gt;
Solution:&lt;br /&gt;
On Visual Studio, go to menu &lt;strong&gt;&lt;span style=&quot;color: blue;&quot;&gt;Tools&lt;/span&gt;&lt;/strong&gt; -&amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;&lt;strong&gt;Options&lt;/strong&gt;&lt;/span&gt; -&amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;&lt;strong&gt;Debugging&lt;/strong&gt;&lt;/span&gt; -&amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;&lt;strong&gt;General&lt;/strong&gt;&lt;/span&gt; -&amp;gt; Disable &quot;&lt;span style=&quot;color: blue;&quot;&gt;&lt;strong&gt;Enable Just My Code&lt;/strong&gt;&lt;/span&gt;&quot; options.&lt;br /&gt;
&lt;br /&gt;
PS: I am not sure if there is another more feasible solution. This might only be a workaround. There could be side effects. As of now, it is still working fine after this option is disabled.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style=&quot;color: red;&quot;&gt;Update:&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
Looks like this does not really solve the issue. I find out that if the project or solution is rebuilt, it will go to normal when the web is run. If it doesn&#39;t, rebuild, then try it again.&lt;br /&gt;
&lt;br /&gt;
However, when the web is run on debug mode, some pages will get this error, thus not viewable. Another workaround is to view the web in browser (not in debug mode), then attach the process to the web. On Visual Studio, after the web is viewed in browser, go to menu &lt;span style=&quot;color: blue;&quot;&gt;&lt;strong&gt;Tools&lt;/strong&gt;&lt;/span&gt; -&amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;&lt;strong&gt;Attach to Process&lt;/strong&gt;&lt;/span&gt; -&amp;gt; look for the web server process under which the web is run, e.g. &lt;span style=&quot;color: blue;&quot;&gt;&lt;strong&gt;WebDev.WebServer20.EXE&lt;/strong&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://programmerslab.blogspot.com/feeds/2938525174767906469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://programmerslab.blogspot.com/2012/11/could-not-load-type-from-assembly_29.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/2938525174767906469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5216553291715844463/posts/default/2938525174767906469'/><link rel='alternate' type='text/html' href='http://programmerslab.blogspot.com/2012/11/could-not-load-type-from-assembly_29.html' title='Could not Load Type from Assembly'/><author><name>Steven Luck</name><uri>http://www.blogger.com/profile/05335979566112962818</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhChg0yCgiHblYcuWuoU-A_C-CgnBDNaFCzHU17EkgaCsd0kEsZKuJQ8kEjPqsVmB5dopLn173dPWWUjkixJ2VzjHr3ALRxtCEUrVhg8aZVpAje9DYZGz1bz6o71pBj_Q/s113/ryoma5.jpg'/></author><thr:total>0</thr:total></entry></feed>