SQLServerCentral - www.sqlservercentral.com

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

Featured Contents

Featured Script

The Voice of the DBA

Happy Thanksgiving 2016

Happy Thanksgiving to everyone in the US, and Happy Thursday to everyone around the world.

It's a holiday for me and I'm not at work, but relaxing at time. Well, I might work a touch, but mostly I'll be relaxing with family. This is one of the few years we're not skiing for the holiday as there has been far too little snow in Colorado. A disaster, if you ask me.

Today is idealistically a day to give thanks for the good things in our lives. I'm very thankful that my family is all in good health, I have a wonderful job, and there is peace in my world. I hope that many of you can say the same thing yourselves.

I would also ask that you keep in mind there are others in the world that are less fortunate and if you can make a difference that helps another, please make an effort to do so.

Steve Jones from SQLServerCentral.com

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

ADVERTISEMENT

Version control
your database
changes with
SQL Source Control.

Improve team collaboration,
get a full change history, and avoid deployment problems.

Featured Contents

 

Change the Collation Setting for Clustered SQL Server 2014 Instance

Ganapathi varma Chekuri from SQLServerCentral.com

In this post I will show a procedure to change collation settings of SQL Server 2014 cluster instance. More »


 

Which Edition of SQL Server is Best for Development Work?

You might think, as a developer, that nothing but the best is good enough as a development database. You might be mistaken. There is a lot to be said for LocalDB, but Ed Elliott argues that every edition has its pros and cons, and you need to consider Cloud-based resources, VMs and Containerised databases too. There is a whole range of alternatives and how you choose depends on the type of database you are developing, but for Ed, LocalDB gets the five-star accolade. More »


 

From the SQLServerCentral Blogs - Power BI On Premises Integration with Reporting Services Preview

pturley from SQLServerCentral Blogs

Since the Reporting Services product team announced last year that it was their intention to provide an on premises deployment... More »


 

From the SQLServerCentral Blogs - Two Weeks to Live! 360 and VSLive Orlando

Steve Jones from SQLServerCentral Blogs

A short break in speaking, as I haven’t been on stage since Oct 11. Now it’s two weeks to Live! 360... More »

Question of the Day

Today's Question (by Steve Jones):

I want to find out today's day of the year for Thanksgiving. Which of these queries will work consistently on every Thanksgiving?

 -- 1 WITH tally AS ( SELECT n = ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (0)) a(n) , (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (0)) b(n) , (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (0)) c(n) ) SELECT n FROM tally WHERE DATEADD(DAY, n-1, DATEADD(yy, DATEDIFF( YEAR, 0, SYSDATETIME()), 0)) = DATEADD(day, DATEDIFF(day, 0, SYSDATETIME()), 0); -- 2 SELECT DATEPART(DAYOFYEAR, SYSDATETIME()); -- 3 WITH tally AS ( SELECT n = ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (0)) a(n) , (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (0)) b(n) , (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (0)) c(n) ) SELECT DATEADD(DAY, n-1, DATEADD(yy, DATEDIFF( YEAR, 0, SYSDATETIME()), 0)) FROM tally; -- 4 SELECT DATEDIFF( DAY, '20160101', SYSDATETIME()); 

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: T-SQL.

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

Securing SQL Server - Written by Denny Cherry, a Microsoft MVP for the SQL Server product, a Microsoft Certified Master for SQL Server 2008, and one of the biggest names in SQL Server today, Securing SQL Server, Second Edition explores the potential attack vectors someone can use to break into your SQL Server database as well as how to protect your database from these attacks. In this book, you will learn how to properly secure your database from both internal and external threats using best practices and specific tricks the author uses in his role as an independent consultant while working on some of the largest and most complex SQL Server installations in the world. This edition includes new chapters on Analysis Services, Reporting Services, and Storage Area Network Security.

Get your copy from Amazon today.

Yesterday's Question of the Day

Yesterday's Question (by Steve Jones):

What can I not do with the ALTER AVAILABILITY GROUP command?

Answer: Start a backup on another node

Explanation:

You can do many things with the ALTER AVAILABILITY GROUP command, but you cannot kick off a backup.

Ref: ALTER AVAILABILITY GROUP - https://msdn.microsoft.com/en-us/library/ff878601.aspx


» Discuss this question and answer on the forums

Featured Script

Calculate Holidays

PaladinTech

Calculate Thanksgiving, Easter Sunday, Memorial Day, and Labor Day out to 2050 by only passing in year as integer.

More »

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 2016 : SQL Server 2016 - Development and T-SQL

T-SQL formatting tool - Does anyone know of a t-sql formatting tool that is compatible with SSMS 2016 and will format BACKUP/RESTORE statements? I've got...


SQL Server 2014 : Administration - SQL Server 2014

Transaction Log File removal - I have a database with two transaction log files, I have deleted one log file using alter database remove file...

Help in understanding Security Updates - I'm a bit confused about a recent security patch application. We applied the Security Patch KB3194722, but in looking at...

Resource semaphore Query Compile and Maxdop Setting SQL 2014 - Hello, We have migrated SQL standard edition from 2008R2 to SQL 2014. After the migration we are seeing huge amount of...

Number of logical reads very different between 2 supposed identical environments - Hello, What parameters can have an impact on "number of logical reads" ? UAT and PROD environments are supposed to be the...

certificate problem for restoring a database even if no database or backup encryption - Hello, I have a problem that seems to be a bug existing in SQL 2008 R1/R2 http://support.microsoft.com/kb/2300689/en-us ). But I work on...


SQL Server 2014 : Development - SQL Server 2014

No data in one column of a view (NULL value instead - Hello, I have a table [DataXYZ].[dbo].[DataXYZ_GeoLoc_Input] with, as you can see, data for both "x" and "y" columns for year 2015: [img]http://www.cjoint.com/data/FKxqcfsonpU_XYZ-input.png[/img] I...

Too many stored procedures - Hi all, I have hundreds of SPs and I was thinking that maybe I could do a SP that runs all...

Coalesce and ISNULL not grabbing columns with NULL - I am trying to combine data from two tables. 1 table has a column where a value could be NULL....

Convert Cross Join to Inner Join - Hopefully this isn't too daunting given that I'm providing a rather lengthy piece of sample code. I understand that cross...

Query - I have a truantday table that has students who has absent, each row is one student, one truant day starting...

Inline table-valued function to list numbers - Hi everyone, I'm a newbie and recently I've come across an excercise quite complex (for me). In short, these are the...


SQL Server 2012 : SQL 2012 - General

Make Varchar the Default instead of NVarchar - When I use ETL or SELECT * INTO TableName to automatically create and populate a table, SQL Server 2102 defaults to...


SQL Server 2012 : SQL Server 2012 - T-SQL

will it call subquery for every row of table with distinct in subqyery. - hi, 1) select * from abc where abcid =(select top 1 abcid from xyz where xyzid =@xyz) 2) Select * from df...

sifting sequencing problem - hi, DROP TABLE MARBLE CREATE TABLE [dbo].MARBLE( [marbleid] [int] IDENTITY(1,1) NOT NULL, [name] [varchar](10) NULL, gluefromid int null, gluetoid int null, seqnumber...


SQL Server 2008 : SQL Server 2008 - General

Unable to complete login process due to delay in opening server connection - We have a 2008 DB, with 3 client servers all on the same subnet as the sql server. 2 machines connect...


SQL Server 2008 : T-SQL (SS2K8)

SQL query help - Hi Guys, I am working on an email alert to be sent to customers along with some information on monthly...


Data Warehousing : Integration Services

Change Detection with (44) Columns! - I am mirroring about (23) tables in another DW. I have built my first incremental loads package, for the first...


SQL Server 2005 : Business Intelligence

How do I remove zombie Business Intelligence Development Studio installed by SQL Server Express? - I am at a client where they install SQL Server Express 2008 R2 from a disk that apparently is capable...


SQL Server 2005 : SQL Server Newbies

Calling Stored Procedure issue in Excel 2013 - Hi All, I'm very new to SQL please bear with me.. I have a stored procedure that does what I expect...

This email has been sent to newsletter@newslettercollector.com. To be removed from this list, please click here.
If you have any problems leaving the list, please contact the webmaster@sqlservercentral.com.
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 ©2015 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
Contact: webmaster@sqlservercentral.com