<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ralf Eisenreich &#187; SQL Server</title>
	<atom:link href="http://sqlblog.de/blog/tag/sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://sqlblog.de/blog</link>
	<description>SQLBlog.DE &#124; ..things to remember</description>
	<lastBuildDate>Mon, 26 Dec 2011 14:37:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>T-SQL: IsNumeric function</title>
		<link>http://sqlblog.de/blog/2009/11/t-sql-isnumeric-function/</link>
		<comments>http://sqlblog.de/blog/2009/11/t-sql-isnumeric-function/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 16:18:27 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/?p=691</guid>
		<description><![CDATA[The IsNumeric function has a very variable interpretation algorithm. In order to get only numeric values following statement should be...]]></description>
			<content:encoded><![CDATA[<p>The IsNumeric function has a very variable interpretation algorithm. In order to get only numeric values following statement should be used:</p>
<p><code><br />
CASE WHEN (NUM_VALUE LIKE '%[0-9]%' AND ISNUMERIC(<em>NUM_VALUE</em>) = 1) THEN CAST(NUM_VALUE AS FLOAT) ELSE NULL END AS NUM_VALUE<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2009/11/t-sql-isnumeric-function/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>SSRS: Add Excel Export Link to Report</title>
		<link>http://sqlblog.de/blog/2009/10/ssrs-add-excel-export-link-to-report/</link>
		<comments>http://sqlblog.de/blog/2009/10/ssrs-add-excel-export-link-to-report/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 14:45:08 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[ssrs]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/?p=689</guid>
		<description><![CDATA[How to add a Excel Export Link to a Report Add an item (e.g. TextBox, Image, etc.) and open the...]]></description>
			<content:encoded><![CDATA[<p><strong>How to add a Excel Export Link to a Report</strong><br />
Add an item (e.g. TextBox, Image, etc.) and open the <em>properties dialog</em>. Under the <em>navigation tab</em> use the setting <em>Go to URL</em> and add following comand.</p>
<p><code><br />
=Globals!ReportServerUrl.ToString() + "/Pages/ReportViewer.aspx?"<br />
+ System.Web.HttpUtility.UrlEncode("https://ReportServer/ReportFolder/Report.rdl")<br />
+ "&#038;rs:Command=Render&#038;rs:Format=EXCEL&#038;rc:OmitFormulas=true"<br />
+ "&#038;[Parameter_Name1]=" + Join(Parameters![Parameter_Name1].Value, "&#038;[Parameter_Name1]=") --> Multivalue Parameter<br />
+ "&#038;[Parameter_Name2]=" + System.Web.HttpUtility.UrlEncode(Parameters![Parameter_Name2].Value) --> Normaler Paraemter<br />
</code></p>
<p>It is important to use the <em>HttpUtility.UrlEncode()</em> function in order to pass the correct values.<br />
In the properties dialog of the report add a reference to the <em>System.Web</em> assembly.</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2009/10/ssrs-add-excel-export-link-to-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSIS: Execute Package via Stored Procedure</title>
		<link>http://sqlblog.de/blog/2009/09/ssis-execute-package-via-stored-procedure/</link>
		<comments>http://sqlblog.de/blog/2009/09/ssis-execute-package-via-stored-procedure/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 12:42:44 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[ssis]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/?p=671</guid>
		<description><![CDATA[There are two options executing SSIS packages: - xp_cmdshell command (not recommended for security reasons) - sp_start_job command The main...]]></description>
			<content:encoded><![CDATA[<p>There are two options executing SSIS packages:</p>
<p>- <strong>xp_cmdshell</strong> command (not recommended for security reasons)<br />
- <strong>sp_start_job</strong> command</p>
<p>The main difference between both options is the execution method. The xp_cmdshell command is a <em>synchronous</em> call and the sp_start_job command is an <em>asynchronous</em> call.</p>
<p><strong>xp_cmdshell command</strong> (synchronous)</p>
<ul>
<li>enable xp_cmdshell mode in Surface Area Configuration Tool for SQL Server</li>
<li>use following procedure to execute SSIS package:<br />
<code><br />
DECLARE @returncode int<br />
EXEC @returncode = xp_cmdshell 'dtexec /f "<strong>PackageNameWithFullPath</strong>.dtsx"'<br />
</code>
</li>
</ul>
<p><strong>sp_start_job</strong> (asynchronous)</p>
<ul>
<li>define job in SQL Server Agent with SSIS execution step</li>
<li>use following procedure to start SQL Server Agent job with SSIS execution step:<br />
<code><br />
[msdb].dbo.sp_start_job @job_name='<strong>JobName</strong>'<br />
</code>
</li>
<li>check execution status of job, since the call is asynchronous:<br />
<code><br />
SELECT<br />
	[server],<br />
	[start_execution_date],<br />
	[stop_execution_date],<br />
	[run_date],<br />
	[run_duration],<br />
	[run_status],<br />
	[message]<br />
FROM<br />
	MSDB.DBO.SYSJOBS Z<br />
INNER JOIN<br />
	MSDB.DBO.SYSJOBACTIVITY A<br />
	ON Z.JOB_ID = A.JOB_ID<br />
INNER JOIN<br />
	(<br />
	SELECT<br />
		MAX(SESSION_ID) AS SESSION_ID<br />
	FROM<br />
		MSDB.DBO.SYSSESSIONS<br />
	) AS B<br />
	ON	A.SESSION_ID = B.SESSION_ID<br />
LEFT JOIN<br />
	MSDB.DBO.SYSJOBHISTORY C<br />
	ON A.JOB_HISTORY_ID = C.INSTANCE_ID<br />
WHERE<br />
	Z.NAME = '<strong>JobName</strong>'<br />
</code>
</li>
</ul>
<p>There is following way to make the call of sp_start_job synchronous.</p>
<p><strong>sp_start_job</strong> (<strong>synchronous</strong>)</p>
<ul>
<li>define job in SQL Server Agent with SSIS execution step</li>
<li>use following procedure to start SQL Server Agent job with SSIS execution step:<br />
<code><br />
ALTER PROCEDURE [dbo].[AGENT_JOB_CHECK2]<br />
-- Add the parameters for the stored procedure here<br />
DECLARE @job_name nvarchar(100)='',<br />
DECLARE @maxwaitmins int = 5<br />
AS<br />
BEGIN<br />
set NOCOUNT ON;<br />
set XACT_ABORT ON;<br />
    BEGIN TRY<br />
    declare @running as int<br />
    declare @seccount as int<br />
    declare @maxseccount as int<br />
    set @maxseccount = 60*@maxwaitmins<br />
    set @seccount = 0<br />
    set @running = 0<br />
    declare @job_owner sysname<br />
    declare @job_id UNIQUEIDENTIFIER<br />
    set @job_owner = SUSER_SNAME()<br />
    -- get job id<br />
    select @job_id=job_id<br />
    from msdb.dbo.sysjobs sj<br />
    where sj.name=@job_name<br />
    -- invalid job name then exit with an error<br />
    if @job_id is null<br />
        RAISERROR (N'Unknown job: %s.', 16, 1, @job_name)<br />
    -- output from stored procedure xp_sqlagent_enum_jobs is captured in the following table<br />
    declare @xp_results TABLE ( job_id                UNIQUEIDENTIFIER NOT NULL,<br />
                                last_run_date         INT              NOT NULL,<br />
                                last_run_time         INT              NOT NULL,<br />
                                next_run_date         INT              NOT NULL,<br />
                                next_run_time         INT              NOT NULL,<br />
                                next_run_schedule_id  INT              NOT NULL,<br />
                                requested_to_run      INT              NOT NULL, -- BOOL<br />
                                request_source        INT              NOT NULL,<br />
                                request_source_id     sysname          COLLATE database_default NULL,<br />
                                running               INT              NOT NULL, -- BOOL<br />
                                current_step          INT              NOT NULL,<br />
                                current_retry_attempt INT              NOT NULL,<br />
                                job_state             INT              NOT NULL)<br />
    -- start the job<br />
    declare @r as int<br />
    exec @r = msdb..sp_start_job @job_name<br />
    -- quit if unable to start<br />
    if @r<>0<br />
        RAISERROR (N'Could not start job: %s.', 16, 2, @job_name)<br />
    -- start with an initial delay to allow the job to appear in the job list (maybe I am missing something ?)<br />
    WAITFOR DELAY '0:0:10';<br />
    set @seccount = 10<br />
    -- check job run state<br />
    insert into @xp_results<br />
    execute master.dbo.xp_sqlagent_enum_jobs 1, @job_owner, @job_id<br />
    set @running= (SELECT top 1 running from @xp_results)<br />
    while @running<>0 and @seccount < @maxseccount<br />
    begin<br />
        WAITFOR DELAY '0:0:10';<br />
        set @seccount = @seccount + 10<br />
        delete from @xp_results<br />
        insert into @xp_results<br />
        execute master.dbo.xp_sqlagent_enum_jobs 1, @job_owner, @job_id<br />
        set @running= (SELECT top 1 running from @xp_results)<br />
    end<br />
	-- result: query<br />
	SELECT<br />
		[server],<br />
		[start_execution_date],<br />
		[stop_execution_date],<br />
		[run_date],<br />
		[run_duration],<br />
		[run_status],	-- 0: failed, 1: success, null: running<br />
		[message]<br />
	FROM<br />
		MSDB.DBO.SYSJOBS Z<br />
	INNER JOIN<br />
		MSDB.DBO.SYSJOBACTIVITY A<br />
		ON Z.JOB_ID = A.JOB_ID<br />
	INNER JOIN<br />
		(<br />
		SELECT<br />
			MAX(SESSION_ID) AS SESSION_ID<br />
		FROM<br />
			MSDB.DBO.SYSSESSIONS<br />
		) AS B<br />
		ON	A.SESSION_ID = B.SESSION_ID<br />
		LEFT JOIN<br />
		MSDB.DBO.SYSJOBHISTORY C<br />
		ON A.JOB_HISTORY_ID = C.INSTANCE_ID<br />
	WHERE Z.NAME = @job_name<br />
	-- result: not ok (=1) if still running<br />
    --if @running <> 0<br />
        --return 0<br />
    --else<br />
        --return 1<br />
    END TRY<br />
    BEGIN CATCH<br />
    DECLARE<br />
        @ErrorMessage    NVARCHAR(4000),<br />
        @ErrorNumber     INT,<br />
        @ErrorSeverity   INT,<br />
        @ErrorState      INT,<br />
        @ErrorLine       INT,<br />
        @ErrorProcedure  NVARCHAR(200);<br />
    SELECT<br />
        @ErrorNumber = ERROR_NUMBER(),<br />
        @ErrorSeverity = ERROR_SEVERITY(),<br />
        @ErrorState = ERROR_STATE(),<br />
        @ErrorLine = ERROR_LINE(),<br />
        @ErrorProcedure = ISNULL(ERROR_PROCEDURE(), '-');<br />
    SELECT @ErrorMessage =<br />
        N'Error %d, Level %d, State %d, Procedure %s, Line %d, ' +<br />
            'Message: '+ ERROR_MESSAGE();<br />
    RAISERROR<br />
        (<br />
        @ErrorMessage,<br />
        @ErrorSeverity,<br />
        1,<br />
        @ErrorNumber,    -- original error number.<br />
        @ErrorSeverity,  -- original error severity.<br />
        @ErrorState,     -- original error state.<br />
        @ErrorProcedure, -- original error procedure name.<br />
        @ErrorLine       -- original error line number.<br />
        );<br />
    END CATCH<br />
END<br />
</code>
</li>
</ul>
<p>[Source: <a href="http://blog.boxedbits.com/archives/124">http://blog.boxedbits.com/archives/124</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2009/09/ssis-execute-package-via-stored-procedure/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL Server: Security Check List</title>
		<link>http://sqlblog.de/blog/2009/08/sql-server-security-check-list/</link>
		<comments>http://sqlblog.de/blog/2009/08/sql-server-security-check-list/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 15:50:54 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[sicherheit]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/?p=635</guid>
		<description><![CDATA[In the following you find a compact catalog of steps which should be considered in a SQL Server environment. It...]]></description>
			<content:encoded><![CDATA[<p>In the following you find a compact catalog of steps which should be considered in a SQL Server environment.<br />
It is a conclusion of information from different sources.</p>
<p><strong>Check List</strong><br />
<em>Installation &#038; Patching</em></p>
<ul>
<li>Are only required components installed? Additional components should be installed when required.</li>
<li>As Service Account a Local or Domain Account should be rather used than a System Account.</li>
<li>A separate account for each service should be used.</li>
<li>Service accounts should use standard privileges (no special). The privileges are applied per Group Membership (SQL Server supplied group accounts).</li>
<li>Service Accounts should be applied with SQL Server Configuration Manager.</li>
<li>Always the most recent updates should be used.</li>
<li>Do not apply automatic updates. Rather test them before on a test environment.</li>
</ul>
<p><em>Configuration: Surface Area Reduction</em></p>
<ul>
<li>Surface Area Configuration Tool: only required features should be enabled.</li>
<li>Only Required Services should be set to Auto startup. Others should be set to Manual startup. Also consider to set some Services to Disabled startup.</li>
<li>If not needed supported Network protocols should be disabled in Configuration Manager.</li>
<li>If not needed, SQL Server should not be exposed to all networks (e.g. the Internet).</li>
<li>For some Configurations it is easier if named instances use fixed ports, rather than  dynamic ports.</li>
<li>Surface Area Configuration Tool: the xp_cmdshell should be disabled unless it is absolutely needed.</li>
<li>Surface Area Configuration Tool: COM components should be disabled once all COM components have been converted to SQLCLR.</li>
<li>Surface Area Configuration Tool: both mail procedures (database mail and SQL mail) should be disabled unless it required to send mails from SQL Server. Rather use database mail.</li>
<li>Surface Area Configuration Tool: standard policy should be enforced for extended procedure usage.</li>
<li>No system stored procedure should be removed by dropping it.</li>
<li>User or Administrator access should not be denied to the extended procedures by using DENY all.</li>
<li>Surface Area Configuration Tool: All exceptions to the above statements should be documented here.</li>
</ul>
<p><em>SQL Server Agent</em></p>
<ul>
<li>In order to apply special privileges to Jobs, Credentials should be used, instead of adjusting the privileges of SQL Server Agent service account.</li>
<li>In order to execute a Job with different Windows credentials, Proxy accounts should be used.</li>
</ul>
<p><em>Security: Authentication (general)</em></p>
<ul>
<li>Always Windows Authentication should be used. Mixed Authentication should be used only for Non-Windows accounts or incompatible applications.</li>
<li>The sa account should have a strong and known password.</li>
<li>If possible, the sa account should be renamed.</li>
<li>The SQL Server Management should not be done using the sa account. Rather use a known login and assign the sysadmin privilege to it.</li>
</ul>
<p><em>Security: Authentication (administrative access)</em></p>
<ul>
<li>Use administrative privileges only when needed to access SQL Server.</li>
<li>The number of administrators should be as low as possible.</li>
<li>Administrative logins should not be linked to the BuiltIn\Administrators group.</li>
</ul>
<p><em>Security: Authorisation</em></p>
<ul>
<li>Permissions on DB objects should be managed using Database roles or Windows groups.</li>
<li>Guest access should not be enabled.</li>
</ul>
<p><em>Security: Scanner Tools</em></p>
<ul>
<li>Use Microsoft Best Practices Analyser to identiy possible weak points in SQL Server 2005.</li>
<li>Use Microsoft Baseline Security Analyser to identify weak points in your operating System.</li>
</ul>
<p><em>Security: Password Policy</em></p>
<ul>
<li>Set up a strong password policy, including an expiration and a complexity policy. E.g. use the company password policy.</li>
<li>If using SQL logins, SQL Server should run on Windows Server 2003 OS. Also password policies should be mandatory.</li>
<li>Application should support the change procedure for SQL Login passwords.</li>
<li>New SQL Logins should have the property MUST_CHANGE_ON_FIRST_ACCESS on true.</li>
<li>Security on Database objects should be managed by using schemas.</li>
</ul>
<p><em>Database Properties</em></p>
<ul>
<li>Databases should have distinct owners. The sa user should not own all databases.</li>
<li>The number of owners per Database should be as low as possible.</li>
</ul>
<p><em>Schema Properties</em></p>
<ul>
<li>Similar SQL objects should be grouped into the same schema.</li>
<li>Schemas should not be owned only by dbo.</li>
<li>The number of schema owners should be minimized.</li>
</ul>
<p><em>Catalog Views</em></p>
<ul>
<li>Catalog views are secure by default, so no additional action is required to secure them.</li>
</ul>
<p><em>Remote Data Source Execution</em></p>
<ul>
<li>Instead of Remote server definitions rather Linked Servers should be used.</li>
<li>Ad hoc queries through Linked Servers should be disabled if not needed.</li>
</ul>
<p><em>Execution Context</em></p>
<ul>
<li>Rather use EXECUTE AS instead of SETUSER.</li>
<li>Rather use WITH NO REVERT/COOKIE instead of Application Roles.</li>
</ul>
<p><em>Data Encryption</em></p>
<ul>
<li>Information which is classified as secret (or confidential) should be encrypted.</li>
<li>Data encryption should be done with symmetric keys which are protected by using asymmetric keys or certificates.</li>
<li>Keys should be password-protected and the master key encryption should be removed for the most secure configuration.</li>
<li>The service master key, database master keys, and certificates should be backed-up by using the key-specific DDL statements.</li>
</ul>
<p><em>Auditing</em></p>
<ul>
<li>The amount of auditing data (detail level) should be project specific.</li>
<li>C2 auditing should be enabled only if explicitly needed.</li>
<li>DDL and specific server events should be audited by using trace events or event notifications.</li>
<li>DML must be audited by using trace events.</li>
<li>WMI should ber used to be alerted of emergency events.</li>
</ul>
<p><strong>Fazit</strong><br />
My recommendation is to use following Test Protocol in order to check the several steps.</p>
<p><strong>Download</strong>: <a href="http://sqlblog.de/blog/wp-content/uploads/2009/08/T_SQL_Server_Best_Practices.xls">SQL Server: Check List Best Practices</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2009/08/sql-server-security-check-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linked SQL Server: Encrypted Connection</title>
		<link>http://sqlblog.de/blog/2009/07/linked-sql-server-encrypted-connection/</link>
		<comments>http://sqlblog.de/blog/2009/07/linked-sql-server-encrypted-connection/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 08:59:50 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[sicherheit]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/?p=591</guid>
		<description><![CDATA[Linked SQL Server (applies to SQL Server 2005 / SQL Server 2008 / later) It can happen that an application...]]></description>
			<content:encoded><![CDATA[<p><strong>Linked SQL Server (applies to SQL Server 2005 / SQL Server 2008 / later)</strong><br />
It can happen that an application may need data stored in second database which is not located on the same instance of SQL Server. That instance could be on the same physical machine or it could be on another machine. There are many solutions to this scenario, but it depends on your requirements which solution you should choose. If there is no need to transport a huge amount of data between the two SQL Server instances then you should consider to register the second instance as Linked SQL Server into the first instance.</p>
<p>The advantage is that the Linked Server can provide seamlessly data access to the application. By the way, Linked Servers can be also used to register Non-SQL-Server instances.</p>
<p><strong>Basic Architecture Example</strong><br />
The following illustration shows a basic architecture sample. As you can see the Client is only accessing the Application Server and the Application Server is only accessing the first SQL Server.<br />
<div id="attachment_595" class="wp-caption aligncenter" style="width: 310px"><a href="http://sqlblog.de/blog/wp-content/uploads/2009/07/Server_Topologie.png"><img src="http://sqlblog.de/blog/wp-content/uploads/2009/07/Server_Topologie-300x56.png" alt="Linked SQL Server: Basic Architecture" title="Linked SQL Server: Basic Architecture" width="300" height="56" class="size-medium wp-image-595" /></a><p class="wp-caption-text">Linked SQL Server: Basic Architecture</p></div></p>
<p>This means the Application Server is submitting only one query to the first SQL Server instance and gets the result back only from the the same SQL Server instance. The data retrieval from the second SQL Server instance is processed by the first SQL Server instance.<br />
More detailed:  If the application running on the Application Server submits a query to the frist SQL Server instance that needs to retrieve data from a database hosted on the second SQL Server instance, then a so called <em>Distributed Query</em> is fired. An Example for such a query:</p>
<p><code><br />
SELECT SERVER2.[DB].[SCHEMA].[TABLE].[FIELD]<br />
FROM SERVER2.[DB]<br />
</code></p>
<p>In this sample the SERVER2 (= Linked Server Registration name on SERVER1) identifies that I am starting a distributed query.</p>
<p><strong>How to setup the Linked Server</strong><br />
You can register a Linked Server instance within Management Studio as the following illustration shows.<br />
<div id="attachment_601" class="wp-caption aligncenter" style="width: 304px"><img src="http://sqlblog.de/blog/wp-content/uploads/2009/07/Linked_Server_MMS.png" alt="Linked SQL Server: Management Studio" title="Linked SQL Server: Management Studio" width="294" height="274" class="size-full wp-image-601" /><p class="wp-caption-text">Linked SQL Server: Management Studio</p></div></p>
<p>For a greater flexibility I recommend to use the stored procedure.<br />
<code><br />
EXEC master.dbo.sp_addlinkedserver<br />
@server = N'REGISTRATION_NAME',<br />
@srvproduct=N'',<br />
@provider=N'SQLNCLI',<br />
@datasrc=N'SERVER\INSTANCE',<br />
@provstr=N'',<br />
@catalog = 'DATABASE_NAME'<br />
</code></p>
<p><strong>Linked Server Options: Server Options</strong><br />
Following Server options are available:</p>
<ul>
<li><strong>Collation Compatible</strong>: is used to identify whether or not the Linked Server has the same collation as the Local Server, should be set only the to true if you know for sure that both instances have the same collation. </li>
<li><strong>Data Access</strong>: is used allow data access on the linked server, should be true. This option can be used to disable a Linked Server temporally.</li>
<li><strong>RPC</strong>: is used to allow remote procedures calls <strong>from</strong> the Linked Server.</li>
<li><strong>RPC out</strong>: is used to allow remote procedures calls <strong>to</strong> the Linked Server (procedures which are defined on the second instance).</li>
<li><strong>Use Remote Collation</strong>: is used to specify that the collation setting from the remote instance is used.</li>
<li><strong>Collation Name</strong>: is to specify the collation setting of the Linked Server.</li>
<li><strong>Connection Timeout</strong>: is used to specify a time the Local Server waits to obtain a connection to the Linked Server (Zero used the remote instance setting).</li>
<li><strong>Query Timeout</strong>: is used to specify a time the Local Server waits to retrieve data from the Linked Server (Zero used the remote instance setting).</li>
</ul>
<p><strong>Linked Server Options: Security</strong></p>
<ul>
<li><strong>Login mapping</strong>: is a way to associate a login on the Local Server, with a login on the Remote Server. There are two options &#8211; Impersonate login and SQL login.</li>
<li><strong>Impersonate login</strong>: uses a local Windows login and uses it to connect to the Linked Server, by impersonating it. For this login delegation has to be enabled between the two Servers!</li>
<li><strong>SQL login</strong>: is used by associating a local login with a remote login and password. The remote login needs to be a SQL Server Authenticated user on the remote server.</li>
</ul>
<p>For logins which are not defined in the mapping you can specify the behavior for the connection to the linked server. There are four different options that are available by choosing the corresponding radio button. </p>
<ul>
<li><strong>Not be made</strong>: any users who are not added to the mapping list cannot connect to the Linked Server.</li>
<li><strong>Be made without using a security context</strong>: can be used for Data Sources which do not require any authentication. E.g. text files.</li>
<li><strong>Be made using Login’s current security context</strong>: the Windows account of the current login is used to connect to the Linked Server. The Local Server has to be able to impersonate the corresponding local account. This option is a simple way to specify that all Windows accounts are able to connect to the Linked Server, without mapping each login.</li>
<li><strong>Be made with this security context</strong>: specifies that all logins connecting to the Linked Server are using a single remote login and password (SQL Server Authenticated login).</li>
</ul>
<p><strong>Encryption of Connection stream</strong><br />
SQL Server is able to encrypt the connection between Client and Server. Since SQL Server 2005 you do not necessarily need to use SSL certificates. However, it makes sense to have certificates, because the Client can not check the identity of the Server. By the way, if you use a certificate which was generated from the Server itself then it will not be trustful.</p>
<p>The Login packets are always encrypted since SQL Server 2005, if the Client supports it. Encrypted communication between Client and Server is supported since MDAC 2.6 and third party Client tools should be ckecked. It is important to know that encryption takes additional CPU time and that encrypted data streams cannot be compressed anymore.</p>
<p>The encryption option can be activated in the Configuration Manager (SQL Server Network Cobnfiguration). Choosing the Properties dialog for an Instance you can set the option &#8220;Force Encryption&#8221; to true.<br />
With this option set to true the SQL Server instance only accepts encrypted connections. If you want to have both connection options (encrypted / non-encrypted) then you should not set this option to true.</p>
<p>If you do not choose a certificate (under certificate tab) then SQL Server 2005 (or later) generates a self-signed certificate. This means that the communication between Client and Server is encrypted and that spoofing of data is not possible anymore.</p>
<p><strong>Encryption of Linked Server Connection Stream</strong><br />
To enable the encryption of a Linked Server connection stream you should use the provider string option &#8220;Encrypted=YES&#8221;. The following stored procedure includes this option.</p>
<p><code><br />
EXEC master.dbo.sp_addlinkedserver<br />
@server = N'REGISTRATION_NAME',<br />
@srvproduct=N'',<br />
@provider=N'SQLNCLI',<br />
@datasrc=N'SERVER\INSTANCE',<br />
@provstr=N'<strong>Encrypt=yes;</strong>',<br />
@catalog = 'DATABASE_NAME'</code></p>
<p>The Linked SQL Server connection is now encrypted using a self-signed certificate or if available a Server certificate.</p>
<p><strong>How to check encrypted connection for SQL Server</strong><br />
I recommend the tool <a href="http://www.wireshark.org/">Wireshark</a> (former known as <a href="http://www.ethereal.com/">Ethereal</a>) to check the packages and look into the data. Just run this tool, capture a stream and fire a SELECT statement.</p>
<p><strong>Conclusion</strong><br />
Registering another SQL Server instance as Linked Server allows you to submit T-SQL statements on one SQL Server instance, which retrieves data from a second instance. Moreover it is possible to fire linked statements so that you can join data between several instances.</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2009/07/linked-sql-server-encrypted-connection/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SSIS: SQL Server Agent Job (run packages)</title>
		<link>http://sqlblog.de/blog/2009/07/ssis-sql-server-agent-job-run-packages/</link>
		<comments>http://sqlblog.de/blog/2009/07/ssis-sql-server-agent-job-run-packages/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 11:33:54 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[ssis]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/?p=579</guid>
		<description><![CDATA[If you experience following error &#8220;Executed as user: MyDomain\SQLServer. The package execution failed. The step failed.&#8221; then check that your...]]></description>
			<content:encoded><![CDATA[<p>If you experience following error <em>&#8220;Executed as user: MyDomain\SQLServer. The package execution failed. The step failed.&#8221;</em><br />
then check that your Service User for the SQL Server Agent has full file permissions to all packages, config files and log files!<br />
Moreover this service user should be member of the SQL Server DTS Group.</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2009/07/ssis-sql-server-agent-job-run-packages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSIS: Import localized Date columns under different regional settings</title>
		<link>http://sqlblog.de/blog/2009/07/ssis-import-localized-date-columns-under-different-regional-settings/</link>
		<comments>http://sqlblog.de/blog/2009/07/ssis-import-localized-date-columns-under-different-regional-settings/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 12:24:39 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ssis]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/?p=563</guid>
		<description><![CDATA[Importing Date values e.g. from Flat Files it can happen that the format of the date is different to the...]]></description>
			<content:encoded><![CDATA[<p>Importing Date values e.g. from Flat Files it can happen that the format of the date is different to the Host System date formatting of the regional settings. Especial the date setting for English (UK: day/month/year) and English (US: month/day/year) are often very problematic.</p>
<p>In SSIS a solution for this issue can be realized with a ScriptComponent as follows.</p>
<ol>
<li><strong>Date column</strong><br />
First of all you should import your Date column as nvarchar type. In this example let us assume we are going to import a Birthday column in Germany format on a host system with US-based regional setting.
	</li>
<li><strong>Script Component: Columns</strong><br />
We specify as import column the <em>BIRTHDAY_STR</em> column (nvarchar) from the Flat File and as export column we specify a column of type <em>date</em> named <em>BIRTHDAY_DATE</em>.
</li>
<li><strong>ScriptComponent: Code</strong><br />
In the Script we are using the <em>TryParse</em> method which is stable and flexible enough. But in order to import the German date we have to create a <em>culture</em> object.</p>
<p><code><br />
        Dim dt As DateTime<br />
        Dim culture As Globalization.CultureInfo<br />
        culture = Globalization.CultureInfo.CreateSpecificCulture("de-DE")<br />
        Try<br />
            If DateTime.TryParse(CStr(Row.BIRTHDAY_STR), culture, Globalization.DateTimeStyles.None, dt) Then<br />
                Row.BIRTHDAY_DATE = dt<br />
            Else<br />
                Row.BIRTHDAY_DATE_IsNull = True<br />
            End If<br />
        Catch ex As Exception<br />
            Row.BIRTHDAY_DATE_IsNull = True<br />
        End Try<br />
</code>
</li>
</ol>
<p>This example should help you to import the dates of different regional settings.</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2009/07/ssis-import-localized-date-columns-under-different-regional-settings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSIS: Split Excel cell values into rows</title>
		<link>http://sqlblog.de/blog/2009/04/ssis-split-excel-cell-values-into-rows/</link>
		<comments>http://sqlblog.de/blog/2009/04/ssis-split-excel-cell-values-into-rows/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 14:26:42 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[ssis]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/?p=474</guid>
		<description><![CDATA[Here I would like to show you a solution for following problem. One source row coming from Excel contains several...]]></description>
			<content:encoded><![CDATA[<p>Here I would like to show you a solution for following problem.<br />
One source row coming from Excel contains several values within one column. Each one of these values should be reflected in a separate row in the data destination.<br />
So the basic problem is that there we have a &#8220;list column&#8221; whose contents should be result in separate rows.</p>
<p>To make the problem more complex: The number of values in the &#8220;list column&#8221; is variable and there is a second column which contains corresponding values.</p>
<p><strong>Excel Source</strong><br />
<div id="attachment_481" class="wp-caption aligncenter" style="width: 280px"><a href="http://sqlblog.de/blog/wp-content/uploads/2009/04/excel_sheet.png"><img src="http://sqlblog.de/blog/wp-content/uploads/2009/04/excel_sheet.png" alt="Excel Sheet" title="Excel Sheet" width="270" height="165" class="size-full wp-image-481" /></a><p class="wp-caption-text">Excel Sheet</p></div></p>
<p><strong>solution: SSIS Script Component</strong></p>
<p>To implement a solution for the problem we use the most adequate item &#8211; the Script Component.</p>
<ol>
<li> We start with a data flow task in our package and add an <em>OLE DB Excel Source</em> component (that returns the source data above).<br />
We can use following SQL statement:<br />
<code><br />
SELECT<br />
F1,F2,F3<br />
FROM<br />
[sheet1$B1:D5]<br />
</code><br />
The imported columns can be named as <code>KEY</code>, <code>PERSON</code>, <code>DEPARTMENT</code>.<br />
<div id="attachment_507" class="wp-caption aligncenter" style="width: 233px"><a href="http://sqlblog.de/blog/wp-content/uploads/2009/04/excel_source.png"><img class="size-full wp-image-507" title="Excel Source" src="http://sqlblog.de/blog/wp-content/uploads/2009/04/excel_source.png" alt="Excel Source" width="223" height="300" /></a><p class="wp-caption-text">Excel Source</p></div>
	</li>
<li> Then we add a <em>Derived Column</em> Component to the data flow as well.<br />
<div id="attachment_505" class="wp-caption aligncenter" style="width: 160px"><a href="http://sqlblog.de/blog/wp-content/uploads/2009/04/derived_column.png"><img src="http://sqlblog.de/blog/wp-content/uploads/2009/04/derived_column.png" alt="Derived Column" title="Derived Column" width="150" height="131" class="size-full wp-image-505" /></a><p class="wp-caption-text">Derived Column</p></div></p>
<p>In order to replace the CRs with commas we replace the imported columns with following formula:<br />
<code><br />
REPLACE(REPLACE(REPLACE(REPLACE(PERSON,"\n",",")," ",""),",,",","),",,",",")<br />
REPLACE(REPLACE(REPLACE(REPLACE(DEPARTMENT,"\n",",")," ",""),",,",","),",,",",")<br />
</code><br />
<div id="attachment_506" class="wp-caption aligncenter" style="width: 310px"><a href="http://sqlblog.de/blog/wp-content/uploads/2009/04/derived_column_settings.png"><img src="http://sqlblog.de/blog/wp-content/uploads/2009/04/derived_column_settings-300x218.png" alt="Derived Column Settings" title="Derived Column Settings" width="300" height="218" class="size-medium wp-image-506" /></a><p class="wp-caption-text">Derived Column Settings</p></div>
	</li>
<li>
As result we receive following list of elements:</p>
<ul>
<li> &#8211; -</li>
<li><em>row 1</em></li>
<li>PERSON: Mr. Wayne,Mr. Kent,Mr. Parker</li>
<li>DEPARTMENT: Heros/Batman,Heros/Superman,Heros/Spiderman</li>
<li> &#8211; -</li>
<li><em>row 2</em></li>
<li>PERSON: Mr. Kirk,Ms. Janeway</li>
<li>DEPARTMENT: StarTrek/Classic,StartTrek/Voyager</li>
<li> &#8211; -</li>
<li><em>row 3</em></li>
<li>PERSON: &#8220;Mr. Wrong&#8221;</li>
<li>DEPARTMENT: Wrong entry 1,Wrong entry 2</li>
<li> &#8211; -</li>
</ul>
</li>
<li> Now we add a Script Component to the data flow.<br />
When we are prompted to select the type of the component we choose <em>Transformation</em>.</p>
<p><div id="attachment_508" class="wp-caption aligncenter" style="width: 168px"><a href="http://sqlblog.de/blog/wp-content/uploads/2009/04/script_component.png"><img src="http://sqlblog.de/blog/wp-content/uploads/2009/04/script_component.png" alt="Script Component" title="Script Component" width="158" height="232" class="size-full wp-image-508" /></a><p class="wp-caption-text">Script Component</p></div>
	</li>
<li> Then we right-click on the <em>Script Component</em> and choose Edit. In the Script Transformation Editor dialog box we select all three columns to make them available as input columns. Now these column are available in the Script code.<br />
<div id="attachment_516" class="wp-caption aligncenter" style="width: 310px"><a href="http://sqlblog.de/blog/wp-content/uploads/2009/04/script_component_columns.png"><img src="http://sqlblog.de/blog/wp-content/uploads/2009/04/script_component_columns-300x260.png" alt="Script Component Columns" title="Script Component Columns" width="300" height="260" class="size-medium wp-image-516" /></a><p class="wp-caption-text">Script Component Columns</p></div>
	</li>
<li> Since the tranformation is going to produce more output rows than it receives input rows we have to mark the transformation as asynchronous. This is done by setting the <em>SynchronousInputID</em> property of the output to <em>None</em>.<br />
<div id="attachment_511" class="wp-caption aligncenter" style="width: 310px"><a href="http://sqlblog.de/blog/wp-content/uploads/2009/04/script_component_settings.png"><img src="http://sqlblog.de/blog/wp-content/uploads/2009/04/script_component_settings-300x212.png" alt="Script Component Settings" title="Script Component Settings" width="300" height="212" class="size-medium wp-image-511" /></a><p class="wp-caption-text">Script Component Settings</p></div>
	</li>
<li> Next, we have to specify the output columns that the output buffer will contain. So we select the transformation&#8217;s output and click <em>Add Column</em> and set the properties (column name and data type).<br />
<div id="attachment_510" class="wp-caption aligncenter" style="width: 310px"><a href="http://sqlblog.de/blog/wp-content/uploads/2009/04/script_component_input.png"><img src="http://sqlblog.de/blog/wp-content/uploads/2009/04/script_component_input-300x256.png" alt="Script Component Input / Output rows" title="Script Component Input / Output rows" width="300" height="256" class="size-medium wp-image-510" /></a><p class="wp-caption-text">Script Component Input / Output rows</p></div>
	</li>
<li>
Now we can add the code by clicking on the <em>Design Script button</em>.<br />
<div id="attachment_509" class="wp-caption aligncenter" style="width: 295px"><a href="http://sqlblog.de/blog/wp-content/uploads/2009/04/script_component_design.png"><img src="http://sqlblog.de/blog/wp-content/uploads/2009/04/script_component_design.png" alt="Script Component - Design Script" title="Script Component - Design Script" width="285" height="183" class="size-full wp-image-509" /></a><p class="wp-caption-text">Script Component - Design Script</p></div>
	</li>
<li>
Following Code is splitting our list of items into rows:<br />
<code><br />
' Variables<br />
Dim i As Integer = 0<br />
Dim itemList_PERSON As String = Row.PERSON<br />
Dim itemList_DEPARTMENT As String = Row.DEPARTMENT<br />
Dim delimiter As String = ','<br />
If Not (String.IsNullOrEmpty(itemList_PERSON) Or String.IsNullOrEmpty(itemList_DEPARTMENT)) Then<br />
Dim inputListArray_Wer() As String = itemList_PERSON.Split(New String() {delimiter}, StringSplitOptions.RemoveEmptyEntries)<br />
Dim inputListArray_Abt() As String = itemList_DEPARTMENT.Split(New String() {delimiter}, StringSplitOptions.RemoveEmptyEntries)<br />
If (inputListArray_Wer.Length = inputListArray_Abt.Length) Then<br />
' new rows<br />
For Each item As String In inputListArray_Wer<br />
With Output0Buffer<br />
.AddRow()<br />
.KEY = CInt(Row.KEY)<br />
.PERSON = item<br />
.DEPARTMENT = inputListArray_Abt(i).ToString()<br />
End With<br />
' increase counter<br />
i = i + 1<br />
Next<br />
Else<br />
' Filtered Rows<br />
With Output1Buffer<br />
.AddRow()<br />
.KEY = CInt(Row.KEY)<br />
.PERSON = Row.PERSON<br />
.DEPARTMENT = Row.DEPARTMENT<br />
End With<br />
End If<br />
End If<br />
</code><br />
The code shows that there are two outputs. Whenever a record set cannot be split or the columns <em>PERSON</em> and <em>DEPARTMENT</em> have a different number of itemss the rows is redirected to the second output (here <em>Output1</em>).
	</li>
<li>
In order to receive the output from the Script Component we add a <em>Union All Component</em>. Additionally we add two <em>Data Viewer Components</em>, since  we want to see the resulting outputs from the Script Component.<br />
<div id="attachment_502" class="wp-caption aligncenter" style="width: 295px"><a href="http://sqlblog.de/blog/wp-content/uploads/2009/04/data_flow_union_all.png"><img src="http://sqlblog.de/blog/wp-content/uploads/2009/04/data_flow_union_all-285x300.png" alt="Union ALL" title="Union ALL" width="285" height="300" class="size-medium wp-image-502" /></a><p class="wp-caption-text">Union ALL</p></div>
	</li>
<li>
Running the SSIS package will bring the following result.<br />
<div id="attachment_501" class="wp-caption aligncenter" style="width: 290px"><a href="http://sqlblog.de/blog/wp-content/uploads/2009/04/data_flow_complete.png"><img src="http://sqlblog.de/blog/wp-content/uploads/2009/04/data_flow_complete-280x300.png" alt="Data Flow completed" title="Data Flow completed" width="280" height="300" class="size-medium wp-image-501" /></a><p class="wp-caption-text">Data Flow completed</p></div>
	</li>
<li>
As we can see, the first DataViewer Component show us the <em>valid</em> rows produced by our Script Component.<br />
<div id="attachment_504" class="wp-caption aligncenter" style="width: 310px"><a href="http://sqlblog.de/blog/wp-content/uploads/2009/04/data_viewer_valid.png"><img src="http://sqlblog.de/blog/wp-content/uploads/2009/04/data_viewer_valid-300x120.png" alt="Data Viewer valid rows" title="Data Viewer valid rows" width="300" height="120" class="size-medium wp-image-504" /></a><p class="wp-caption-text">Data Viewer valid rows</p></div>
	</li>
<li>
The second DataViewer Component show us the <em>invalid</em> rows produced by our Script Component.<br />
<div id="attachment_503" class="wp-caption aligncenter" style="width: 310px"><a href="http://sqlblog.de/blog/wp-content/uploads/2009/04/data_viewer_invalid.png"><img src="http://sqlblog.de/blog/wp-content/uploads/2009/04/data_viewer_invalid-300x35.png" alt="Data Viewer invalid rows" title="Data Viewer invalid rows" width="300" height="35" class="size-medium wp-image-503" /></a><p class="wp-caption-text">Data Viewer invalid rows</p></div>
	</li>
</ol>
<p><strong>download</strong><br />
Of course I provide you the solution as <a href='http://sqlblog.de/blog/wp-content/uploads/2009/04/excel_split_column.zip'>download</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2009/04/ssis-split-excel-cell-values-into-rows/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>T-SQL: Split column in several rows</title>
		<link>http://sqlblog.de/blog/2009/04/t-sql-split-column-in-several-rows/</link>
		<comments>http://sqlblog.de/blog/2009/04/t-sql-split-column-in-several-rows/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 14:10:39 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/?p=550</guid>
		<description><![CDATA[problem If I have a column with several values (separated by CR) which I need separated into rows then following...]]></description>
			<content:encoded><![CDATA[<p><strong>problem</strong><br />
If I have a column with several values (separated by CR) which I need separated into rows then following solution can help:</p>
<p><strong>possible solution: T-SQL</strong><br />
One possible solution using T-SQL is following statement.<br />
The function <code>fn_Split</code> returns all values in a list and the <code>replace</code> function converts the CR (carriage returns) to commas.</p>
<p><code><br />
SELECT<br />
[Key]<br />
,[b.Value]<br />
,[c.Value]<br />
FROM<br />
[dbo.TableExcel] AS a<br />
CROSS APPLY<br />
fn_Split(REPLACE(a.Persons, CHAR(10)+CHAR(13),','), ',') AS b<br />
CROSS APPLY<br />
fn_Split(REPLACE(a.Departments, CHAR(10)+CHAR(13),','), ',') AS c<br />
</code></p>
<p>The corresponding <code>fn_Split</code> function:<br />
<code><br />
CREATE FUNCTION [dbo].[fn_Split](@text nvarchar(max), @delimiter char(1) = ' ')<br />
RETURNS @Strings TABLE (<br />
position int IDENTITY PRIMARY KEY,<br />
value nvarchar(max)<br />
)<br />
AS<br />
BEGIN<br />
DECLARE @index int<br />
SET @index = -1<br />
WHILE (LEN(@text) &gt; 0)<br />
BEGIN<br />
SET @index = CHARINDEX(@delimiter , @text)<br />
IF (@index = 0) AND (LEN(@text) &gt; 0)<br />
BEGIN<br />
INSERT INTO @Strings VALUES (@text)<br />
BREAK<br />
END<br />
IF (@index &gt; 1)<br />
BEGIN<br />
INSERT INTO @Strings<br />
VALUES (LEFT(@text, @index - 1))<br />
SET @text = RIGHT(@text, (LEN(@text) - @index))<br />
END<br />
ELSE<br />
SET @text = RIGHT(@text, (LEN(@text) - @index))<br />
END<br />
RETURN<br />
END<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2009/04/t-sql-split-column-in-several-rows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSIS: Excel Import Column Data Types</title>
		<link>http://sqlblog.de/blog/2009/04/ssis-excel-import-column-data-types/</link>
		<comments>http://sqlblog.de/blog/2009/04/ssis-excel-import-column-data-types/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 08:39:59 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[ssis]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/?p=428</guid>
		<description><![CDATA[When Excel data is not coming into SSIS right, then do the following: use option &#8220;IMEX=1&#8221; in ConnectionString (Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\..\MyExcel.xls;Extended...]]></description>
			<content:encoded><![CDATA[<p>When Excel data is not coming into SSIS right, then do the following:</p>
<ol>
<li>use option &#8220;<code>IMEX=1</code>&#8221; in ConnectionString (<code>Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\..\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1"</code>)</li>
<li>modify registry setting &#8220;<code>TypeGuessRows=8</code>&#8221; to a much higher value</li>
<li>use a sql statement to retrieve data (e.g. &#8220;<code>SELECT * FROM [sheet1$A5:M2000]</code>&#8220;)</li>
</ol>
<p>NOTE: The setting <code>IMEX=1</code> tells the Excel driver to use <em>Import</em> mode. This mode reads the registry setting &#8220;<code>ImportMixedTypes=Text</code>&#8221; which forces mixed data to be converted to text. To achieve a more reliable column type recognition, the registry setting &#8220;<code>TypeGuessRows=8</code>&#8221; should be increased. By default the ISAM driver analyzes  the first eight rows and determines the column datatypes from this sampling. If the first analysed rows contain only numeric values, then setting <code>IMEX=1</code> will not convert this column datatype to Text &#8211; it will remain numeric.</p>
<p>ATTENTION: The IMEX setting has some other modes:</p>
<ul>
<li>0 is Export mode</li>
<li>1 is Import mode</li>
<li>2 is Linked mode (full update capabilities)</li>
</ul>
<p>Registry Setting Location:<br />
<code><br />
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\X.X\Engines\Excel<br />
</code></p>
<p><strong>supplement</strong><br />
If you experience following error the above described solution could fix it.<br />
1. An OLE DB error has occurred. Error code: 0x80040E21.<br />
2. Failed to retrieve long data for column &#8220;XYZ&#8221;.<br />
3. There was an error with output column &#8220;XYZ&#8221; (55488) on output &#8220;Excel Source Output&#8221; (109). The column status returned was: &#8220;DBSTATUS_UNAVAILABLE&#8221;.<br />
4. The &#8220;output column &#8220;XYZ&#8221;  (55488)&#8221; failed because error code 0xC0209071 occurred, and the error row disposition on &#8220;output column &#8220;XYZ&#8221; (55488)&#8221; specifies failure on error. An error occurred on the specified object of the specified component.<br />
5. [DTS.Pipeline] Error: The PrimeOutput method on component &#8220;Info Source&#8221; (101) returned error code 0xC0209029.  The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.<br />
6. [DTS.Pipeline] Error: Thread &#8220;SourceThread0&#8243; has exited with error code 0xC0047038. </p>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2009/04/ssis-excel-import-column-data-types/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQL Server: Version, Service Pack, Edition</title>
		<link>http://sqlblog.de/blog/2009/03/sql-server-version-service-pack/</link>
		<comments>http://sqlblog.de/blog/2009/03/sql-server-version-service-pack/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 08:59:06 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/?p=413</guid>
		<description><![CDATA[SQL Server: Version, Service Pack, Edition Just run following command within Management Studio: SELECT @@VERSION, SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')...]]></description>
			<content:encoded><![CDATA[<p><strong>SQL Server: Version, Service Pack, Edition</strong></p>
<p>Just run following command within Management Studio:<br />
<code>SELECT<br />
 @@VERSION,<br />
 SERVERPROPERTY('productversion'),<br />
 SERVERPROPERTY ('productlevel'),<br />
 SERVERPROPERTY ('edition')</code></p>
<p>As result you receive something like:</p>
<pre class="code">Microsoft SQL Server 2005 - ... Windows NT 5.2 (Build 3790: SP 2)
  9.00.4035.00
  SP3
  Standard Edition (64-bit)</pre>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2009/03/sql-server-version-service-pack/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SSRS: Disable Reporting Services Cache in Preview Mode</title>
		<link>http://sqlblog.de/blog/2008/12/ssrs-disable-reporting-services-cache-in-preview-mode/</link>
		<comments>http://sqlblog.de/blog/2008/12/ssrs-disable-reporting-services-cache-in-preview-mode/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 14:40:21 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ssrs]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/?p=382</guid>
		<description><![CDATA[How to disable caching in SQL Server Reporting Services for Visual Studio in Preview Mode? SQL Server 2005 Service Pack...]]></description>
			<content:encoded><![CDATA[<p>How to disable caching in SQL Server Reporting Services for Visual Studio in Preview Mode?</p>
<p>SQL Server 2005 Service Pack 1 brings a new feature: caching data in BIDS (Business Intelligence Development Studio) Report Designer. Following objects are cached: all the data query, parameter value and  credentials for previewing a report. Sometimes this feature can be annoying, if changes in preview mode should be visible immediately.</p>
<p>In order to disable the caching feature, following key has to be added to the config file &#8216;<code>RSReportDesigner.config</code>&#8216;.</p>
<p>Key:<br />
<code>&lt;Add Key="CacheDataForPreview" value="False" /&gt;</code></p>
<p>Location:<br />
<code>C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\RSReportDesigner.config</code><br />
To clear the cache you can also delete the *.data cache file which is located in the report RDL directory.</p>
<div id="attachment_383" class="wp-caption alignnone" style="width: 164px"><img class="size-full wp-image-383" title="ssrs_data_files" src="http://sqlblog.de/blog/wp-content/uploads/2008/12/ssrs_data_files.png" alt="SSRS: Caching Files (Preview Mode)" width="154" height="146" /><p class="wp-caption-text">SSRS: Caching Files (Preview Mode)</p></div>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2008/12/ssrs-disable-reporting-services-cache-in-preview-mode/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ReportViewer: Pass Parameters to Remote Report</title>
		<link>http://sqlblog.de/blog/2008/08/reportviewer-pass-parameters-to-remote-report/</link>
		<comments>http://sqlblog.de/blog/2008/08/reportviewer-pass-parameters-to-remote-report/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 07:13:30 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[ssrs]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/?p=367</guid>
		<description><![CDATA[How to pass parameters to ReportViewer Control displaying a remote report (SSRS): ReportParameter[] parameters = new ReportParameter[2]; protected void Page_Load(object...]]></description>
			<content:encoded><![CDATA[<p>How to pass parameters to ReportViewer Control displaying a remote report (SSRS):</p>
<p><code>ReportParameter[] parameters = new ReportParameter[2];</code></p>
<p><code>protected void Page_Load(object sender, EventArgs e) {<br />
    parameters[0] = new ReportParameter("wave_id", "28");<br />
    parameters[1] = new ReportParameter("mpc_id", "1530");<br />
    ReportViewer1.ServerReport.SetParameters(parameters);<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2008/08/reportviewer-pass-parameters-to-remote-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>T-SQL: Dynamic Pivot</title>
		<link>http://sqlblog.de/blog/2008/05/t-sql-dynamic-pivot/</link>
		<comments>http://sqlblog.de/blog/2008/05/t-sql-dynamic-pivot/#comments</comments>
		<pubDate>Thu, 08 May 2008 08:56:41 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/?p=255</guid>
		<description><![CDATA[Here is an example using dynamic Pivot: The Pivot columns (country short names) are dynamically generated from a query. Single...]]></description>
			<content:encoded><![CDATA[<p>Here is an example using dynamic Pivot:</p>
<p>The Pivot columns (country short names) are dynamically generated from a query.<br />
Single Quotations within Single Quotations can be realized by using 2 singe Quotations at once.</p>
<p>DECLARE @wave_id int<br />
SET @wave_id = 2</p>
<p>&#8211; Populate table variable with list of MPC_SHORT_NAMES<br />
SET NOCOUNT ON<br />
DECLARE @T AS TABLE(y nvarchar(10) NOT NULL PRIMARY KEY)<br />
INSERT INTO @T SELECT DISTINCT MPC_NAME_SHORT_EN_US FROM VL8C_DWH.VL8RS_DIM_MPCS WHERE WAVE_ID = @wave_id</p>
<p>&#8211; Construct the column list for the IN clause<br />
&#8211; e.g., [D],[E],[F]<br />
DECLARE @cols AS nvarchar(MAX), @y AS nvarchar(10)<br />
SET @y = (SELECT MIN(y) FROM @T)<br />
SET @cols = N&#8221;<br />
WHILE @y IS NOT NULL<br />
BEGIN<br />
SET @cols = @cols + N&#8217;,[' + @y + N']&#8216;<br />
SET @y = (SELECT MIN(y) FROM @T WHERE y &gt; @y)<br />
END<br />
SET @cols = SUBSTRING(@cols, 2, LEN(@cols))<br />
&#8211;SELECT @cols</p>
<p>&#8211; Construct the full T-SQL statement and execute it dynamically.<br />
DECLARE @sql AS nvarchar(MAX)<br />
SET @sql = N&#8217;<br />
SELECT<br />
*<br />
FROM<br />
(<br />
SELECT<br />
KEY_TYPES.KEY_TYPE_NAME,<br />
KEY_TYPES.KT_SORT_ORDER,<br />
DATA.MPC_NAME_SHORT_EN_US,<br />
DATA.K29*100 AS K29<br />
FROM<br />
(<br />
SELECT<br />
KC.KEY_TYPE_CLUSTER,<br />
KC.KT_NAME_EU AS KEY_TYPE_NAME,<br />
KC.KT_SORT_ORDER<br />
FROM<br />
VL8C_DWH.VL8RS_DIM_KEY_TYPE_CLUSTERS KC<br />
WHERE<br />
WAVE_ID = &#8216; + CAST(@wave_id AS nvarchar) + N&#8217;<br />
) KEY_TYPES</p>
<p>LEFT JOIN<br />
(<br />
SELECT<br />
M.MPC_NAME_SHORT_EN_US,<br />
KC.KEY_TYPE_CLUSTER,<br />
FM.K29_CNP_INDEX_TOTAL_BUSINESS AS K29<br />
FROM</p>
<p>VL8C_DWH.VL8RS_FACTS_MAIN FM</p>
<p>INNER JOIN<br />
VL8C_DWH.VL8RS_DIM_KEY_TYPES K<br />
ON	FM.KEY_TYPE_ID = K.KEY_TYPE_ID</p>
<p>INNER JOIN<br />
VL8C_DWH.VL8RS_DIM_KEY_TYPE_CLUSTERS KC<br />
ON	K.KEY_TYPE_CLUSTER_ID = KC.KEY_TYPE_CLUSTER_ID</p>
<p>INNER JOIN<br />
VL8C_DWH.VL8RS_DIM_WAVES W<br />
ON	FM.WAVE_ID = W.WAVE_ID</p>
<p>INNER JOIN<br />
VL8C_DWH.VL8RS_DIM_COMPETITORS C<br />
ON	FM.COMPETITOR_ID = C.COMPETITOR_ID</p>
<p>INNER JOIN<br />
VL8C_DWH.VL8RS_DIM_MPCS M<br />
ON	FM.MPC_ID = M.MPC_ID</p>
<p>WHERE<br />
W.WAVE_ID = &#8216; + CAST(@wave_id AS nvarchar) + N&#8217;<br />
AND	C.COMPETITOR_NAME = &#8221;MB&#8221; AND<br />
M.EUX_MEMBER = 1 AND<br />
(K.REPORT_RELEVANCY = &#8221;B&#8221; OR K.REPORT_RELEVANCY = &#8221;E&#8221;)<br />
) DATA<br />
ON	KEY_TYPES.KEY_TYPE_CLUSTER = DATA.KEY_TYPE_CLUSTER</p>
<p>WHERE<br />
DATA.K29 IS NOT NULL AND<br />
DATA.MPC_NAME_SHORT_EN_US &lt;&gt; &#8221;D&#8221;<br />
) p<br />
pivot<br />
(<br />
sum(K29)<br />
for MPC_NAME_SHORT_EN_US<br />
in (&#8216; + @cols + N&#8217;)<br />
) as p&#8217;<br />
PRINT @sql &#8212; for debugging<br />
EXEC sp_executesql @sql</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2008/05/t-sql-dynamic-pivot/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Uninstall Embedded SQL Server Instance</title>
		<link>http://sqlblog.de/blog/2008/03/uninstall-embedded-sql-server-instance/</link>
		<comments>http://sqlblog.de/blog/2008/03/uninstall-embedded-sql-server-instance/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 09:38:03 +0000</pubDate>
		<dc:creator>Ralf</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[2008]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://sqlblog.de/blog/index.php/2008/03/25/uninstall-embedded-sql-server-instance/</guid>
		<description><![CDATA[Folgender Tipp hilft, um die versteckte Instance Microsoft##SSEE von den WSS 3.0 zu entfernen: To uninstall SSEE: Start Registry Editor,...]]></description>
			<content:encoded><![CDATA[<p>Folgender Tipp hilft, um die versteckte Instance Microsoft##SSEE von den WSS 3.0 zu entfernen:</p>
<blockquote><p>To uninstall SSEE:<br />
Start Registry Editor, and then locate the following registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall</p>
<p>In the left pane, click each GUID.<br />
For each GUID that you click, look for a display name in the right pane that matches &#8220;Microsoft SQL 2005 Embedded Edition&#8221;.</p>
<p>When you see a display name that matches the name, copy the value of the Key named &#8220;UninstallString&#8221;<br />
Open a Command-Window (Start-&gt;run-&gt;cmd)<br />
Paste the Copied string.<br />
Append &#8220;CALLERID=OCSETUP.EXE&#8221; e.g. &#8220;MsiExec.exe /X {BDD79957-5801-4A2D-B09E-852E7FA64D01} CALLERID=OCSETUP.EXE&#8221;</p>
<p>There you go<br />
Don&#8217;t forget to reboot.<br />
Hope that helps<br />
Patrick</p></blockquote>
<p>[Source: http://www.sharepointblogs.com/]</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlblog.de/blog/2008/03/uninstall-embedded-sql-server-instance/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

