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

<channel>
	<title>Placko&#039;s SQL KB</title>
	<atom:link href="http://placko.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://placko.wordpress.com</link>
	<description>Microsoft SQL Server</description>
	<lastBuildDate>Sun, 15 Jan 2012 17:12:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='placko.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/ec366a22bed76e62efd95f13c598414d?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Placko&#039;s SQL KB</title>
		<link>http://placko.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://placko.wordpress.com/osd.xml" title="Placko&#039;s SQL KB" />
	<atom:link rel='hub' href='http://placko.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Creating an automated database backup by means of SQL Server Agent Job</title>
		<link>http://placko.wordpress.com/2012/01/15/creating-an-automated-database-backup-by-means-of-sql-server-agent-job/</link>
		<comments>http://placko.wordpress.com/2012/01/15/creating-an-automated-database-backup-by-means-of-sql-server-agent-job/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 17:05:47 +0000</pubDate>
		<dc:creator>placko</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[DBA]]></category>

		<guid isPermaLink="false">http://placko.wordpress.com/?p=975</guid>
		<description><![CDATA[Task: to create a fully automatic database backup system by means of SQL Server Agent Job with an e-mail fails notification subsystem EXEC [master].[dbo].[sp_addumpdevice] @devtype = N'disk', @logicalname = N'AdventureWorks2008R2', @physicalname = N'D:\SqlData\MSSQL\Backup\AdventureWorks2008R2.bak' GO Source code 1: SSMS -&#62; Object Explorer -&#62; [sql_server_instance] -&#62; Server Objects -&#62; Backup Devices -&#62; AdventureWorks2008R2 EXEC [master].[dbo].[sp_configure] 'show advanced [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=975&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div><strong>Task: </strong>to create a fully automatic database backup system by means of SQL Server Agent Job with an e-mail fails notification subsystem</div>
<p><em> </em><br />
<em> </em></p>
<pre>
<code>
EXEC [master].[dbo].[sp_addumpdevice]
     @devtype      = N'disk',
     @logicalname  = N'AdventureWorks2008R2',
     @physicalname = N'D:\SqlData\MSSQL\Backup\AdventureWorks2008R2.bak'
GO
</code>
</pre>
<div><em>Source code 1: </em>SSMS -&gt; Object Explorer -&gt; [sql_server_instance] -&gt; Server Objects -&gt; Backup Devices -&gt; AdventureWorks2008R2</div>
<p><em> </em><br />
<em> </em></p>
<pre>
<code>
EXEC [master].[dbo].[sp_configure] 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC [master].[dbo].[sp_configure] 'xp_cmdshell', 1
GO
RECONFIGURE
GO

USE [master]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Backup]
AS
BEGIN
    DECLARE @Out INT

    -- NOTE: make sure the database is in Full Recovery Model and is online!
    ALTER DATABASE [AdventureWorks2008R2]
    SET RECOVERY FULL
    ALTER DATABASE [AdventureWorks2008R2]
    SET ONLINE
    -- NOTE: functional for a FileStream database as well!

    DBCC CHECKDB([AdventureWorks2008R2])

    -- Create a database backup
    EXEC @Out = [master]..[xp_cmdshell]
                N'D:\SqlData\MSSQL\Backup\BACKUP_FILO_BEGIN.bat'

    CHECKPOINT

    BACKUP LOG [AdventureWorks2008R2]
               TO DISK='NUL' --WITH TRUNCATE_ONLY
    BACKUP DATABASE [AdventureWorks2008R2]
                    TO [AdventureWorks2008R2] WITH COMPRESSION --WITH INIT

    -- Copy the backup database to a tape
    EXEC @Out = [master]..[xp_cmdshell]
                N'D:\SqlData\MSSQL\Backup\BACKUP_FILO_END.bat'
END
GO
</code>
</pre>
<div><em>Source code 2: </em>SSMS -&gt; Object Explorer -&gt; [sql_server_instance] -&gt; Databases -&gt; System Databases -&gt; master -&gt; Programmability -&gt; Stored Procedures -&gt; dbo.Backup</div>
<p><em> </em><br />
<em> </em></p>
<pre>
<code>
REM ***Creating a Database Backup***

REM Path: "D:\SqlData\MSSQL\Backup\"
SET FILEPATH="D:\SqlData\MSSQL\Backup\"

SET FILENAME="AdventureWorks2008R2"

IF EXIST %FILEPATH%\%FILENAME%.BA4 DEL    %FILEPATH%\%FILENAME%.BA4
IF EXIST %FILEPATH%\%FILENAME%.BA3 RENAME %FILEPATH%\%FILENAME%.BA3 %FILENAME%.BA4
IF EXIST %FILEPATH%\%FILENAME%.BA2 RENAME %FILEPATH%\%FILENAME%.BA2 %FILENAME%.BA3
IF EXIST %FILEPATH%\%FILENAME%.BA1 RENAME %FILEPATH%\%FILENAME%.BA1 %FILENAME%.BA2
IF EXIST %FILEPATH%\%FILENAME%.BAK COPY   %FILEPATH%\%FILENAME%.BAK %FILEPATH%\%FILENAME%.BA1

SET FILENAME=
SET FILEPATH=
</code>
</pre>
<div><em>Source code 3: </em>Creating a database backup &#8211; BACKUP_FILO_BEGIN.bat</div>
<p><em> </em><br />
<em> </em></p>
<pre>
<code>
REM ***Copying the Database Backup to a Tape***

REM Path: "D:\SqlData\MSSQL\Backup\"
SET FILEPATHSRC="D:\SqlData\MSSQL\Backup\"

REM Path: "\\[server_name]\SQL_BAK$"
SET FILEPATHDST="\\[server_name]\SQL_BAK$"

SET FILENAME="AdventureWorks2008R2"

COPY %FILEPATHSRC%\%FILENAME%.BAK %FILEPATHDST%\%FILENAME%.BAK

SET FILENAME=
SET FILEPATHSRC=
SET FILEPATHDST=
</code>
</pre>
<div><em>Source code 4: </em>Copying the database backup to a tape &#8211; BACKUP_FILO_END.bat</div>
<p><em> </em><br />
<em> </em></p>
<pre>
<code>
USE [msdb]
GO

EXEC [msdb].[dbo].[sp_add_operator]
     @name                      = N'BACKUP',
     @enabled                   = 1,
     @weekday_pager_start_time  = 90000,
     @weekday_pager_end_time    = 180000,
     @saturday_pager_start_time = 90000,
     @saturday_pager_end_time   = 180000,
     @sunday_pager_start_time   = 90000,
     @sunday_pager_end_time     = 180000,
     @pager_days                = 0,
     @email_address             = N'test@example.eu',
     @category_name             = N'[Uncategorized]'
GO
</code>
</pre>
<div><em>Source code 5: </em>SSMS -&gt; Object Explorer -&gt; [sql_server_instance] -&gt; SQL Server Agent -&gt; Operators -&gt; BACKUP</div>
<p><em> </em><br />
<em> </em></p>
<pre>
<code>
USE [msdb]
GO

BEGIN TRANSACTION
    DECLARE @ReturnCode INT
    SELECT  @ReturnCode = 0

    IF NOT EXISTS
    (
        SELECT [name]
        FROM   [msdb].[dbo].[syscategories]
        WHERE  [name]           = N'Database Maintenance'
               AND
               [category_class] = 1 -- Job
    )
    BEGIN
        EXEC @ReturnCode = [msdb].[dbo].[sp_add_category]
                           @class = N'JOB',
                           @type  = N'LOCAL',
                           @name  = N'Database Maintenance'
        IF (@@ERROR != 0 OR @ReturnCode != 0)
        BEGIN
            GOTO QuitWithRollback
        END
    END

    DECLARE @jobId BINARY(16)
    EXEC @ReturnCode = [msdb].[dbo].[sp_add_job]
		       @job_name                   = N'BACKUP',
		       @enabled                    = 1,
		       @notify_level_eventlog      = 2,
		       @notify_level_email         = 2,
		       @notify_level_netsend       = 0,
		       @notify_level_page          = 0,
		       @delete_level               = 0,
		       @description                = N'Creating a database backup by means of SQL Server Agent Job',
		       @category_name              = N'Database Maintenance',
		       @owner_login_name           = N'NB0046\Marian Placko',
                       @notify_email_operator_name = N'BACKUP',
                       @job_id                     = @jobId OUTPUT
    IF (@@ERROR != 0 OR @ReturnCode != 0)
    BEGIN
        GOTO QuitWithRollback
    END
    EXEC @ReturnCode = [msdb].[dbo].[sp_add_jobstep]
		       @job_id               = @jobId,
		       @step_name            = N'BACKUP',
		       @step_id              = 1,
		       @cmdexec_success_code = 0,
		       @on_success_action    = 1,
		       @on_success_step_id   = 0,
		       @on_fail_action       = 2,
		       @on_fail_step_id      = 0,
		       @retry_attempts       = 0,
		       @retry_interval       = 0,
		       @os_run_priority      = 0,
		       @subsystem            = N'TSQL',
		       @command              = N'EXEC [dbo].[Backup]',
		       @database_name        = N'master',
		       @flags                = 0
    IF (@@ERROR != 0 OR @ReturnCode != 0)
    BEGIN
        GOTO QuitWithRollback
    END
    EXEC @ReturnCode = [msdb].[dbo].[sp_update_job]
                       @job_id        = @jobId,
                       @start_step_id = 1
    IF (@@ERROR != 0 OR @ReturnCode != 0)
    BEGIN
        GOTO QuitWithRollback
    END
    DECLARE @guid UNIQUEIDENTIFIER
    SET     @guid = NEWID()
    EXEC @ReturnCode = [msdb].[dbo].[sp_add_jobschedule]
		       @job_id                 = @jobId,
		       @name                   = N'BACKUP',
		       @enabled                = 1,
		       @freq_type              = 8,
		       @freq_interval          = 62,
		       @freq_subday_type       = 1,
		       @freq_subday_interval   = 0,
		       @freq_relative_interval = 0,
		       @freq_recurrence_factor = 1,
		       @active_start_date      = 20111230,
		       @active_end_date        = 99991231,
		       @active_start_time      = 200000,
		       @active_end_time        = 235959,
		       @schedule_uid           = @guid
    IF (@@ERROR != 0 OR @ReturnCode != 0)
    BEGIN
        GOTO QuitWithRollback
    END
    EXEC @ReturnCode = [msdb].[dbo].[sp_add_jobserver]
                       @job_id      = @jobId,
                       @server_name = N'(local)'
    IF (@@ERROR != 0 OR @ReturnCode != 0)
    BEGIN
        GOTO QuitWithRollback
    END
COMMIT TRANSACTION
    GOTO EndSave
QuitWithRollback:
    IF (@@TRANCOUNT &gt; 0)
    BEGIN
        ROLLBACK TRANSACTION
    END
EndSave:
GO
</code>
</pre>
<div><em>Source code 6: </em>SSMS -&gt; Object Explorer -&gt; [sql_server_instance] -&gt; SQL Server Agent -&gt; Jobs -&gt; BACKUP</div>
<p><em> </em><br />
<em> </em></p>
<pre>
<code>
-- Enable a Database Mail
[master].[dbo].[sp_configure] 'show advanced options', 1
GO
RECONFIGURE
GO
[master].[dbo].[sp_configure] 'Database Mail XPs', 1
GO
RECONFIGURE
GO

-- Set up an Account
 -- Port number: 25
 -- SMPT authentication: anonymous
EXECUTE [msdb].[dbo].[sysmail_add_account_sp]
        @account_name    = 'BACKUP',
        @description     = 'Creating a database backup by means of SQL Server Agent Job',
        @email_address   = 'test@example.eu',
        @display_name    = 'BACKUP',
        @replyto_address = 'test@example.eu',
        @mailserver_name = 'localhost' -- NOTE: SMTP server must be set up!
GO

-- Set up a Profile
EXECUTE [msdb].[dbo].[sysmail_add_profile_sp]
        @profile_name = 'BACKUP',
        @description  = 'Creating a database backup by means of SQL Server Agent Job'
GO

-- Associate the Profile with the Account
EXECUTE [msdb].[dbo].[sysmail_add_profileaccount_sp]
        @profile_name    = 'BACKUP',
        @account_name    = 'BACKUP',
        @sequence_number = 1
GO

-- Add NB0046\Marian Placko to the Database Mail Role
EXEC [msdb].[dbo].[sp_addrolemember]
     @rolename   = 'DatabaseMailUserRole',
     @membername = 'NB0046\Marian Placko'
GO

-- Grant access to the Profile to NB0046\Marian Placko
EXEC [msdb].[dbo].[sysmail_add_principalprofile_sp]
     @profile_name   = 'BACKUP',
     @principal_name = 'NB0046\Marian Placko',
     @is_default     = 0
GO

-- Send a test e-mail
EXEC [msdb].[dbo].[sp_send_dbmail]
     @profile_name='BACKUP',
     @recipients='test@example.eu',
     @subject='Test message',
     @body='This is the body of the test message.'
</code>
</pre>
<div><em>Source code 7: </em>SSMS -&gt; Object Explorer -&gt; [sql_server_instance] -&gt; Management -&gt; Database Mail -&gt; BACKUP</div>
<p><em> </em><br />
<em> </em></p>
<pre>
<code>
-- Enable SQL Server Agent to use the Database Mail
 -- NOTE: make sure to start SQL Server Agent!
 EXEC master.dbo.xp_ServiceControl 'QUERYSTATE','SQLServerAgent'
 -- Current Service State: Running.
 --EXEC master.dbo.xp_ServiceControl 'START', 'SQLServerAgent'
 GO

EXEC [msdb].[dbo].[sp_set_sqlagent_properties]
     @email_save_in_sent_folder = 1

EXEC [master].[dbo].[xp_instance_regwrite]
     N'HKEY_LOCAL_MACHINE',
     N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent',
     N'UseDatabaseMail',
     N'REG_DWORD',
     1

EXEC [master].[dbo].[xp_instance_regwrite]
     N'HKEY_LOCAL_MACHINE',
     N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent',
     N'DatabaseMailProfile',
     N'REG_SZ',
     N'BACKUP'
GO

-- Enable SQL Server Agent to set Fail-safe Operator
EXEC [master].[dbo].[sp_MSsetalertinfo]
     @failsafeoperator   = N'BACKUP',
     @notificationmethod = 1 -- E-mail
GO
 -- NOTE: make sure to restart SQL Server Agent!
 EXEC master.dbo.xp_ServiceControl 'STOP', 'SQLServerAgent'
 GO
 -- Message: Service Stopped.
 EXEC master.dbo.xp_ServiceControl 'START', 'SQLServerAgent'
 GO
 -- Message: Service Started.
</code>
</pre>
<div><em>Source code 8: </em>SSMS -&gt; Object Explorer -&gt; [sql_server_instance] -&gt; SQL Server Agent -&gt; Properties -&gt; Alert System</div>
<p><em> </em><br />
<em> </em></p>
<div>Additional references:</div>
<ul>
<li><a href="http://sqlserverpedia.com/blog/sql-server-management/backup-log-with-truncate_only/" target="_blank">Backup Log with Truncate_Only</a><br />
by Brent Ozar</li>
<li><a href="http://www.sqlservercentral.com/scripts/Backup+%2f+Restore/62095/" target="_blank">Comprehensive Backup Script</a><br />
by Simon Facer</li>
<li><a href="http://www.ideaexcursion.com/2009/01/05/configuring-sql-server-agent-operators/" target="_blank">Configuring SQL Server Agent Operators</a><br />
by Taylor Gerring</li>
<li><a href="http://www.sqlservercentral.com/blogs/scarydba/2012/01/11/database-backups-things-you-need-to-do-now/" target="_blank">Database Backups: Things You Need To Do Now</a><br />
by The Scary DBA</li>
<li><a href="http://blogs.technet.com/b/technetczsk/archive/2011/11/01/princip-prace-sql-server-recovery-models.aspx" target="_blank">Princip práce SQL Server Recovery Models</a><br />
by Marek Chmel</li>
<li><a href="http://www.red-gate.com/products/dba/backup-restore-bundle/" target="_blank">SQL Backup and Restore Bundle</a><br />
by redgate</li>
<li><a href="http://www.idera.com/SQL-Server/SQL-safe-backup/" target="_blank">SQL safe backup</a><br />
by idera</li>
<li><a href="http://blog.sqlauthority.com/2007/09/09/sql-server-2005-start-stop-restart-sql-server-from-command-prompt/" target="_blank">SQL SERVER – 2005 – Start Stop Restart SQL Server From Command Prompt</a><br />
by Pinal Dave</li>
<li><a href="http://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/" target="_blank">SQL SERVER – 2008 – Configure Database Mail – Send Email From SQL Database</a><br />
by Pinal Dave</li>
<li><a href="http://blog.sqlauthority.com/2008/07/03/sql-server-2008-introduction-to-new-feature-of-backup-compression/" target="_blank">SQL SERVER – 2008 – Introduction to New Feature of Backup Compression</a><br />
by Pinal Dave</li>
<li><a href="http://blog.sqlauthority.com/2011/12/23/sql-server-a-quick-script-for-point-in-time-recovery-back-up-and-restore/" target="_blank">SQL SERVER – A Quick Script for Point in Time Recovery – Back Up and Restore</a><br />
by Pinal Dave</li>
<li><a href="http://blog.sqlauthority.com/2009/07/14/sql-server-backup-timeline-and-understanding-of-database-restore-process-in-full-recovery-model/" target="_blank">SQL SERVER – Backup Timeline and Understanding of Database Restore Process in Full Recovery Model</a><br />
by Pinal Dave</li>
<li><a href="http://blog.sqlauthority.com/2011/12/28/sql-server-effect-of-compressed-backup-setting-at-server-level-on-database-backup/" target="_blank">SQL SERVER – Effect of Compressed Backup Setting at Server Level on Database Backup</a><br />
by Pinal Dave</li>
<li><a href="http://blog.sqlauthority.com/2010/04/06/sql-server-retrieve-and-explore-database-backup-without-restoring-database-idera-virtual-database/" target="_blank">SQL SERVER – Retrieve and Explore Database Backup without Restoring Database – Idera virtual database</a><br />
by Pinal Dave</li>
<li><a href="http://blog.sqlauthority.com/2006/12/30/sql-server-shrinking-truncate-log-file-log-full/" target="_blank">SQL SERVER – Shrinking Truncate Log File – Log Full</a><br />
by Pinal Dave</li>
<li><a href="http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/54e6e281-005a-4b07-8c85-3685441f4f3d" target="_blank">truncate_only&#8217; is not a recognized BACKUP option</a><br />
by MSDN</li>
<li><a href="http://www.idevelopment.info/data/SQLServer/DBA_tips/Database_Administration/DBA_20.shtml" target="_blank">Using Database Mail in SQL Server 2008</a><br />
by Jeff Hunter</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/placko.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/placko.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/placko.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/placko.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/placko.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/placko.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/placko.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/placko.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/placko.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/placko.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/placko.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/placko.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/placko.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/placko.wordpress.com/975/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=975&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://placko.wordpress.com/2012/01/15/creating-an-automated-database-backup-by-means-of-sql-server-agent-job/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>48.312872 18.086038</georss:point>
		<geo:lat>48.312872</geo:lat>
		<geo:long>18.086038</geo:long>
		<media:content url="http://1.gravatar.com/avatar/1c0bc5b54e549b05a3ee622a9d8f6aac?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">placko</media:title>
		</media:content>
	</item>
		<item>
		<title>A simple hack of a built-in MS SQL Server WITH ENCRYPTION mechanism</title>
		<link>http://placko.wordpress.com/2012/01/09/a-simple-hack-of-a-built-in-ms-sql-server-with-encryption-mechanism/</link>
		<comments>http://placko.wordpress.com/2012/01/09/a-simple-hack-of-a-built-in-ms-sql-server-with-encryption-mechanism/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 20:56:22 +0000</pubDate>
		<dc:creator>placko</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://placko.wordpress.com/?p=1144</guid>
		<description><![CDATA[The SQL professionals know that the built-in MS SQL Server encryption mechanism by means of WITH ENCRYPTION T-SQL keyword is ineffective and easily broken. For much more details see also Google’s results e.g.: search phrase: sql decryptor (approximate number of results: 405 000) search phrase: sql server syscomments decryptor (approximate number of results: 2 850) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=1144&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-indent:20px;">
The SQL professionals know that the built-in MS SQL Server encryption mechanism by means of WITH ENCRYPTION T-SQL keyword is ineffective and easily broken. For much more details see also Google’s results e.g.:
</p>
<ul style="margin-top:-20px;">
<li>
search phrase: <a href="http://www.google.sk/#hl=sk&amp;cp=9&amp;gs_id=3z&amp;xhr=t&amp;q=sql+decryptor&amp;pq=sqldecryptor&amp;pf=p&amp;sclient=psy-ab&amp;source=hp&amp;pbx=1&amp;oq=sql+decry&amp;aq=0&amp;aqi=g4&amp;aql=&amp;gs_sm=&amp;gs_upl=&amp;bav=on.2,or.r_gc.r_pw.,cf.osb&amp;fp=4f97f312bc548c4&amp;biw=1303&amp;bih=659" target="_blank">sql decryptor</a> (approximate number of results: 405 000)
</li>
<li style="margin-top:-10px;">
search phrase: <a href="http://www.google.sk/#sclient=psy-ab&amp;hl=sk&amp;source=hp&amp;q=sql+server+syscomments+decryptor&amp;pbx=1&amp;oq=sql+server+syscomments+decryptor&amp;aq=f&amp;aqi=&amp;aql=&amp;gs_sm=e&amp;gs_upl=73778l95440l3l95861l36l29l7l0l0l0l1743l5595l0.14.8.8-1l36l0&amp;bav=on.2,or.r_gc.r_pw.,cf.osb&amp;fp=4f97f312bc548c4&amp;biw=1303&amp;bih=659" target="_blank">sql server syscomments decryptor</a> (approximate number of results: 2 850)
</li>
</ul>
<p><em> </em></p>
<p style="text-indent:20px;">
<b>{3S} SQL Smart Security</b> is an add-in which can be installed in Microsoft SQL Server Management Studio (SSMS) 2005, 2008, 2008 R2 and their respective Express versions. It enables software companies to create a secured content for database objects (note: currently, in 1.0 version can be secured only the content of stored procedures, but in the future, there are considered user defined functions, triggers and views as well). It brings much higher level of protection in comparison with SQL Server built in WITH ENCRYPTION mechanism for software companies that want to protect their heavily acquired know-how by creation of application logic on the database server side on a daily basis.
</p>
<p style="text-indent:20px;margin-top:-20px;">
None of the currently available SQL decryptors are capable of cracking <b>{3S} SQL Smart Security</b>. Most importantly, all encrypted database objects remain executable! Moreover, installing <b>{3S} SQL Smart Security</b> does not affect any settings and does not replace default encryption options entirely. The developers (end-users) always have an option to choose which encryption settings to use.
</p>
<p><em> </em></p>
<p style="text-indent:20px;">
See a short story of a simple hack by means of built-in MS SQL Server WITH ENCRYPTION mechanism on the example bellow.
</p>
<p><em> </em></p>
<p style="margin-left:20px;margin-top:30px;margin-bottom:40px;">
<u>WARNING:</u> In the following examples, an excellent free tool called dbForge SQL Decryptor by the Devart (formerly known as Core Lab) software development company (<a href="http://www.devart.com/" target="_blank" style="color:#cc0000;">http://www.devart.com/</a>) will be used for educational purposes, only for decrypting the stored procedure.
</p>
<p><div id="attachment_390" class="wp-caption aligncenter" style="width: 610px"><img class="size-full wp-image-390" src="http://placko.files.wordpress.com/2012/01/3s_with-encryption-hack-040_3s-sql-smart_appendix_example_step005.jpg?w=614" alt="built-in WITH ENCRYPTION hack – stored procedure encryption by means of built-in MS SQL Server WITH ENCRYPTION mechanism"   /><p class="wp-caption-text">Figure 1: built-in WITH ENCRYPTION hack – stored procedure encryption by means of built-in MS SQL Server WITH ENCRYPTION mechanism</p></div><br />
<div id="attachment_390" class="wp-caption aligncenter" style="width: 389px"><img class="size-full wp-image-390" src="http://placko.files.wordpress.com/2012/01/3s_with-encryption-hack-040_3s-sql-smart_appendix_example_step010.png?w=614" alt="built-in WITH ENCRYPTION hack – lock on encrypted stored procedure by means of built-in MS SQL Server WITH ENCRYPTION mechanism"   /><p class="wp-caption-text">Figure 2: built-in WITH ENCRYPTION hack – lock on encrypted stored procedure by means of built-in MS SQL Server WITH ENCRYPTION mechanism</p></div><br />
<div id="attachment_390" class="wp-caption aligncenter" style="width: 610px"><img class="size-full wp-image-390" src="http://placko.files.wordpress.com/2012/01/3s_with-encryption-hack-040_3s-sql-smart_appendix_example_step015.jpg?w=614" alt="built-in WITH ENCRYPTION hack – stored procedure decrypting by means of dbForge SQL Decryptor"   /><p class="wp-caption-text">Figure 3: built-in WITH ENCRYPTION hack – stored procedure decrypting by means of dbForge SQL Decryptor</p></div><br />
<div id="attachment_390" class="wp-caption aligncenter" style="width: 610px"><img class="size-full wp-image-390" src="http://placko.files.wordpress.com/2012/01/3s_with-encryption-hack-040_3s-sql-smart_appendix_example_step020.jpg?w=614" alt="built-in WITH ENCRYPTION hack – decrypted stored procedure by means of dbForge SQL Decryptor"   /><p class="wp-caption-text">Figure 4: built-in WITH ENCRYPTION hack – decrypted stored procedure by means of dbForge SQL Decryptor</p></div></p>
<p style="text-indent:20px;">
By applying dbForge SQL Decryptor to the encrypted stored procedure by means of built-in MS SQL Server WITH ENCRYPTION mechanism it is possible to see that the stored procedure body IS A PLAIN SOURCE CODE TEXT!!!
</p>
<p><div id="attachment_390" class="wp-caption aligncenter" style="width: 610px"><img class="size-full wp-image-390" src="http://placko.files.wordpress.com/2012/01/3s_with-encryption-hack-040_3s-sql-smart_appendix_example_step025.jpg?w=614" alt="built-in WITH ENCRYPTION hack – encrypted stored procedure by means of {3S} SQL Smart Security"   /><p class="wp-caption-text">Figure 5: built-in WITH ENCRYPTION hack – encrypted stored procedure by means of {3S} SQL Smart Security</p></div><br />
<div id="attachment_390" class="wp-caption aligncenter" style="width: 610px"><img class="size-full wp-image-390" src="http://placko.files.wordpress.com/2012/01/3s_with-encryption-hack-040_3s-sql-smart_appendix_example_step030.jpg?w=614" alt="built-in WITH ENCRYPTION hack – decrypted {3S} SQL Smart Security stored procedure by means of dbForge SQL Decryptor"   /><p class="wp-caption-text">Figure 6: built-in WITH ENCRYPTION hack – decrypted {3S} SQL Smart Security stored procedure by means of dbForge SQL Decryptor</p></div></p>
<p style="text-indent:20px;">
By applying dbForge SQL Decryptor to the encrypted stored procedure by means of <b>{3S} SQL Smart Security</b> it is possible to see that the stored procedure body IS NOT A PLAIN SOURCE CODE TEXT but includes the <b>{3S} SQL Smart Security</b> metadata only!!!
</p>
<p><em> </em></p>
<div style="margin-top:40px;">Additional references:</div>
<ul>
<li><a href="http://www.3sdownload.placko.eu/%7B3S%7D%20SQL%20Smart%20Security%20-%20Step%20by%20Step%20MANUAL.pdf" target="_blank">{3S} SQL Smart Security: Step by Step Manual&#8221;</a><br />
by Marian Placko</li>
</ul>
<p><a href="http://www.3s.placko.eu/" target="_blank"><br />
<img src="http://placko.files.wordpress.com/2012/01/logowithslogan.png?w=372&#038;h=68" alt="{3S} SQL Smart Security ''Protect your T-SQL know-how!''" width="372" height="68" style="margin-top:-20px;" /><br />
</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/placko.wordpress.com/1144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/placko.wordpress.com/1144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/placko.wordpress.com/1144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/placko.wordpress.com/1144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/placko.wordpress.com/1144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/placko.wordpress.com/1144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/placko.wordpress.com/1144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/placko.wordpress.com/1144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/placko.wordpress.com/1144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/placko.wordpress.com/1144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/placko.wordpress.com/1144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/placko.wordpress.com/1144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/placko.wordpress.com/1144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/placko.wordpress.com/1144/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=1144&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://placko.wordpress.com/2012/01/09/a-simple-hack-of-a-built-in-ms-sql-server-with-encryption-mechanism/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>48.312872 18.086038</georss:point>
		<geo:lat>48.312872</geo:lat>
		<geo:long>18.086038</geo:long>
		<media:content url="http://1.gravatar.com/avatar/1c0bc5b54e549b05a3ee622a9d8f6aac?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">placko</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2012/01/3s_with-encryption-hack-040_3s-sql-smart_appendix_example_step005.jpg" medium="image">
			<media:title type="html">built-in WITH ENCRYPTION hack – stored procedure encryption by means of built-in MS SQL Server WITH ENCRYPTION mechanism</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2012/01/3s_with-encryption-hack-040_3s-sql-smart_appendix_example_step010.png" medium="image">
			<media:title type="html">built-in WITH ENCRYPTION hack – lock on encrypted stored procedure by means of built-in MS SQL Server WITH ENCRYPTION mechanism</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2012/01/3s_with-encryption-hack-040_3s-sql-smart_appendix_example_step015.jpg" medium="image">
			<media:title type="html">built-in WITH ENCRYPTION hack – stored procedure decrypting by means of dbForge SQL Decryptor</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2012/01/3s_with-encryption-hack-040_3s-sql-smart_appendix_example_step020.jpg" medium="image">
			<media:title type="html">built-in WITH ENCRYPTION hack – decrypted stored procedure by means of dbForge SQL Decryptor</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2012/01/3s_with-encryption-hack-040_3s-sql-smart_appendix_example_step025.jpg" medium="image">
			<media:title type="html">built-in WITH ENCRYPTION hack – encrypted stored procedure by means of {3S} SQL Smart Security</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2012/01/3s_with-encryption-hack-040_3s-sql-smart_appendix_example_step030.jpg" medium="image">
			<media:title type="html">built-in WITH ENCRYPTION hack – decrypted {3S} SQL Smart Security stored procedure by means of dbForge SQL Decryptor</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2012/01/logowithslogan.png" medium="image">
			<media:title type="html">{3S} SQL Smart Security &#039;&#039;Protect your T-SQL know-how!&#039;&#039;</media:title>
		</media:content>
	</item>
		<item>
		<title>CSV &#8211; row values concatenation (FOR XML PATH) and exporting column values to a MS Excel file (Microsoft.Jet.OLEDB)</title>
		<link>http://placko.wordpress.com/2011/11/20/csv-row-values-concatenation-for-xml-path-and-exporting-column-values-to-a-ms-excel-file-microsoft-jet-oledb/</link>
		<comments>http://placko.wordpress.com/2011/11/20/csv-row-values-concatenation-for-xml-path-and-exporting-column-values-to-a-ms-excel-file-microsoft-jet-oledb/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 15:58:50 +0000</pubDate>
		<dc:creator>placko</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">http://placko.wordpress.com/?p=785</guid>
		<description><![CDATA[Task: to create row values concatenation, i.e. CSV (Comma Separated Values), by means of the FOR XML PATH construction, and to export database table column values to the MS Excel file using the Microsoft.Jet.OLEDB ad hoc method of connecting and accessing remote data by using OLE DB Solution: see Source code 1 &#8211; 4 EXEC [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=785&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div><strong>Task: </strong>to create row values concatenation, i.e. CSV (Comma Separated Values), by means of the FOR XML PATH construction, and to export database table column values to the MS Excel file using the Microsoft.Jet.OLEDB ad hoc method of connecting and accessing remote data by using OLE DB<br />
<strong>Solution: </strong>see Source code 1 &#8211; 4</div>
<p><em> </em><br />
<em> </em></p>
<pre>
<code>
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
EXEC sp_configure 'ad hoc distributed queries', 1;
GO
RECONFIGURE;
GO
</code>
</pre>
<div><em>Source code 1: </em>system configuration</div>
<p><em> </em><br />
<em> </em></p>
<pre>
<code>
USE [AdventureWorks]
GO

DECLARE @InputData        AS TABLE
(
        [ManagerCounter]  INT,
        [ManagerLoginID]  NVARCHAR(256),
        [EmployeeLoginID] NVARCHAR(256)
)
;WITH [Employees]
(
      [ManagerCounter],
      [ManagerID],
      [LoginID]
)
AS
(
    SELECT ROW_NUMBER() OVER(PARTITION BY [ManagerID] ORDER BY [ManagerID]),
           [ManagerID],
           [LoginID]
    FROM   [HumanResources].[Employee]
)
INSERT INTO @InputData
(
            [ManagerCounter],
            [ManagerLoginID],
            [EmployeeLoginID]
)
SELECT   [ManagerCounter],
         [Managers].[LoginID],
         [Employees].[LoginID]
FROM     [HumanResources].[Employee] AS [Managers] INNER JOIN [Employees] ON
         [Managers].[EmployeeID] = [Employees].[ManagerID]
ORDER BY [Managers].[LoginID]

/* temporary test */
SELECT    [ManagerCounter]  AS 'ManagersCounter',
          [ManagerLoginID]  AS 'Managers',
          [EmployeeLoginID] AS 'Employees'
FROM      @InputData
ORDER BY  [ManagerLoginID]
</code>
</pre>
<div><em>Source code 2: </em>input data preparation (ManagersCounter &#8211; number of employees per manager)</div>
<p><em> </em><br />
<div id="attachment_390" class="wp-caption aligncenter" style="width: 429px"><img class="size-full wp-image-390" title="MS SSMS result of input data preparation (ManagersCounter - number of employees per manager)" src="http://placko.files.wordpress.com/2011/11/ms-ssms-result-of-input-data-preparation.png?w=614" alt="MS SSMS result of input data preparation (ManagersCounter - number of employees per manager)"   /><p class="wp-caption-text">Figure 1: MS SSMS result of input data preparation (ManagersCounter - number of employees per manager)</p></div><br />
<em> </em></p>
<pre>
<code>
SELECT       [Managers].[ManagerLoginID] AS 'Manager',
(
    SELECT
        CASE
	     WHEN [Employees].[ManagerCounter] = 1
                  THEN [Employees].[EmployeeLoginID]
	     ELSE ',' + [Employees].[EmployeeLoginID]
	END
    FROM     @InputData AS [Employees]
    WHERE    [Employees].[ManagerLoginID] = [Managers].[ManagerLoginID]
    ORDER BY [Employees].[ManagerLoginID]
    FOR XML  PATH('')
)            AS 'Employees'
FROM         @InputData AS [Managers]
GROUP BY     [Managers].[ManagerLoginID]
</code>
</pre>
<div><em>Source code 3: </em>row values concatenation (converting to the CSV format) by means of FOR XML PATH</div>
<p><em> </em><br />
<div id="attachment_390" class="wp-caption aligncenter" style="width: 610px"><img class="size-full wp-image-390" title="MS SSMS result of row values concatenation (converting to the CSV format) by means of FOR XML PATH" src="http://placko.files.wordpress.com/2011/11/ms-ssms-result-of-row-values-concatenation-convert-to-csv-format-by-means-of-for-xml-path1.png?w=614" alt="MS SSMS result of row values concatenation (converting to the CSV format) by means of FOR XML PATH"   /><p class="wp-caption-text">Figure 2: MS SSMS result of row values concatenation (converting to the CSV format) by means of FOR XML PATH</p></div><br />
<em> </em></p>
<pre>
<code>
INSERT INTO OPENROWSET
(
            'Microsoft.Jet.OLEDB.4.0',
            'Excel 8.0;Database=C:\Managers.xls;',
                -- NOTE: the MS Excel file must already exist on the disk
                --       together with the specified path and name!
            'SELECT [Managers] FROM [Managers$]'
                -- NOTE: the above-mentioned MS Excel file must have one
                --       sheet named Managers, and the value in cell [0, 0],
                --       i.e. the first row and column, must be
                --       set to Managers (see Figure 5)!
)
SELECT	    [Managers].[ManagerLoginID]
FROM	    @InputData AS [Managers]
GROUP BY    [Managers].[ManagerLoginID]

GO
</code>
</pre>
<div><em>Source code 4: </em>exporting data (the column Managers) to the MS Excel file on the disk</div>
<p><em> </em><br />
<div id="attachment_390" class="wp-caption aligncenter" style="width: 610px"><img class="size-full wp-image-390" title="MS SSMS result of exported data (the column Managers) to the MS Excel file on the disk - error" src="http://placko.files.wordpress.com/2011/11/ms-ssms-result-of-export-data-column-managers-to-a-excel-file-on-disk-error1.png?w=614" alt="MS SSMS result of exported data (the column Managers) to the MS Excel file on the disk - error"   /><p class="wp-caption-text">Figure 3: MS SSMS result of exported data (the column Managers) to the MS Excel file on the disk - error</p></div><br />
<div id="attachment_390" class="wp-caption aligncenter" style="width: 610px"><img class="size-full wp-image-390" title="MS SSMS result of exported data (the column Managers) to the MS Excel file on the disk - solution for the above error" src="http://placko.files.wordpress.com/2011/11/ms-ssms-result-of-export-data-column-managers-to-a-excel-file-on-disk-services1.png?w=614" alt="MS SSMS result of exported data (the column Managers) to the MS Excel file on the disk - solution for the above error"   /><p class="wp-caption-text">Figure 4: MS SSMS result of exported data (the column Managers) to the MS Excel file on the disk - solution for the above error</p></div><br />
<div id="attachment_390" class="wp-caption aligncenter" style="width: 228px"><img class="size-full wp-image-390" title="MS SSMS result of exported data (the column Managers) to the MS Excel file on the disk" src="http://placko.files.wordpress.com/2011/11/ms-ssms-result-of-export-data-column-managers-to-a-excel-file-on-disk-excel.png?w=614" alt="MS SSMS result of exported data (the column Managers) to the MS Excel file on the disk"   /><p class="wp-caption-text">Figure 5: MS SSMS result of exported data (the column Managers) to the MS Excel file on the disk</p></div><br />
<em> </em></p>
<div>Additional references:</div>
<ul>
<li><a title="Concatenating Row Values in Transact-SQL" href="http://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/" target="_blank">Concatenating Row Values in Transact-SQL<br />
</a>by Anith Sen</li>
<li><a title="Data truncated to 255 characters with Excel ODBC driver" href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q189897" target="_blank">Data truncated to 255 characters with Excel ODBC driver<br />
</a>by Microsoft</li>
<li><a title="Execute SQLTask Error String or binary data would be truncated" href="http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/bae751d3-14ee-4739-90c1-ca9316825e11/" target="_blank">Execute SQLTask Error String or binary data would be truncated<br />
</a>by MSDN</li>
<li><a title="Export to Excel" href="http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926&amp;whichpage=2/" target="_blank">Export to Excel<br />
</a>by SQL Team</li>
<li><a title="OPENROWSET (Transact-SQL)" href="http://msdn.microsoft.com/en-us/library/ms190312.aspx" target="_blank">OPENROWSET (Transact-SQL)<br />
</a>by MSDN</li>
<li><a title="SQL Memory and External Data" href="http://nathondalton.wordpress.com/2010/04/01/sql-memory-and-external-data/" target="_blank">SQL Memory and External Data<br />
</a>by Nathon Dalton</li>
<li><a title="SQL SERVER – 2005 – Export Data From SQL Server 2005 to Microsoft Excel Datasheet" href="http://blog.sqlauthority.com/2008/01/08/sql-server-2005-export-data-from-sql-server-2005-to-microsoft-excel-datasheet/" target="_blank">SQL SERVER – 2005 – Export Data From SQL Server 2005 to Microsoft Excel Datasheet<br />
</a>by Pinal Dave</li>
<li><a title="SQL SERVER – 2005 – Sample Example of RANKING Functions – ROW_NUMBER, RANK, DENSE_RANK, NTILE" href="http://blog.sqlauthority.com/2007/10/09/sql-server-2005-sample-example-of-ranking-functions-row_number-rank-dense_rank-ntile/" target="_blank">SQL SERVER – 2005 – Sample Example of RANKING Functions – ROW_NUMBER, RANK, DENSE_RANK, NTILE<br />
</a>by Pinal Dave</li>
<li><a title="SQL SERVER – Comma Separated Values (CSV) from Table Column" href="http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/" target="_blank">SQL SERVER – Comma Separated Values (CSV) from Table Column<br />
</a>by Pinal Dave</li>
<li><a title="SQL SERVER – Create a Comma Delimited List Using SELECT Clause From Table Column" href="http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/" target="_blank">SQL SERVER – Create a Comma Delimited List Using SELECT Clause From Table Column<br />
</a>by Pinal Dave</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/placko.wordpress.com/785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/placko.wordpress.com/785/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/placko.wordpress.com/785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/placko.wordpress.com/785/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/placko.wordpress.com/785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/placko.wordpress.com/785/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/placko.wordpress.com/785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/placko.wordpress.com/785/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/placko.wordpress.com/785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/placko.wordpress.com/785/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/placko.wordpress.com/785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/placko.wordpress.com/785/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/placko.wordpress.com/785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/placko.wordpress.com/785/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=785&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://placko.wordpress.com/2011/11/20/csv-row-values-concatenation-for-xml-path-and-exporting-column-values-to-a-ms-excel-file-microsoft-jet-oledb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>48.312872 18.086038</georss:point>
		<geo:lat>48.312872</geo:lat>
		<geo:long>18.086038</geo:long>
		<media:content url="http://1.gravatar.com/avatar/1c0bc5b54e549b05a3ee622a9d8f6aac?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">placko</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/11/ms-ssms-result-of-input-data-preparation.png" medium="image">
			<media:title type="html">MS SSMS result of input data preparation (ManagersCounter - number of employees per manager)</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/11/ms-ssms-result-of-row-values-concatenation-convert-to-csv-format-by-means-of-for-xml-path1.png" medium="image">
			<media:title type="html">MS SSMS result of row values concatenation (converting to the CSV format) by means of FOR XML PATH</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/11/ms-ssms-result-of-export-data-column-managers-to-a-excel-file-on-disk-error1.png" medium="image">
			<media:title type="html">MS SSMS result of exported data (the column Managers) to the MS Excel file on the disk - error</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/11/ms-ssms-result-of-export-data-column-managers-to-a-excel-file-on-disk-services1.png" medium="image">
			<media:title type="html">MS SSMS result of exported data (the column Managers) to the MS Excel file on the disk - solution for the above error</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/11/ms-ssms-result-of-export-data-column-managers-to-a-excel-file-on-disk-excel.png" medium="image">
			<media:title type="html">MS SSMS result of exported data (the column Managers) to the MS Excel file on the disk</media:title>
		</media:content>
	</item>
		<item>
		<title>Concurrent Behaviour at Transaction Isolation Levels</title>
		<link>http://placko.wordpress.com/2011/02/20/concurrent-behaviour-at-transaction-isolation-levels/</link>
		<comments>http://placko.wordpress.com/2011/02/20/concurrent-behaviour-at-transaction-isolation-levels/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 15:13:11 +0000</pubDate>
		<dc:creator>placko</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://placko.wordpress.com/?p=364</guid>
		<description><![CDATA[Task: to determine the behaviour of particular transaction isolation levels with respect to concurrent SQL query &#8230;SELECT TOP(1) [...] + 1&#8230; Solution: see Figure 2 USE [Test_IsolationLevels] GO Source code 1: Use database CREATE TABLE [dbo].[IsoSelTopOnePlusOne](  [Identity] [int] IDENTITY(1,1) NOT NULL,  [TopOnePlusOne] [int] NOT NULL,  [ModifiedDate] [datetime] NOT NULL ) ON [PRIMARY] GO Source code 2: Create table -- 0: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=364&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div><span style="text-decoration:underline;"><strong>Task:</strong></span> to determine the behaviour of particular transaction isolation levels with respect to concurrent SQL query &#8230;SELECT TOP(1) [...] + 1&#8230;<br />
<span style="text-decoration:underline;"><strong>Solution:</strong></span> see Figure 2</div>
<p><em> </em><br />
<em> </em></p>
<pre>USE [Test_IsolationLevels]
GO</pre>
<div><em>Source code 1:</em> Use database</div>
<p><em> </em></p>
<pre>CREATE TABLE [dbo].[IsoSelTopOnePlusOne](
 [Identity] [int] IDENTITY(1,1) NOT NULL,
 [TopOnePlusOne] [int] NOT NULL,
 [ModifiedDate] [datetime] NOT NULL
) ON [PRIMARY]
GO</pre>
<div><em>Source code 2:</em> Create table</div>
<p><em> </em></p>
<pre>-- 0: (NOTE: default isolation level)
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
---- 1:
--SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
---- 2:
--SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
---- 3:
--SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
---- 4:
--ALTER DATABASE [Test_IsolationLevels] SET ALLOW_SNAPSHOT_ISOLATION ON
--SET TRANSACTION ISOLATION LEVEL SNAPSHOT
---- 5: (NOTE: set up failed)
--ALTER DATABASE [Test_IsolationLevels] SET READ_COMMITTED_SNAPSHOT ON
GO

DBCC USEROPTIONS
GO</pre>
<div><em>Source code 3:</em> Set up and select user options</div>
<p><em> </em></p>
<div id="attachment_390" class="wp-caption aligncenter" style="width: 262px"><img class="size-full wp-image-390" title="DBCC USEROPTIONS" src="http://placko.files.wordpress.com/2011/02/isolationlevel__dbcc_useroptions.png?w=614" alt="DBCC USEROPTIONS"   /><p class="wp-caption-text">Figure 1: SSMS result of DBCC USEROPTIONS</p></div>
<p><em> </em></p>
<pre>CREATE PROCEDURE [dbo].[IsoSelTopOnePlusOne_Ins]
AS
BEGIN
 -- 0: (NOTE: default isolation level)
 SET TRANSACTION ISOLATION LEVEL READ COMMITTED
 ---- 1:
 --SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
 ---- 2:
 --SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
 ---- 3:
 --SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
 ---- 4:
 --SET TRANSACTION ISOLATION LEVEL SNAPSHOT

 BEGIN TRANSACTION IsoSelTop1PlusOne 

  DECLARE @Top1PlusOne INT
  SET @Top1PlusOne =
  (
   SELECT TOP(1) [TopOnePlusOne] + 1
   FROM [dbo].[IsoSelTopOnePlusOne]
   ORDER BY [TopOnePlusOne] DESC
  )
  IF
  (
   @Top1PlusOne
  ) IS NULL
  BEGIN
   SET @Top1PlusOne = 0
  END

  INSERT INTO [dbo].[IsoSelTopOnePlusOne]
  (
   [TopOnePlusOne],
   [ModifiedDate]
  )
  VALUES
  (
   @Top1PlusOne,
   GETDATE()
  )

  WAITFOR DELAY '00:00:10'

 COMMIT TRANSACTION IsoSelTop1PlusOne
END
GO</pre>
<div><em>Source code 4:</em> Create procedure</div>
<p><em> </em></p>
<pre>EXEC [dbo].[IsoSelTopOnePlusOne_Ins]
GO</pre>
<div><em>Source code 5:</em> Execute procedure</div>
<p><em> </em></p>
<p><div id="attachment_397" class="wp-caption aligncenter" style="width: 493px"><img class="size-full wp-image-397" title="SELECT TABLE [dbo].[IsoSelTopOnePlusOne]" src="http://placko.files.wordpress.com/2011/02/isolationlevel__select_table_dbo_isoseltoponeplusone.png?w=614" alt="SELECT TABLE [dbo].[IsoSelTopOnePlusOne]"   /><p class="wp-caption-text">Figure 2: SSMS result of concurrent behaviour at the transaction isolation levels</p></div><em> </em><br />
Measuring results:</p>
<table>
<tbody>
<tr>
<th>[Identity]</th>
<th>Isolation Level</th>
<th>[TopOnePlusOne]</th>
<th>match/mismatch</th>
</tr>
<tr>
<td>1-2</td>
<td>ISOLATION LEVEL READ COMMITTED</td>
<td>0, 1</td>
<td style="color:white;background-color:green;">mismatch</td>
</tr>
<tr>
<td>3-4</td>
<td>ISOLATION LEVEL READ UNCOMMITTED</td>
<td>2, 3</td>
<td style="color:white;background-color:green;">mismatch</td>
</tr>
<tr>
<td>5-6</td>
<td>ISOLATION LEVEL REPEATABLE READ</td>
<td>4, 5</td>
<td style="color:white;background-color:green;">mismatch</td>
</tr>
<tr>
<td>7-8</td>
<td>ISOLATION LEVEL SERIALIZABLE</td>
<td>6, 7</td>
<td style="color:white;background-color:green;">mismatch</td>
</tr>
<tr>
<td>9-10</td>
<td>ISOLATION LEVEL SNAPSHOT</td>
<td>8, 8</td>
<td style="color:white;background-color:red;">match</td>
</tr>
</tbody>
</table>
<div><em> </em><br />
The measurement above included 2 concurrent SQL queries (two SSMS windows). The second query started up approximately in half of the first SQL query.</div>
<p><em> </em></p>
<div>Additional references:</div>
<ul>
<li><a title="DBCC USEROPTIONS (Transact-SQL)" href="http://msdn.microsoft.com/en-us/library/ms180065.aspx" target="_blank">DBCC USEROPTIONS<br />
</a>by MSDN</li>
<li><a title="Isolation (database systems)" href="http://en.wikipedia.org/wiki/Isolation_(database_systems)" target="_blank">Isolation (database systems)<br />
</a>by Wikipedia</li>
<li><a title="Isolation Levels in the Database Engine" href="http://msdn.microsoft.com/en-us/library/ms189122.aspx" target="_blank">Isolation Levels in the Database Engine<br />
</a>by MSDN</li>
<li><a title="SET TRANSACTION ISOLATION LEVEL (Transact-SQL)" href="http://msdn.microsoft.com/en-us/library/ms173763.aspx" target="_blank">SET TRANSACTION ISOLATION LEVEL<br />
</a>by MSDN</li>
<li><a title="SQL SERVER – Applying NOLOCK Hint at Query Level – NOLOCK for whole Transaction" href="http://blog.sqlauthority.com/2011/04/17/sql-server-applying-nolock-hint-at-query-level-nolock-for-whole-transaction/" target="_blank">SQL SERVER – Applying NOLOCK Hint at Query Level – NOLOCK for whole Transaction<br />
</a>by Pinal Dave</li>
<li><a title="SQL SERVER – Concurrancy Problems and their Relationship with Isolation Level" href="http://blog.sqlauthority.com/2011/03/04/sql-server-concurrancy-problems-and-their-relationship-with-isolation-level/" target="_blank">SQL SERVER – Concurrancy Problems and their Relationship with Isolation Level<br />
</a>by Pinal Dave</li>
<li><a title="SQL SERVER – Simple Example of Snapshot Isolation – Reduce the Blocking Transactions" href="http://blog.sqlauthority.com/2010/05/21/sql-server-simple-example-of-snapshot-isolation-reduce%C2%A0the%C2%A0blocking%C2%A0transactions/" target="_blank">SQL SERVER – Simple Example of Snapshot Isolation – Reduce the Blocking Transactions<br />
</a>by Pinal Dave</li>
</ul>
<p><em> </em></p>
<div>Other references:</div>
<ul>
<li><a title="SQL SERVER – Locking and Blocking – Important Aspect of Database and Effect on Performance – Quiz – Puzzle – 5 of 31" href="http://blog.sqlauthority.com/2012/01/06/sql-server-locking-and-blocking-important-aspect-of-database-and-effect-on-performance-quiz-puzzle-5-of-31/" target="_blank">SQL SERVER – Locking and Blocking – Important Aspect of Database and Effect on Performance – Quiz – Puzzle – 5 of 31<br />
</a>by Pinal Dave</li>
<li><a title="SQLServer Quiz 2012 - ANSI ISOLATIONS levels are very important part of any database" href="http://beyondrelational.com/quiz/sqlserver/general/2012/questions/188/ansi-isolations-levels-are-very-important-part-of-any-database.aspx" target="_blank">SQLServer Quiz 2012 &#8211; ANSI ISOLATIONS levels are very important part of any database<br />
</a>by Beyond Relational</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/placko.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/placko.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/placko.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/placko.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/placko.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/placko.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/placko.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/placko.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/placko.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/placko.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/placko.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/placko.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/placko.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/placko.wordpress.com/364/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=364&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://placko.wordpress.com/2011/02/20/concurrent-behaviour-at-transaction-isolation-levels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>48.312872 18.086038</georss:point>
		<geo:lat>48.312872</geo:lat>
		<geo:long>18.086038</geo:long>
		<media:content url="http://1.gravatar.com/avatar/1c0bc5b54e549b05a3ee622a9d8f6aac?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">placko</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/02/isolationlevel__dbcc_useroptions.png" medium="image">
			<media:title type="html">DBCC USEROPTIONS</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/02/isolationlevel__select_table_dbo_isoseltoponeplusone.png" medium="image">
			<media:title type="html">SELECT TABLE [dbo].[IsoSelTopOnePlusOne]</media:title>
		</media:content>
	</item>
		<item>
		<title>Parsing T-SQL</title>
		<link>http://placko.wordpress.com/2010/12/15/parsing-t-sql/</link>
		<comments>http://placko.wordpress.com/2010/12/15/parsing-t-sql/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 11:15:56 +0000</pubDate>
		<dc:creator>placko</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://placko.wordpress.com/?p=327</guid>
		<description><![CDATA[Task: syntax parsing and checking db object existence in SQL query Solution: see Source code No. 4 Source code No. 1: Syntax parsing of SQL DECLARE @SqlQuery NVARCHAR(4000) SET @SqlQuery = 'SELECT [ID] FRON [dbo].[Parsing_T-SQL]' EXEC ('SET FMTONLY ON ' + @SqlQuery) Figure 1: SSMS SQL query result &#8211; syntax parsing of SQL Source code No. 2: Table [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=327&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration:underline;"><strong>Task:</strong></span> syntax parsing and checking db object existence in SQL query<br />
<span style="text-decoration:underline;"><strong>Solution:</strong></span> see Source code No. 4<br />
<em> </em><br />
<em> </em><br />
<em>Source code No. 1:</em> Syntax parsing of SQL</p>
<pre>DECLARE @SqlQuery NVARCHAR(4000)
SET @SqlQuery = 'SELECT [ID] <span style="color:#ffff00;">FRON</span> [dbo].[Parsing_T-SQL]'
EXEC ('SET FMTONLY ON ' + @SqlQuery)</pre>
<p><em> </em></p>
<p><em>Figure 1:</em> SSMS SQL query result &#8211; syntax parsing of SQL<br />
<img src="http://placko.files.wordpress.com/2011/03/ssms_queryresult_syntaxparsing.png?w=614" alt="Figure 1: SSMS SQL query result - syntax parsing of SQL" /></p>
<p><em> </em></p>
<p><em>Source code No. 2:</em> Table existence check</p>
<pre>DECLARE @SqlQuery NVARCHAR(4000)
SET @SqlQuery = 'SELECT [ID] FROM <span style="color:#ffff00;">[dbo].[Parsing_T-SQL]</span>'
EXEC ('SET FMTONLY ON ' + @SqlQuery)</pre>
<p><em> </em></p>
<p><em>Figure 2:</em> SSMS SQL query result &#8211; table existence check<br />
<img src="http://placko.files.wordpress.com/2011/03/ssms_queryresult_tableexistencecheck.png?w=614" alt="Figure 2: SSMS SQL query result - table existence check" /></p>
<p><em> </em></p>
<p>Notes:</p>
<ul>
<li>syntax parsing and checking db object existence in SQL query is valid equally for all commands of DML set (it means: SELECT/INSERT/UPDATE/DELETE)</li>
<li>functionally identical for EXEC and EXEC sp_executesql</li>
<li>option SET NOEXEC ON and SET PARSEONLY ON executed syntax parsing only but not db object existence check (db object existence check may be carried out by means of SYSOBJECTS, SYSCOLUMNS etc.)</li>
<li>the structure of BEGIN TRAN-ROLLBACK TRAN is not suitable because not all operations may be rollbacked (e.g. DROP DATABASE)</li>
</ul>
<p><em> </em></p>
<p><em>Source code No. 3:</em> Syntax parsing and checking the existence in SQL query with user&#8217;s parameter (i.e. input)</p>
<pre>DECLARE @SqlQuery NVARCHAR(4000)
SET @SqlQuery = 'UPDATE [dbo].[Parsing_T-SQL] SET [Value] = ''Test'' WHERE [ID] = <span style="color:#ffff00;">@ID</span>'
EXEC ('SET FMTONLY ON ' + @SqlQuery)</pre>
<p><em> </em></p>
<p><em>Figure 3:</em> SSMS SQL query result &#8211; syntax parsing and checking the existence in SQL query with user&#8217;s parameter (input)<br />
<img src="http://placko.files.wordpress.com/2011/03/ssms_queryresult_syntaxparsingandexistencecheckwithparameter.png?w=614" alt="Figure 3: SSMS SQL query result - syntax parsing and checking the existence in SQL query with user's parameter (input)" /></p>
<p><em> </em></p>
<p>Note: PARSE is OK but for EXECUTE see Figure 3</p>
<p>Solution: replacement @ID = 1 (see Source code No. 4)</p>
<p><em> </em></p>
<p><em>Source code No. 4:</em> Syntax parsing and checking the existence in SQL query with user&#8217;s parameter (i.e. input) and replacement @ID = 1</p>
<pre>DECLARE @SqlQuery NVARCHAR(4000)
SET @SqlQuery = 'UPDATE [dbo].[Parsing_T-SQL] SET [Value] = ''Test'' WHERE [ID] = <span style="color:#ffff00;">1</span>'
EXEC ('SET FMTONLY ON ' + @SqlQuery)</pre>
<p><em> </em><br />
<em> </em></p>
<p>Additional reference:</p>
<ul>
<li><a href="http://luke.breuer.com/html/sqlwrite.htm" target="_blank">SqlWrite</a><br />
by Luke Breuer</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/placko.wordpress.com/327/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/placko.wordpress.com/327/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/placko.wordpress.com/327/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/placko.wordpress.com/327/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/placko.wordpress.com/327/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/placko.wordpress.com/327/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/placko.wordpress.com/327/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/placko.wordpress.com/327/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/placko.wordpress.com/327/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/placko.wordpress.com/327/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/placko.wordpress.com/327/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/placko.wordpress.com/327/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/placko.wordpress.com/327/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/placko.wordpress.com/327/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=327&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://placko.wordpress.com/2010/12/15/parsing-t-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>48.312872 18.086038</georss:point>
		<geo:lat>48.312872</geo:lat>
		<geo:long>18.086038</geo:long>
		<media:content url="http://1.gravatar.com/avatar/1c0bc5b54e549b05a3ee622a9d8f6aac?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">placko</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/ssms_queryresult_syntaxparsing.png" medium="image">
			<media:title type="html">Figure 1: SSMS SQL query result - syntax parsing of SQL</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/ssms_queryresult_tableexistencecheck.png" medium="image">
			<media:title type="html">Figure 2: SSMS SQL query result - table existence check</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/ssms_queryresult_syntaxparsingandexistencecheckwithparameter.png" medium="image">
			<media:title type="html">Figure 3: SSMS SQL query result - syntax parsing and checking the existence in SQL query with user&#039;s parameter (input)</media:title>
		</media:content>
	</item>
		<item>
		<title>Select of SQL Server Best Practices</title>
		<link>http://placko.wordpress.com/2010/11/15/select-of-sql-server-best-practices/</link>
		<comments>http://placko.wordpress.com/2010/11/15/select-of-sql-server-best-practices/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 11:15:08 +0000</pubDate>
		<dc:creator>placko</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[patterns & practices]]></category>

		<guid isPermaLink="false">http://placko.wordpress.com/?p=322</guid>
		<description><![CDATA[Best Practice for renaming a SQL Server Database by Ashish K. Metha, February 12, 2009 Best Practices – When Using FILESTREAM Feature of SQL Server 2008 by Ashish, K. Metha, June 11, 2009 Brad&#8217;s Sure DBA Checklist by Brad McGehee, January 20, 2010 SQL Server Best Practices – Implementation of Database Object Schemas by Microsoft [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=322&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<ul>
<li><a href="http://www.mssqltips.com/tip.asp?tip=1891&amp;home" target="_blank">Best Practice for renaming a SQL Server Database</a> by Ashish K. Metha, February 12, 2009</li>
<li><a href="http://www.mssqltips.com/tip.asp?tip=1875" target="_blank">Best Practices – When Using FILESTREAM Feature of SQL Server 2008</a> by Ashish, K. Metha, June 11, 2009</li>
<li><a href="http://www.simple-talk.com/sql/database-administration/brads-sure-dba-checklist/?utm_source=simpletalk&amp;utm_medium=email&amp;utm_content=BradChecklist-20100125&amp;utm_campaign=SQL#_Toc209585610" target="_blank">Brad&#8217;s Sure DBA Checklist</a> by Brad McGehee, January 20, 2010</li>
<li><a href="http://technet.microsoft.com/en-us/library/dd283095.aspx" target="_blank">SQL Server Best Practices – Implementation of Database Object Schemas</a> by Microsoft TechNet, SQL Server TechCenter, Library, November, 2008</li>
<li><a href="http://blogs.msdn.com/buckwoody/archive/2009/12/07/sql-server-best-practices-use-roles-when-you-can.aspx" target="_blank">SQL Server Best Practices: Use Roles When You Can</a> by Buck Woody, December 07, 2009</li>
<li><a href="http://www.databasejournal.com/features/mssql/article.php/3863516/SQL-Server-Impersonation.htm" target="_blank">SQL Server Impersonation</a> by Deanna Dicken, February 12, 2010</li>
<li><a href="http://www.sqlservercentral.com/blogs/robert_davis/archive/2010/03/10/Top-6-Myths-of-Transaction-Logs.aspx" target="_blank">Top 6 Myths of Transaction Logs</a> by Robert Davis, October 03, 2010</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/placko.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/placko.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/placko.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/placko.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/placko.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/placko.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/placko.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/placko.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/placko.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/placko.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/placko.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/placko.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/placko.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/placko.wordpress.com/322/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=322&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://placko.wordpress.com/2010/11/15/select-of-sql-server-best-practices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>48.312872 18.086038</georss:point>
		<geo:lat>48.312872</geo:lat>
		<geo:long>18.086038</geo:long>
		<media:content url="http://1.gravatar.com/avatar/1c0bc5b54e549b05a3ee622a9d8f6aac?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">placko</media:title>
		</media:content>
	</item>
		<item>
		<title>Select of T-SQL/Database Bad Habits to Kick</title>
		<link>http://placko.wordpress.com/2010/10/15/select-of-t-sqldatabase-bad-habits-to-kick/</link>
		<comments>http://placko.wordpress.com/2010/10/15/select-of-t-sqldatabase-bad-habits-to-kick/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 11:15:45 +0000</pubDate>
		<dc:creator>placko</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[patterns & practices]]></category>

		<guid isPermaLink="false">http://placko.wordpress.com/?p=318</guid>
		<description><![CDATA[Abusing triggers by A. Bertrand, October 12, 2009 Avoiding the schema prefix by A. Bertrand, October 11, 2009 Blind SQL Server installs by A. Bertrand, February 10, 2010 Creating the user-view by A. Bertrand, March 07, 2010 Declaring VARCHAR without (length) by A. Bertrand, October 09, 2009 Choosing the wrong data type by A. Bertrand, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=318&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<ul>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/12/bad-habits-to-kick-abusing-triggers.aspx" target="_blank">Abusing triggers</a> by A. Bertrand, October 12, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/11/bad-habits-to-kick-avoiding-the-schema-prefix.aspx" target="_blank">Avoiding the schema prefix</a> by A. Bertrand, October 11, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2010/02/10/bad-habits-to-kick-blind-sql-server-installs.aspx" target="_blank">Blind SQL Server installs</a> by A. Bertrand, February 10, 2010</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2010/03/07/bad-habits-to-kick-creating-the-uber-view.aspx" target="_blank">Creating the user-view</a> by A. Bertrand, March 07, 2010</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/09/bad-habits-to-kick-declaring-varchar-without-length.aspx" target="_blank">Declaring VARCHAR without (length)</a> by A. Bertrand, October 09, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/12/bad-habits-to-kick-using-the-wrong-data-type.aspx" target="_blank">Choosing the wrong data type</a> by A. Bertrand, October 12, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2010/02/12/bad-habits-to-kick-ignoring-the-principles-of-least-privilege.aspx" target="_blank">Ignoring the principle of least privilege</a> by A. Bertrand, February 12, 2010</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/11/bad-habits-to-kick-inconsistent-naming-conventions.aspx" target="_blank">Inconsistent naming conventions</a> by A. Bertrand, October 11, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2010/02/16/bad-habits-to-kick-inconsistent-table-aliasing.aspx" target="_blank">Inconsistent table aliasing</a> by A. Bertrand, February 16, 2010</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/12/bad-habits-to-kick-expecting-identity-to-mean-something.aspx" target="_blank">Making assumptions about IDENTITY</a> by A. Bertrand, October 12, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/16/bad-habits-to-kick-mishandling-date-range-queries.aspx" target="_blank">Mis-handling date / range queries</a> by A. Bertrand, October 16, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/06/bad-habits-to-kick-order-by-ordinal.aspx" target="_blank">ORDER BY ordinal</a> by A. Bertrand, October 06, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/14/bad-habits-to-kick-using-alias-types.aspx" target="_blank">Using alias types</a> by A. Bertrand, October 14, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/09/bad-habits-to-kick-using-dashes-and-spaces-in-entity-names.aspx" target="_blank">Using dashes and spaces in entity names</a> by A. Bertrand, October 09, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/07/bad-habits-to-kick-using-a-loop-to-populate-a-table.aspx" target="_blank">Using loops to populate large tables</a> by A. Bertrand, October 07, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick-using-old-style-joins.aspx" target="_blank">Using old-style JOINs</a> by A. Bertrand, October 08, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/10/bad-habits-to-kick-using-select-omitting-the-column-list.aspx" target="_blank">Using SELECT * / omitting the column list</a> by A. Bertrand, October 10, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/09/bad-habits-to-kick-using-select-or-return-instead-of-output.aspx" target="_blank">Using SELECT or RETURN instead of OUTPUP</a> by A. Bertrand, October 09, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick-using-table-aliases-like-a-b-c-or-t1-t2-t3.aspx" target="_blank">Using table aliases like (a, b, c) or (t1, t2, t3)</a> by A. Bertrand, October 08, 2009</li>
<li><a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/14/bad-habits-to-kick-using-the-visual-designers.aspx" target="_blank">Using the visual designer</a> by A. Bertrand, October 14, 2009</li>
<li>::</li>
<li><a href="http://sqlblog.com/blogs/adam_machanic/archive/2009/10/08/bad-habits-to-kick-not-using-as.aspx" target="_blank">Not Using &#8220;AS&#8221;</a> by A. Machanic, October 08, 2009</li>
<li>::</li>
<li><a href="http://sqlblog.com/blogs/linchi_shea/archive/2009/10/30/database-bad-practices-moving-data-to-the-procedures-vs-moving-procedures-to-data.aspx" target="_blank">Moving data to procedures vs. moving procedures to data</a> by L. Shea, October 30, 2009</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/placko.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/placko.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/placko.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/placko.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/placko.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/placko.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/placko.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/placko.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/placko.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/placko.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/placko.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/placko.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/placko.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/placko.wordpress.com/318/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=318&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://placko.wordpress.com/2010/10/15/select-of-t-sqldatabase-bad-habits-to-kick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>48.312872 18.086038</georss:point>
		<geo:lat>48.312872</geo:lat>
		<geo:long>18.086038</geo:long>
		<media:content url="http://1.gravatar.com/avatar/1c0bc5b54e549b05a3ee622a9d8f6aac?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">placko</media:title>
		</media:content>
	</item>
		<item>
		<title>System Function RAND() within UDF</title>
		<link>http://placko.wordpress.com/2010/09/15/system-function-rand-within-udf/</link>
		<comments>http://placko.wordpress.com/2010/09/15/system-function-rand-within-udf/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 11:15:55 +0000</pubDate>
		<dc:creator>placko</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://placko.wordpress.com/?p=313</guid>
		<description><![CDATA[Task: the system function RAND() use in the user defined function (UDF) Solution: the system function RAND() is not possible to be used in the user defined function (see Figure 1 to 3). However, this function is possible to be implemented without problems into the stored procedure (see Figure 4 and 6), or to be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=313&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration:underline;"><strong>Task:</strong></span> the system function RAND() use in the user defined function (UDF)<br />
<span style="text-decoration:underline;"><strong>Solution:</strong></span> the system function RAND() is not possible to be used in the user defined function (see Figure 1 to 3). However, this function is possible to be implemented without problems into the stored procedure (see Figure 4 and 6), or to be used by means of a database object “view” ( see Figure 5 to 8 )</p>
<p><em> </em></p>
<p><em>Figure 1:</em> Definition of the Table-valued function<br />
<img src="http://placko.files.wordpress.com/2011/03/rand_functiondefinition0.png?w=614" alt="Figure 1: Definition of the Table-valued function" /></p>
<p><em>Figure 2:</em> Result of SQL query (of the Table-valued and Scalar-valued function)<br />
<img src="http://placko.files.wordpress.com/2011/03/rand_functionexception.png?w=614" alt="Figure 2: Result of SQL query (of the Table-valued and Scalar-valued function)" /></p>
<p><em>Figure 3:</em> Definition of the Scalar-valued function<br />
<img src="http://placko.files.wordpress.com/2011/03/rand_functiondefinition1.png?w=614" alt="Figure 3: Definition of the Scalar-valued function" /></p>
<p><em>Figure 4:</em> Definition of the stored procedure<br />
<img src="http://placko.files.wordpress.com/2011/03/rand_proceduredefinition.png?w=614" alt="Figure 4: Definition of the stored procedure" /></p>
<p><em>Figure 5:</em> definition of the view<br />
<img src="http://placko.files.wordpress.com/2011/03/rand_viewdefinition.png?w=614" alt="Figure 5: Definition of the view" /></p>
<p><em>Figure 6:</em> Result of SQL query (of the stored procedure and view)<br />
<img src="http://placko.files.wordpress.com/2011/03/rand_procedureandviewresult.png?w=614" alt="Figure 6: Result of SQL query (of the stored procedure and view)" /></p>
<p><em>Figure 7:</em> Definition of SQL query using the view<br />
<img src="http://placko.files.wordpress.com/2011/03/rand_querydefinition.png?w=650&#038;h=184" alt="Figure 7: Definition of SQL query using the view" width="650" height="184" /></p>
<p>Note: command <strong>GO</strong> 5 provides the execution of programming batch 5 times</p>
<p><em>Figure 8:</em> Result of SQL query using the view<br />
<img src="http://placko.files.wordpress.com/2011/03/rand_queryresult0.png?w=614" alt="Figure 8: Result of SQL query using the view" /></p>
<p><em>Figure 9:</em> Definition of SQL query with the pre-defined initialisation value<br />
<img src="http://placko.files.wordpress.com/2011/03/rand_querydefinition1.png?w=614" alt="Figure 9: Definition of SQL query with the pre-defined initialisation value" /></p>
<p><em>Figure 10:</em> Result of SQL query with the pre-defined initialisation value<br />
<img src="http://placko.files.wordpress.com/2011/03/rand_queryresult1.png?w=614" alt="Figure 10: Result of SQL query with the pre-defined initialisation value" /></p>
<p>Note: when entering the initialisation value, an identical result of random value will always be generated</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/placko.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/placko.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/placko.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/placko.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/placko.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/placko.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/placko.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/placko.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/placko.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/placko.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/placko.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/placko.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/placko.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/placko.wordpress.com/313/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=313&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://placko.wordpress.com/2010/09/15/system-function-rand-within-udf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>48.312872 18.086038</georss:point>
		<geo:lat>48.312872</geo:lat>
		<geo:long>18.086038</geo:long>
		<media:content url="http://1.gravatar.com/avatar/1c0bc5b54e549b05a3ee622a9d8f6aac?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">placko</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/rand_functiondefinition0.png" medium="image">
			<media:title type="html">Figure 1: Definition of the Table-valued function</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/rand_functionexception.png" medium="image">
			<media:title type="html">Figure 2: Result of SQL query (of the Table-valued and Scalar-valued function)</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/rand_functiondefinition1.png" medium="image">
			<media:title type="html">Figure 3: Definition of the Scalar-valued function</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/rand_proceduredefinition.png" medium="image">
			<media:title type="html">Figure 4: Definition of the stored procedure</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/rand_viewdefinition.png" medium="image">
			<media:title type="html">Figure 5: Definition of the view</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/rand_procedureandviewresult.png" medium="image">
			<media:title type="html">Figure 6: Result of SQL query (of the stored procedure and view)</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/rand_querydefinition.png" medium="image">
			<media:title type="html">Figure 7: Definition of SQL query using the view</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/rand_queryresult0.png" medium="image">
			<media:title type="html">Figure 8: Result of SQL query using the view</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/rand_querydefinition1.png" medium="image">
			<media:title type="html">Figure 9: Definition of SQL query with the pre-defined initialisation value</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/rand_queryresult1.png" medium="image">
			<media:title type="html">Figure 10: Result of SQL query with the pre-defined initialisation value</media:title>
		</media:content>
	</item>
		<item>
		<title>SysObjects</title>
		<link>http://placko.wordpress.com/2010/08/15/299/</link>
		<comments>http://placko.wordpress.com/2010/08/15/299/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 11:15:12 +0000</pubDate>
		<dc:creator>placko</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://placko.wordpress.com/?p=299</guid>
		<description><![CDATA[sys.columns Task: listing of the name and nullability of individual columns from the given table Solution: SELECT [name], [is_nullable] FROM [sys].[columns] WHERE [object_id] = OBJECT_ID('[dbo].[Test_SysColumns]') Figure 1: Definition of the table Figure 2: Result of SQL query sys.parameters Task: listing of the I/O parameters from the given stored procedure Solution: SELECT [name], [is_output] FROM [sys].[parameters] [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=299&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>sys.columns</strong></p>
<p><span style="text-decoration:underline;">Task:</span> listing of the name and nullability of individual columns from the given table<br />
<span style="text-decoration:underline;">Solution:</span></p>
<pre>SELECT [name], [is_nullable]
FROM [sys].[columns]
WHERE [object_id] = OBJECT_ID('[dbo].[Test_SysColumns]')</pre>
<p><em> </em></p>
<p><em>Figure 1:</em> Definition of the table<br />
<img src="http://placko.files.wordpress.com/2011/03/sysobjects_syscolumns_tabledefinition1.png?w=614" alt="Figure 1: Definition of the table" /></p>
<p><em>Figure 2:</em> Result of SQL query<br />
<img src="http://placko.files.wordpress.com/2011/03/sysobjects_syscolumns_queryresult.png?w=614" alt="Figure 2: Result of SQL query" /><br />
<em> </em><br />
<em> </em><br />
<strong>sys.parameters</strong></p>
<p><span style="text-decoration:underline;">Task:</span> listing of the I/O parameters from the given stored procedure<br />
<span style="text-decoration:underline;">Solution:</span></p>
<pre>SELECT [name], [is_output]
FROM [sys].[parameters]
WHERE [object_id] = OBJECT_ID('[dbo].[Test_SelInputParameters]')</pre>
<p><em> </em></p>
<p><em>Figure 3:</em> Definition of the stored procedure<br />
<img src="http://placko.files.wordpress.com/2011/03/sysobjects_sysparameters_proceduredefinition.png?w=614" alt="Figure 3: Definition of the stored procedure" /></p>
<p><em>Figure 4:</em> Result of SQL query<br />
<img src="http://placko.files.wordpress.com/2011/03/sysobjects_sysparameters_queryresult.png?w=614" alt="Figure 4: Result of SQL query" /><br />
<em> </em><br />
<em> </em><br />
<strong>INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE &amp; INFORMATION_SCHEMA.TABLE_CONSTRAINTS</strong></p>
<p><span style="text-decoration:underline;">Task:</span> listing of the name for a primary key (or primary keys) from the given table<br />
<span style="text-decoration:underline;">Solution:</span> see Figure 6</p>
<p><em>Figure 5:</em> Definition of the table (see Figure 1)</p>
<p><em>Figure 6:</em> Definition of SQL query<br />
<img src="http://placko.files.wordpress.com/2011/03/sysobjects_tableconstraints_querydefinition.png?w=681&#038;h=236" alt="Figure 6: Definition of SQL query" width="681" height="236" /></p>
<p><em>Figure 7:</em> Result of SQL query<br />
<img src="http://placko.files.wordpress.com/2011/03/sysobjects_tableconstraints_queryresult.png?w=614" alt="Figure 7: Result of SQL query" /><br />
<em> </em><br />
<em> </em><br />
<strong>ColumnsDefinition (INFORMATION_SCHEMA.COLUMNS)</strong></p>
<p><span style="text-decoration:underline;">Task:</span> listing of the columns name, pre-defined value (suitably adjusted), nullability, data type and detailed information for data type from the given scheme and table. The objective is to provide this information for, e.g. validation logic at the application level of client application<br />
<span style="text-decoration:underline;">Solution:</span> see Figure 9</p>
<p><em>Figure 8:</em> Definition of the table<br />
<img src="http://placko.files.wordpress.com/2011/03/sysobjects_columnsdefinition_tabledefinition1.png?w=614" alt="Figure 8: Definition of the table" /></p>
<p><em>Figure 9:</em> Definition of the stored procedure<br />
<img src="http://placko.files.wordpress.com/2011/03/sysobjects_columnsdefinition_proceduredefinition.png?w=614" alt="Figure 9: Definition of the stored procedure" /></p>
<p><em>Figure 10:</em> Definition of the user defined scalar function<br />
<img src="http://placko.files.wordpress.com/2011/03/sysobjects_columnsdefinition_functiondefinition.png?w=614" alt="Figure 10: Definition of the user defined scalar function" /></p>
<p><em>Figure 11:</em> Result of the stored procedure<br />
<img src="http://placko.files.wordpress.com/2011/03/sysobjects_columnsdefinition_queryresult.png?w=979&#038;h=114" alt="Figure 11: Result of the stored procedure" width="979" height="114" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/placko.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/placko.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/placko.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/placko.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/placko.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/placko.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/placko.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/placko.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/placko.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/placko.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/placko.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/placko.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/placko.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/placko.wordpress.com/299/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=299&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://placko.wordpress.com/2010/08/15/299/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>48.312872 18.086038</georss:point>
		<geo:lat>48.312872</geo:lat>
		<geo:long>18.086038</geo:long>
		<media:content url="http://1.gravatar.com/avatar/1c0bc5b54e549b05a3ee622a9d8f6aac?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">placko</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/sysobjects_syscolumns_tabledefinition1.png" medium="image">
			<media:title type="html">Figure 1: Definition of the table</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/sysobjects_syscolumns_queryresult.png" medium="image">
			<media:title type="html">Figure 2: Result of SQL query</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/sysobjects_sysparameters_proceduredefinition.png" medium="image">
			<media:title type="html">Figure 3: Definition of the stored procedure</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/sysobjects_sysparameters_queryresult.png" medium="image">
			<media:title type="html">Figure 4: Result of SQL query</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/sysobjects_tableconstraints_querydefinition.png" medium="image">
			<media:title type="html">Figure 6: Definition of SQL query</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/sysobjects_tableconstraints_queryresult.png" medium="image">
			<media:title type="html">Figure 7: Result of SQL query</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/sysobjects_columnsdefinition_tabledefinition1.png" medium="image">
			<media:title type="html">Figure 8: Definition of the table</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/sysobjects_columnsdefinition_proceduredefinition.png" medium="image">
			<media:title type="html">Figure 9: Definition of the stored procedure</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/sysobjects_columnsdefinition_functiondefinition.png" medium="image">
			<media:title type="html">Figure 10: Definition of the user defined scalar function</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/sysobjects_columnsdefinition_queryresult.png" medium="image">
			<media:title type="html">Figure 11: Result of the stored procedure</media:title>
		</media:content>
	</item>
		<item>
		<title>DAC (Dedicated Administrator Connection) in SQL Server 2008/2005 Express Edition</title>
		<link>http://placko.wordpress.com/2010/07/15/dac-dedicated-administrator-connection-in-sql-server-20082005-express-edition/</link>
		<comments>http://placko.wordpress.com/2010/07/15/dac-dedicated-administrator-connection-in-sql-server-20082005-express-edition/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 11:15:11 +0000</pubDate>
		<dc:creator>placko</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://placko.wordpress.com/?p=291</guid>
		<description><![CDATA[For the first time, DAC appeared in the SQL Server 2005 version. It enables one user from the sysadmins group (that means, the system administrator) to connect to the running instance of SQL Server Database Engine, especially for the purpose of solving occurred problems on the server (note: DAC connection will disconnect all other users [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=291&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For the first time, DAC appeared in the SQL Server 2005 version. It enables one user from the sysadmins group (that means, the system administrator) to connect to the running instance of SQL Server Database Engine, especially for the purpose of solving occurred problems on the server (note: DAC connection will disconnect all other users from this server.) It will be used, e.g. in cases when the server does not respond to requirements coming from the client’s side but also in decrypting the content of database objects (i.e. of stored procedures, user-defined functions, views and triggers) which were encrypted using the key word WITH ENCRYPTION (note: the possibilities of content decryption by means of implicit encryption of  database objects will be dealt in some of other contributions on this topic.)</p>
<p>In the Express versions, this feature is implicitly deactivated. The procedure to allow DAC for the Express versions is as follows:</p>
<ul>
<li>starting up of “Control Panel\System and Maintenance\Administrative Tools\Services”</li>
<li>stopping of “SQL Server Express” service</li>
<li>opening of the dialog window “Properties” on the suspended service</li>
<li>adding “-T7806” into the text box “Start parameters”</li>
<li>starting of the “SQL Server Express” service</li>
</ul>
<p><em> </em><br />
DAC is available either through the SQLCMD utility (e.g. C:&gt;SQLCMD -E -S.\SQLEXPRESS -A) or by means of SSMS (i.e. SQL Server Management Studio). A requirement is a need to use Query Editor with the ADMIN parameter for the server name (e.g. ADMIN:MP\SQLEXPRESS2008), while it is not possible to use the Object Explorer! The connection may be established direct from the given server only. No network connection to such a server is allowed.</p>
<p><em>Figure 1:</em> Applet Services (Windows Vista)<br />
<img src="http://placko.files.wordpress.com/2011/03/dac_controlpanelservices_windowsvista.png?w=818&#038;h=617" alt="Figure 1: Applet Services (Windows Vista)" width="818" height="617" /></p>
<p><em>Figure 2:</em> SQL Server Properties (SQLS 2008)<br />
<img src="http://placko.files.wordpress.com/2011/03/dac_controlpanelservices_properties_windowsvista.png?w=781&#038;h=499" alt="Figure 2: SQL Server Properties (SQLS 2008)" width="781" height="499" /></p>
<p><em>Figure 3:</em> Management Studio &#8211; failure of an attempt to DAC before allowing it (SQLS 2008)<br />
<img src="http://placko.files.wordpress.com/2011/03/dac_managementstudio_admin_beforeconfiguring_2008.png?w=650&#038;h=543" alt="Figure 3: Management Studio - failure of an attempt to DAC before allowing it (SQLS 2008)" width="650" height="543" /></p>
<p><em>Figure 4:</em> Management Studio &#8211; failure of an attempt to DAC before allowing it (SQLS 2005)<br />
<img src="http://placko.files.wordpress.com/2011/03/dac_managementstudio_admin_beforeconfiguring_2005.png?w=642&#038;h=560" alt="Figure 4: Management Studio - failure of an attempt to DAC before allowing it (SQLS 2005)" width="642" height="560" /></p>
<p><em>Figure 5:</em> Management Studio &#8211; failure of an attempt to DAC after allowing it through Object Explorer (SQLS 2008)<br />
<img src="http://placko.files.wordpress.com/2011/03/dac_managementstudio_admin_afterconfiguring_2008.png?w=654&#038;h=519" alt="Figure 5: Management Studio - failure of an attempt to DAC after allowing it through Object Explorer (SQLS 2008)" width="654" height="519" /></p>
<p><em>Figure 6:</em> SQLCMD &#8211; DAC performance (SQLS 2008)<br />
<img src="http://placko.files.wordpress.com/2011/03/dac_sqlcmd_admin_configuring_2008.png?w=667&#038;h=124" alt="Figure 6: SQLCMD - DAC performance (SQLS 2008)" width="667" height="124" /></p>
<p><em>Figure 7:</em> SQLCMD &#8211; execution of a query in the database (SQLS 2008)<br />
<img src="http://placko.files.wordpress.com/2011/03/dac_sqlcmd_admin_ok_2008.png?w=670&#038;h=772" alt="Figure 7: SQLCMD - execution of a query in the database (SQLS 2008)" width="670" height="772" /></p>
<p><em>Figure 8:</em> SQLCMD &#8211; failure of an attempt to DAC after restarting the SQL Server service (SQLS 2008)<br />
<img src="http://placko.files.wordpress.com/2011/03/dac_sqlcmd_failure_afterconfiguring_2008.png?w=669&#038;h=131" alt="Figure 8: SQLCMD - failure of an attempt to DAC after restarting the SQL Server service (SQLS 2008)" width="669" height="131" /></p>
<p><em>Figure 9:</em> Management Studio - DAC connection configuration through Query Editor (SQLS 2008)<br />
<img src="http://placko.files.wordpress.com/2011/03/dac_managementstudio_admin_configuringconnection_2008.png?w=440&#038;h=455" alt="Figure 9: Management Studio - DAC connection configuration through Query Editor (SQLS 2008)" width="440" height="455" /></p>
<p><em>Figure 10:</em> Management Studio - execution of a query in the database through Query Editor (SQLS 2008)<br />
<a href="http://placko.files.wordpress.com/2011/03/dac_managementstudio_admin_ok_2008.png"><img src="http://placko.files.wordpress.com/2011/03/dac_managementstudio_admin_ok_2008.png?w=968&#038;h=190" alt="Figure 10: Management Studio - execution of a query in the database through Query Editor (SQLS 2008)" width="968" height="190" /></a></p>
<p><em>Figure 11:</em> Management Studio &#8211; a case when DAC is already used by other person (SQLS 2008)<br />
<img src="http://placko.files.wordpress.com/2011/03/dac_managementstudio_admin_duplicateconnection_2008.png?w=635&#038;h=522" alt="Figure 11: Management Studio - a case when DAC is already used by other person (SQLS 2008)" width="635" height="522" /></p>
<p>Additional reference:</p>
<ul>
<li><a href="http://www.sqlservercentral.com/articles/Video/67330/" target="_blank">Dedicated Administrator Connection &#8211; SQL School Video</a><br />
by Andy Warren</li>
<li><a href="http://www.sqlservercentral.com/articles/DAC/68334/" target="_blank">Enabling the Dedicated Administrator Connection (DAC) in SQL Server Express</a><br />
by Brian Kelley</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/placko.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/placko.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/placko.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/placko.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/placko.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/placko.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/placko.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/placko.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/placko.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/placko.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/placko.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/placko.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/placko.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/placko.wordpress.com/291/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=placko.wordpress.com&amp;blog=15755943&amp;post=291&amp;subd=placko&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://placko.wordpress.com/2010/07/15/dac-dedicated-administrator-connection-in-sql-server-20082005-express-edition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>48.312872 18.086038</georss:point>
		<geo:lat>48.312872</geo:lat>
		<geo:long>18.086038</geo:long>
		<media:content url="http://1.gravatar.com/avatar/1c0bc5b54e549b05a3ee622a9d8f6aac?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">placko</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/dac_controlpanelservices_windowsvista.png" medium="image">
			<media:title type="html">Figure 1: Applet Services (Windows Vista)</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/dac_controlpanelservices_properties_windowsvista.png" medium="image">
			<media:title type="html">Figure 2: SQL Server Properties (SQLS 2008)</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/dac_managementstudio_admin_beforeconfiguring_2008.png" medium="image">
			<media:title type="html">Figure 3: Management Studio - failure of an attempt to DAC before allowing it (SQLS 2008)</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/dac_managementstudio_admin_beforeconfiguring_2005.png" medium="image">
			<media:title type="html">Figure 4: Management Studio - failure of an attempt to DAC before allowing it (SQLS 2005)</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/dac_managementstudio_admin_afterconfiguring_2008.png" medium="image">
			<media:title type="html">Figure 5: Management Studio - failure of an attempt to DAC after allowing it through Object Explorer (SQLS 2008)</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/dac_sqlcmd_admin_configuring_2008.png" medium="image">
			<media:title type="html">Figure 6: SQLCMD - DAC performance (SQLS 2008)</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/dac_sqlcmd_admin_ok_2008.png" medium="image">
			<media:title type="html">Figure 7: SQLCMD - execution of a query in the database (SQLS 2008)</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/dac_sqlcmd_failure_afterconfiguring_2008.png" medium="image">
			<media:title type="html">Figure 8: SQLCMD - failure of an attempt to DAC after restarting the SQL Server service (SQLS 2008)</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/dac_managementstudio_admin_configuringconnection_2008.png" medium="image">
			<media:title type="html">Figure 9: Management Studio - DAC connection configuration through Query Editor (SQLS 2008)</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/dac_managementstudio_admin_ok_2008.png" medium="image">
			<media:title type="html">Figure 10: Management Studio - execution of a query in the database through Query Editor (SQLS 2008)</media:title>
		</media:content>

		<media:content url="http://placko.files.wordpress.com/2011/03/dac_managementstudio_admin_duplicateconnection_2008.png" medium="image">
			<media:title type="html">Figure 11: Management Studio - a case when DAC is already used by other person (SQLS 2008)</media:title>
		</media:content>
	</item>
	</channel>
</rss>
