<?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0"><channel><title>SQL Stuff</title><description>Every day is a school day</description><managingEditor>noreply@blogger.com (_RichardABrown)</managingEditor><pubDate>Sun, 22 Mar 2026 00:12:42 -0700</pubDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">101</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">25</openSearch:itemsPerPage><link>http://richbrownesq-sqlserver.blogspot.com/</link><language>en-us</language><item><title>IIS: IE doesn't auto authenticate</title><link>http://richbrownesq-sqlserver.blogspot.com/2012/09/iis-ie-doesnt-auto-authenticate.html</link><category>authentication</category><category>browser</category><category>IE</category><category>IIS</category><category>integrated</category><category>internet explorer</category><category>MVC</category><category>Security</category><category>URL</category><category>Visual Studio 2010</category><category>web app</category><category>web application</category><category>web development</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Mon, 17 Sep 2012 07:43:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-5566012937131272311</guid><description>I've been doing a little web development work recently with MVC and have come across a (very) minor issue when deploying this to my test server.

Essentially, I've deployed to the application to the server but when I access it via the IP Address, I get prompted for my windows credentials. However, when accessing it via server name I am not prompted and I get the (much better) user experience of </description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>T-SQL: Allow low privileged user to Truncate table</title><link>http://richbrownesq-sqlserver.blogspot.com/2012/09/t-sql-allow-low-privileged-user-to.html</link><category>database</category><category>ddl</category><category>delete</category><category>dml</category><category>Security</category><category>SQL</category><category>SQL 2008</category><category>SQL Server</category><category>Stored Procedure</category><category>T-SQL</category><category>truncate</category><category>users</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Mon, 17 Sep 2012 05:35:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-3655551884202200014</guid><description>The problem with TRUNCATE is that it is a DDL statement rather than the regulation DELETE statement which is DML. As such, its not captured by using the db_datewriter database role and so on the face of it, you're left with two options:

1) Add the user to db_ddladmin role (or db_owner)
2) Grant ALTER table permissions to the table(s) in question

I'm not really a fan of either of these </description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>SSMS: Help prevent the "oh ****" moment</title><link>http://richbrownesq-sqlserver.blogspot.com/2012/07/ssms-help-prevent-oh-moment.html</link><category>coding</category><category>connections</category><category>ddl</category><category>dml</category><category>Management Studio</category><category>SQL Developer Tools</category><category>SSMS</category><category>SSMS Tools Pack</category><category>T-SQL</category><category>tools</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Thu, 26 Jul 2012 03:01:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-8064122841902441088</guid><description>Its funny how sometimes you think of something which would be great idea and then the solution falls into your lap. This very thing happened to me the other day after an "oh ****" moment when I executed a query on a production server rather than the test server.&amp;nbsp;Unfortunately, there weren't any fail safes in place (eg restricted privileges) so the query ran successfully and promptly updated </description><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZY3dXqkpZU-FjrkADCLahfuJdnhe6DxaqfH_fJ3vjcGjw4_NBps8HQRcT2aBDUkz32y5kFyHhBJj2kofnhRzDSeN5e2j3pWoYLmCmX9-KgU2oQtz7OrUXrZTViQKrwN9RXtuI1RWe6NEw/s72-c/SSMSToolPack_QueryColour.bmp" width="72"/><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Powershell: String concatenation with underscore confusion</title><link>http://richbrownesq-sqlserver.blogspot.com/2012/07/powershell-string-concatenation-with.html</link><category>Admin</category><category>file</category><category>filesystem</category><category>Powershell</category><category>Scripting</category><category>underscore</category><category>variables</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Thu, 19 Jul 2012 06:36:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-490739389553926166</guid><description>In putting together a simple powershell script to download a file and store it on a filesystem, I came across some strangeness with the user of Underscore (_) when concatenation variables. Essentially, I wanted to create a filename based upon 2 powershell variables, separated by an underscore.
I wanted my filename to be:&amp;nbsp;

Richard_Brown.txt

And my powershell read something like:

$File = "C</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>T-SQL Tuesday #32 - A Day In The Life</title><link>http://richbrownesq-sqlserver.blogspot.com/2012/07/t-sql-tuesday-32-day-in-life.html</link><category>Admin</category><category>automation</category><category>career</category><category>community</category><category>database admin</category><category>DBA</category><category>job</category><category>SPOF</category><category>SQL</category><category>T-SQL Tuesday</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Tue, 17 Jul 2012 12:58:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-9212022577337064583</guid><description>T-SQL Tuesday has been a little off my radar for the last few months (as has all blogging activity!), so I was delighted when Twitter reminded me that it was that time of the month. Even better, the topic chosen by Erin Stellato (Blog | Twitter) was a great one that I felt I could really engage with.



So here we go. For the record, my job title is Database Administrator.

The task as laid out </description><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1mF2KsSHLLDBIX4V3O1IiFVDfVc7tlRfASZj5Hzwe1OnCgA8MzHotEAc0-0H0lrTtD2rBtirYWGswHtmGu_wRN_Bl15K0GSEDV4W8xdunAZlZmn6wtW8l6rm2L6DOFP7EmN2HW08rxIBQ/s72-c/tsql_tuesday.png" width="72"/><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>T-SQL: Change Schema of User Defined Type</title><link>http://richbrownesq-sqlserver.blogspot.com/2012/05/t-sql-change-schema-of-user-defined.html</link><category>books online</category><category>Bug</category><category>objects</category><category>schema</category><category>SQL</category><category>SQL 2008</category><category>SQL 2008 R2</category><category>SQL Server</category><category>T-SQL</category><category>transfer</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Tue, 1 May 2012 06:18:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-5887598625439570662</guid><description>I've been working with one of our developers to try and rationalise some database objects into some sensible schemas using the ALTER SCHEMA syntax:

http://msdn.microsoft.com/en-us/library/ms173423.aspx


Just out of interest, is it me or is this syntax for changing an objects schema a bit strange? Are you altering the Schema or the Object? Anyhow, I digress...

In our example, we have several </description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>T-SQL: Get Last Day of Month</title><link>http://richbrownesq-sqlserver.blogspot.com/2012/02/t-sql-get-last-day-of-month.html</link><category>Date</category><category>datetime</category><category>Denali</category><category>Developer</category><category>development</category><category>Format DateTime</category><category>SQL Denali</category><category>SQL Server</category><category>SQL2012</category><category>T-SQL</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Wed, 15 Feb 2012 03:30:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-619966485548883348</guid><description>One of my early blog posts highlighted how to get the first day of the current month. Well, another common task is get to the last day of a month and i'm (reasonably) pleased to see that SQL Server 2012 has an inbuilt function to achieve this.

In versions previous to SQL2012, this problem can be solved by running the following:

DECLARE @InputDate DATE = GETDATE()&amp;nbsp;

SELECT DATEADD(D, -1, </description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>T-SQL: INSERT with XML shredding is very slow</title><link>http://richbrownesq-sqlserver.blogspot.com/2012/02/t-sql-insert-with-xml-shredding-is-very.html</link><category>.Net</category><category>ampersand</category><category>Bug</category><category>C#</category><category>clr</category><category>connect</category><category>CTE</category><category>decode</category><category>Microsoft</category><category>SP1</category><category>SQL 2008</category><category>SQL Server</category><category>T-SQL</category><category>XML</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Thu, 9 Feb 2012 04:04:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-1015905963827658374</guid><description>Back in 2010, I came across a performance bug with SQL2008 SP1. When shredding XML using the nodes query, the performance is fine with a SELECT but when you want to INSERT the data to a table/temptable/tablevariable the performance becomes very poor.

The query I was having problems with was something like this (Thanks for the sample data wBob!):


DECLARE @xml XML; 
-- Spin up some test data&amp;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>T-SQL: SQL2012 Code Snippets</title><link>http://richbrownesq-sqlserver.blogspot.com/2012/02/t-sql-sql2012-code-snippets.html</link><category>Code Snippets</category><category>Developer</category><category>development</category><category>Management Studio</category><category>SQL</category><category>SQL Developer Tools</category><category>SQL Server</category><category>SQL2012</category><category>SSMS</category><category>T-SQL</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Thu, 2 Feb 2012 07:21:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-3466325640487456326</guid><description>I've never really bought into the idea of object templates in SQL Server Management Studio and in my experience, not many other database professionals have either!

Just recently however, I've been getting a increasingly frustrated at the non-standard development pattern of database objects and (just as importantly) the lack of documentation for procedures and functions. I've written in the past </description><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI1pBdy_o62NfKkm2pt3-RWpyuFDhFVPIFnF9otwvxsrsRwq6-FPmty8s2Dk2XS5fF5WdA4U_hNNflr2vhhIl_m0tJjXtGTByizP5qE0h98ofLxAgwfBdr4dE0VVq7tl8ynC2YPyZl4fJC/s72-c/SQLStuff_SQL2012_CodeSnippet.JPG" width="72"/><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>Admin: Bulkadmin vs ADMINISTER BULK OPERATIONS</title><link>http://richbrownesq-sqlserver.blogspot.com/2012/01/admin-bulkadmin-vs-administer-bulk.html</link><category>Admin</category><category>administer bulk</category><category>bcp</category><category>bulk insert</category><category>bulkcopy</category><category>DBA</category><category>SQL Server</category><category>SQL2008</category><category>T-SQL</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Tue, 31 Jan 2012 06:38:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-3244394805468168114</guid><description>I had an application thrust upon me recently which required the user executing it to have permissions to use the BULK INSERT command in T-SQL. I was aware of the server role bulkadmin which would have been a nice sledgehammer approach to crack this nut, but I was hoping for something a little more refined. Unfortunately, the only thing I came up with was the ADMINISTER BULK OPERATIONS command </description><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh25GntC2uLa6bJUL88Q6nljfPgmNlGvGHgLd38Pp10qIQs4yenx4D7bvjXI0DsBoBTlqeirjwA_1gSlf_5fR5eX_Rbf-VXUMTKpUl6Yum6XHWwrKhOaRhLYrZKSnW-9YjGdKj389tCI2dy/s72-c/SQLStuff_AdminBulkOps_a.bmp" width="72"/><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>Visual Studio: Change default browser</title><link>http://richbrownesq-sqlserver.blogspot.com/2012/01/visual-studio-change-default-browser.html</link><category>asp.net</category><category>browser</category><category>C#</category><category>Developer</category><category>development</category><category>internet explorer</category><category>razor</category><category>Visual Studio</category><category>Visual Studio 2010</category><category>web app</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Wed, 25 Jan 2012 08:54:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-4359817938480397326</guid><description>

When debugging web apps in Visual Studio, the browser it throws up is typically your default browser. Makes sense I guess. However, once you have many browsers on your machine you may wish to change this.

This is the scenario I cam up against the other day and thanks to this article, I managed to do find a way.

Essentially, you need to right click on an ASP.NET (.aspx) page in your project, </description><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIuqjt-eEO1I0hLFgqn5gVmbgi3dH8e_z0Q4Ow9OFWhx1xVFeFmJPdCrA7JzAK5TCzFHOEF9mQWhT9wKXYkd2bVezuI-KSR2KRg2P595UNsbzXSS41y9WuyEAD2qyidXxzD2icZmR5aTwK/s72-c/VS_BrowseWith_a.JPG" width="72"/><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>T-SQL: Find missing gaps in data</title><link>http://richbrownesq-sqlserver.blogspot.com/2012/01/t-sql-find-missing-gaps-in-data.html</link><category>CTE</category><category>Denali</category><category>Developer</category><category>gaps</category><category>lead</category><category>ranking functions</category><category>SQL</category><category>SQL Denali</category><category>SQL2008</category><category>SQL2012</category><category>T-SQL</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Fri, 20 Jan 2012 06:40:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-5276448656341934023</guid><description>I recently had solve a problem of finding missing values in a data series and at the same time, came across this article on the new Analytic Functions in SQL2012.

It turns out that there is a new function which can simplify my solution although as the problem is on a SQL2008 database, I won't be able to implement it. Still, another piece of the jigsaw.

Here, I'll present queries for each </description><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG6bBkghCiLEjBraq6OlNq3RuF86pBw0A-RxS2miVrHb2Bw6nlsq4u4aXNwT6Ucl4hw7k3Wh-slvcwrOImei7fqHLces3IChwS7quVyYkH-knErVcKQxlgWf0JIMPHKpJHI2eKlpECSxvC/s72-c/SQLStuff_LEAD2012.jpg" width="72"/><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>What is the RIGHT technology?</title><link>http://richbrownesq-sqlserver.blogspot.com/2012/01/what-is-right-technology.html</link><category>applications</category><category>Design</category><category>Excel</category><category>problem solving</category><category>ramble</category><category>SQL Server</category><category>support</category><category>technology</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Mon, 16 Jan 2012 02:22:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-6908181873829448450</guid><description>One of things I strongly believe in is using the right technology for solving the right problem. You can often find (understandably) that IT professionals look for solutions using technologies they understand best which can lead to inappropriate decsions being taken. "When all you have is a hammer....".

However, just how do you define the right technology?



An analogy. Whats the best way of </description><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9k_uO6co5Dqb4Vg9U9s9CU5v8mjpQ5wB2BaltfeK1af08AGJnLCviHK7y_nD5VLE60n8cZMBfTINI0yAyvZd-GCJiukGGsWmmDk8euDMQhf5AQSEW9i_cl_JWd2YwYTB4HJWPSijhGf9i/s72-c/cash_till_203x152.jpg" width="72"/><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Admin: Start and Stop Local Instance of SQL Server</title><link>http://richbrownesq-sqlserver.blogspot.com/2012/01/start-and-stop-local-instance-of-sql.html</link><category>Admin</category><category>DBA</category><category>services</category><category>SQL</category><category>SQL 2008</category><category>SQL Server</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Wed, 11 Jan 2012 02:54:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-4168403085808989167</guid><description>As a database professional, i'm accustomed to having a local sql server instance installed. However, it seems that SQL Server (typically Express) is finding its way onto more and more desktops, often unused and unknown to the user!! With the web browser FireFox taking up almost half your memory, you don't want any other applications taking your valuable resources.

I recommend changing the </description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Admin: Windows Group Login Ambiguity</title><link>http://richbrownesq-sqlserver.blogspot.com/2011/12/admin-windows-group-login-ambiguity.html</link><category>Admin</category><category>Date</category><category>Group Membership</category><category>language</category><category>permissions</category><category>Security</category><category>SQL</category><category>SQL 2005</category><category>SQL 2008</category><category>SQL 2008 R2</category><category>SQL Server</category><category>Windows</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Thu, 8 Dec 2011 01:23:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-2986686774221293436</guid><description>Its a typical scenario to grant login access to SQL Server via Windows groups as this eases the administrative burden of setting up multiple logins all with the same access. However, its not uncommon for a user to belong to multiple Windows groups and its possible that these groups could each have a SQL login. So whats the problem? Well, consider this example:

User - DOMAIN\PeterPan
Groups - </description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>T-SQL: Audit Data Changes</title><link>http://richbrownesq-sqlserver.blogspot.com/2011/12/t-sql-audit-data-changes.html</link><category>audit</category><category>change tracking</category><category>data changes</category><category>Developer</category><category>development</category><category>SQL</category><category>SQL Server</category><category>T-SQL</category><category>trigger</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Thu, 1 Dec 2011 01:00:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-1182607771321382670</guid><description>I was recently asked about how to implement auditing of data changes for a database. I know SQL Server contains the Change Data Capture feature but (as is often the case with things I want!), its an Enterprise only feature meaning its out of the reach for the application in question.

As it happened, it turned out that there was already an application in-house (that I hadn't developed) which </description><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifc1ZLpLwO2NIw78h905Kc7KhMn6nGBN6Hd3HXx9W-lhAEReVBZg03ygejhY0_9_AE6TR8zoWlGmsUa6hlUL3gYhBdGsO-j7rUF-kNbHYtsGudCTG8CUVsJDnedm0NhesWGerU7ay4oM8H/s72-c/ChangeTracking.JPG" width="72"/><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></item><item><title>Denali: Now gets a proper name!</title><link>http://richbrownesq-sqlserver.blogspot.com/2011/11/denali-now-gets-proper-name.html</link><category>Denali</category><category>SQL</category><category>sql 2012</category><category>SQL Server</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Sat, 26 Nov 2011 07:21:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-6392013287561763608</guid><description>Since I last blogged about Denali, Microsoft has announced the official name for this version of SQL Server to be....(drum roll). SQL2012. Ok, ok. I'm pretty underwhelmed too but hey ho. Project Crescent now has the rather grand title of Power View and Juneau has the slightly less impressive Data Tools.

More exciting and interesting though are the changes to the Editions and also the licensing </description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Admin: Execute Folder of Scripts</title><link>http://richbrownesq-sqlserver.blogspot.com/2011/11/admin-execute-folder-of-scripts.html</link><category>Admin</category><category>Powershell</category><category>sqlcmd</category><category>T-SQL</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Fri, 18 Nov 2011 04:16:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-4419889605509766621</guid><description>Here's a simple powershell script to loop through a directory and execute the sql files contained within:

ADD-pssnapin SqlServerCmdletSnapin100 $ServerName = "MySERVER"&amp;nbsp;
$Db = "MyDB"&amp;nbsp;
$scriptDir = "c:\FileDir\"
$files = gci $scriptDir* -include *.sql foreach ($file IN $files)&amp;nbsp;
{Invoke-Sqlcmd -ServerInstance $ServerName -DATABASE $Db -InputFile $File}</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>SSRS: Use Stored Procedures in Datasets</title><link>http://richbrownesq-sqlserver.blogspot.com/2011/11/ssrs-use-stored-procedures-in-datasets.html</link><category>Functions</category><category>RDL</category><category>Report</category><category>Reporting Services</category><category>Reporting Services 2008</category><category>SQL</category><category>SQL Server</category><category>SSRS</category><category>Stored Procedure</category><category>T-SQL</category><category>T-SQL Tuesday</category><category>udf</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Tue, 8 Nov 2011 01:10:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-5795970666069255647</guid><description>




This is my contribution to T-SQL Tuesday #24 hosted by Brad Schulz (blog) on the subject of Prox ‘n’ Funx (Stored Procedures and Functions to you and me :-) ).

I'm a big believer in using Stored Procedures (or at the very least, UDFs) for your Reporting Services datasets. and separating your presentation layer from your data layer and moving the SQL code away from the RDL.

The benefits of </description><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSaXzesqLoH_mga_TX1mlhMKf9bqMwxkaKmqae-JQbxWI98viN-7o-aA1kAuKCELlwQ90R3PklvZEl9K8HS4uJkHgfQy4it1k5mTFAekejabfBkdb-9s1OIfxY4stWG5CHHjtfH1ULn3SE/s72-c/TSQL2sDay150x150.jpg" width="72"/><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>T-SQL: Why have NULL bit fields?</title><link>http://richbrownesq-sqlserver.blogspot.com/2011/11/t-sql-why-have-null-bit-fields.html</link><category>bit</category><category>data types</category><category>datatype</category><category>Developer</category><category>development</category><category>SQL 2008</category><category>SQL Server</category><category>T-SQL</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Thu, 3 Nov 2011 05:02:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-708367563948608464</guid><description>I was asked the question the other day, why SQL Server allows NULLs for the BIT datatype. What you need to bear in mind is what NULL represents - a value which is unknown - and, so there are 3 states which you need to cater for. True, False or Unknown. 

As is my wont, I like to explain things with analogies and this is no different. Consider a table holding job application details for a job </description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total></item><item><title>Admin: A day of "a day" series...</title><link>http://richbrownesq-sqlserver.blogspot.com/2011/10/admin-day-of-day-series.html</link><category>Admin</category><category>Bloggers</category><category>DMVs</category><category>extended events</category><category>Integration Services</category><category>Myths</category><category>SQL 2005</category><category>SQL 2008</category><category>SQL Server</category><category>SSIS</category><category>XE</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Thu, 27 Oct 2011 01:11:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-513083665643286057</guid><description>There really are some incredible bloggers out there. Despite my recent 5 day series on Continuous Integration, I typically struggle to blog more frequently than once a week. Yet these guys have committed to a whole month of blogging on a single topic and the quality of the blogs isn't diluted at all giving a real "Deep Dive" into a topic.

So here are some of the "A Day" series that i've dipped </description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Admin: Generate Restore Scripts</title><link>http://richbrownesq-sqlserver.blogspot.com/2011/10/admin-generate-restore-scripts.html</link><category>Admin</category><category>Backup</category><category>database</category><category>DR</category><category>Powershell</category><category>recovery</category><category>restore</category><category>SQL</category><category>sql agent</category><category>SQL2008</category><category>tvf</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Fri, 21 Oct 2011 00:30:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-7270738193787533646</guid><description>In order to speed up the recovery process of database (and to give the unintentional DBAs in my organsiation) a helping hand, I recently started experimenting with generating restore scripts for our production databases.

As is my wont, my technology preference was again Powershell (although it did make use of T-SQL too) as looping through databases on a server and writing to file are all pretty </description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>Denali SSIS: Loop through a list of servers</title><link>http://richbrownesq-sqlserver.blogspot.com/2011/10/denali-ssis-loop-through-list-of.html</link><category>Denali</category><category>dts</category><category>execute t-sql</category><category>for each loop</category><category>foreach loop</category><category>Integration Services</category><category>iterate</category><category>loop</category><category>package</category><category>script task</category><category>SQL</category><category>SQL Server</category><category>SSIS</category><category>Visual Studio</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Thu, 13 Oct 2011 00:42:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-4543964109063353116</guid><description>Its been tough to get any time recently to play with Denali, so I thought i'd put together a quick tutorial on SSIS using Denali to give people a tiny flavour of what it looks like. I intend (time permitting) to use this tutorial in the future to extend the package to show off a few of the new features of Denali.

Note: this task can be achieved in previous versions of SSIS with minimal changes.
</description><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgONfQyKPeeXYIZjufHU9IehMTVRxu3XWaqYz-zMmtKPPHO7kOqPAbvbKWvsJFAblfuoRdY81ouRFBqrWQ7JmGDbnIa8_RlNQV_kP9EAgc8SejIXB7KUVYhzbkbaDxIVvoWv8zN3JxbY2Ul/s72-c/Denali_SSIS_Loop_SQLSetup.JPG" width="72"/><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>T-SQL: Helping the optimiser can hinder</title><link>http://richbrownesq-sqlserver.blogspot.com/2011/10/t-sql-helping-optimiser-can-hinder.html</link><category>Developer</category><category>development</category><category>fundamentals</category><category>Joins</category><category>query plan</category><category>showplan</category><category>SQL</category><category>SQL 2008</category><category>SQL Server</category><category>T-SQL</category><category>T-SQL Tuesday</category><category>TSQL2SDay</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Tue, 4 Oct 2011 03:02:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-678262551990545015</guid><description>



I've been meaning to blog about this for a while and noticing the (earlier than usual) T-SQL Tuesday #23 hosted by Stuart Ainsworth (blog | twitter) on the topic of Joins, I thought i'd cobble something together.

Essentially, this post is about reading the results of SHOWPLAN_TEXT, being aware of the different physical join operators and also how the optimiser can be influenced (poorly) by a</description><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjl77_xJrqLi3x-HA4NQh0MIyxSMZmgrZqk8i1cGMGJVWvz520V_Wub-5iYcYQHDs_qP8Kc-3_fAdSwhuI58Ff-1zwJU8j8sC8TcHwyGfqS7cZ-8a3p15pleqq7NEYO3d_fRLJf2_un_s1d/s72-c/TSQL2sDay150x150.jpg" width="72"/><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Powershell: Out-File truncate text</title><link>http://richbrownesq-sqlserver.blogspot.com/2011/09/powershell-out-file-truncate-text.html</link><category>Admin</category><category>file</category><category>Powershell</category><category>script</category><category>SQL</category><author>noreply@blogger.com (_RichardABrown)</author><pubDate>Fri, 30 Sep 2011 00:00:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5070731366789101952.post-8342139891941401413</guid><description>I was looking to use Powershell to write out some data from a SQL table using a combination of Invoke-Sqlcmd with out-file. Everything was going nicely until my output file suddenly started having data truncated.

Something like:

Invoke-Sqlcmd -Query "SELECT LongText FROM MyTable" -ServerInstance $sql | out-file -filepath $filepath


Produced a file containing:

LongText----------------This was </description><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdC_aZABRplFgceW55r09o6UIQczjXaF6cUA3ZkRY3VlKQBiUxgeON0eH9UHt-hdrSfJTd1jlzsMLYY0GzrR45UEg5XD6TJIjnsV36jPGIyqy44IkiwGOZrQY2yf9jInvmiPCYJvtkqPB3/s72-c/PS_Properties.JPG" width="72"/><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total></item></channel></rss>