SQLServerCentral - www.sqlservercentral.com

A community of more than 1,600,000 database professionals and growing

Featured Contents

The Voice of the DBA

How Far are You Willing To Go To Get Something?

To a certain degree this question is about commitment and stubbornness. I know a lot of technical people that are stubborn and committed. Still, how far would you go to improve or learn a new skill? How far would you go to make sure a database or a new system is production ready?

I guess at the core of this question is: what motivates us to do our best? Why do we go through one more round of testing? Why do we re-factor something again? I think part of the answer is trying to achieve perfection. It will never be attained, but we keep reaching for it. Another part is perhaps just having pride in our work and in projects that our name gets associated with. There may be issues, but they surely won’t be from our contributions. I have seen and experienced time and time again technical professionals caring enough to stay late or work on weekends to get things done.

Sometimes people will go to extremes to get things they want even outside of their jobs. I have firsthand knowledge of a fellow that wanted to get an NES Classic mini for Christmas 2016. You may or may not be familiar with the NES (Nintendo Entertainment System). The original NES came out in the 80’s. Nintendo released a NES Classic mini in the Fall of 2016 which had 30 of the classic games preloaded on it. It was released Nov. 11th  2016 and sold out immediately in the U.S. Anyway, I know this guy that wanted to get an NES Classic mini for Christmas. Now whether he wanted for his kids or for himself is not clear. He started to call stores after the release and couldn’t find a store that had any in stock. Soon he found a website that would show a certain store’s stock, but every time when he would call the store after it opened they were already sold out. He tried one time to get to the store an hour before it opened (6:00) only to find out other people got there ever earlier than him and the store was all sold out.

Finally, one cold Saturday winter morning in late December, after a six-inch snow fall (15cm), he woke up at 3:00 in the morning and decided to check the website for stock. He found that a local store had 9 units. He decided he would sleep a little and then go early to the store. After lying in bed for an hour and not being able to sleep he got up and decided to drive over to the store. He dressed warmly as the temperature out was 5F (-15C). He arrived at the store at 4:30 and found there were already three people waiting. After waiting 2.5 hours outside in the cold the store finally opened at 7:00 and he was able to buy NES Classic Mini. We can only hope it was worth it.

So what about you?Are you willing do to the work to learn something new, something you have been putting off?Share a time where you went over and above to get something done or to learn something new

Ben Kubicek from SQLServerCentral.com

Join the debate, and respond to today's editorial on the forums

ADVERTISEMENT
Foundry

Using SQL Census to audit SQL Server permissions

Redgate have just released SQL Census, a prototype tool that makes auditing SQL Server user access permissions much easier. In this post, Ally Parker shows how it works, tells us what's up next in the tool's development, and explains how you can download it for free. Try the free prototype

SQL Clone

SQL Clone: Now supporting databases up to 64TB

Create copies of production databases and SQL backups in seconds and save up to 99% of disk space using SQL Clone. Redgate’s new tool removes much of the time and resource needed to create and manage database copies, allowing teams to work on local environments to develop, test and diagnose issues faster. Try it free

Featured Contents

 

Parse Data from a Field Containing Multiple Values using CROSS APPLY

Stan Kulp from SQLServerCentral.com

It is possible for a field in a character-delimited text file to contain a list of further-delimited values instead of the customary single value. This article demonstrates how to load such a file into a staging table, then use a CROSS APPLY query to parse the list of values into a related table. More »


 

Templates and Snippets in SSMS and SQL Prompt

Phil Factor provides an overview and comparison of SSMS templates, SSMS snippets, and SQL Prompt snippets. More »


 

Backup SQL Server Databases in Parallel with PowerShell

Additional Articles from MSSQLTips.com

I have a need to decrease the time my SQL Server database backups are taking to run. I thought about trying to run multiple backups at the same time to see if that would work. I could have created multiple SQL Server Agent Jobs to run at the same time, but I wanted a more dynamic way to handle this, so I created a PowerShell script that allows processes to run in parallel. More »


 

From the SQLServerCentral Blogs - Don’t “Test” Against Production

Brian Kelley from SQLServerCentral Blogs

A few months ago, I was participating in a threat hunting exercise on the security side. The gentleman leading the... More »


 

From the SQLServerCentral Blogs - Redgate at Summit 2017

Steve Jones from SQLServerCentral Blogs

I’ll be heading out to the PASS Summit next week, spending Halloween in a conference center with a lot of... More »

Question of the Day

Today's Question (by Steve Jones):

I run this code:

 SELECT EOMONTH('20170928', 3)

What date is returned?

Think you know the answer? Click here, and find out if you are right.


We keep track of your score to give you bragging rights against your peers.
This question is worth 1 point in this category: EOMONTH().

We'd love to give you credit for your own question and answer.
To submit a QOTD, simply log in to the Contribution Center.

ADVERTISEMENT

T-SQL Querying (Developer Reference)

Squeeze maximum performance and efficiency from every T-SQL query you write or tune. Four leading experts take an in-depth look at T-SQL’s internal architecture and offer advanced practical techniques for optimizing response time and resource usage. Get your copy from Amazon today.

Yesterday's Question of the Day

Yesterday's Question (by Steve Jones):

There's a table of my sales in our database, and I've not been having a great month. In fact, since the first week, I've been struggling:

 CREATE TABLE MySales ( SaleDate DATETIME , SaleAmount MONEY ) INSERT MySales (SaleDate, SaleAmount) VALUES ('20171002 9:00am', 2000), ('20171002 10:00am', 1000), ('20171003 2:00pm', 1200), ('20171004 4:59pm', 1800) GO 

We also have a procedure that will return my sales up to a given date. By default, this will get data for up to the current datetime.

 CREATE OR ALTER PROCEDURE GetMyReport @dt DATE = NULL AS SELECT IsNull = 'Isnull' , ms.SaleDate , ms.SaleAmount FROM dbo.MySales AS ms WHERE saledate <= ISNULL(@dt, GETDATE()) ; GO 

I made a great sale today (Oct 27), at 10:00am

 INSERT dbo.MySales (SaleDate, SaleAmount) VALUES (GETDATE(), 25000) 

I ran to my boss' office, and she ran:

 EXEC GetMyReport ; 

The results were disappointing. Why?

 IsNull SaleDate SaleAmount ------ ----------------------- --------------------- Isnull 2017-10-02 09:00:00.000 2000.00 Isnull 2017-10-02 10:00:00.000 1000.00 Isnull 2017-10-03 14:00:00.000 1200.00 Isnull 2017-10-04 16:59:00.000 1800.00 

Answer: The ISNULL returned 2017-10-27 at midnight.

Explanation:

This is an interesting puzzle. All the data is in the table, and if you run the inserts, you will see that. 

When the procedure is called with no parameter, the @dt is given a null value. When the query runs, the ISNULL() will return getdate() since @dt is null, however, this is cast to the date datatype. This means that value will be 2017-10-27 as a date only. My sale is at 10am, which is greater than midnight.

Ref: COALESCE - https://docs.microsoft.com/en-us/sql/t-sql/language-elements/coalesce-transact-sql

Idea from: A Subtle Difference Between ISNULL and COALESCA - click here


» Discuss this question and answer on the forums

Database Pros Who Need Your Help

Here's a few of the new posts today on the forums. To see more, visit the forums.

SQL Server 2017 : SQL Server 2017 - Development

StartDate and EndDate in same column - I have a date column below RunDate , I want to create two column StartDate and EndDate like this StartDate = '2004-08-01' ...


SQL Server 2014 : Administration - SQL Server 2014

Extended Events - sqlserver.query_memory_grant_usage - Hello Folks. Bit of a strange one - or else I am missing something here (high probability). I found some sample code to...


SQL Server 2014 : Development - SQL Server 2014

Trying to speed up this 'GetWorkingDays' function. - I'm trying to redesign one of our working days functions. The idea is to calculate weekends (easy enough) but holidays...


SQL Server 2012 : SQL 2012 - General

Where should I save stored procedures and user defined functions for use in all databases? - I have some generic utility stored procedures and user defined functions that I would like to define/save once, and have...

Transport error encountered when SOME queries run with batch terminator. Behaviour changes depending on text of query. WEIRD! - This is one of the weirdest issues I've ever seen. It's so unbelievable that I actually made a video to...


SQL Server 2012 : SQL Server 2012 - T-SQL

Extra Statistics - I have a table with 50 columns, 15 indexes and 100+ statistics.  I thought statistics were for indexes.  I can't...


SQL Server 2008 : SQL Server 2008 - General

SQL versus program - Hi all, I'm posting my question in this 2008 forum because we're running SQLServer 2008R2, but it is more a general...


SQL Server 2005 : T-SQL (SS2K5)

parsing variable into @query using sp_send_dbmail - Hi, I have a stored procedure that users sp_send_dbmail and i'm trying to pass through a variable to @query using sp_send_dbmail....

This email has been sent to [email protected]. To be removed from this list, please click here.
If you have any problems leaving the list, please contact the [email protected].
This newsletter was sent to you because you signed up at SQLServerCentral.com.
Feel free to forward this to any colleagues that you think might be interested.
If you have received this email from a colleague, you can register to receive it here.
This transmission is ©2017 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
Contact: [email protected]