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

Byte Me: Entrepreneurial

Bob Lang from SQLServerCentral.com

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

ADVERTISEMENT
SQL Prompt

Free webinar: dealing with SQL Server asset management

In this interactive session on Thursday May 4, Microsoft Data Platform MVP Steve Jones joins the Redgate Foundry team to lead a group discussion on strategies for discovering the full extent of your estate, mitigating security risks, ensuring consistent server configurations, and incident response and prevention. Register now.

SQL Clone

NEW SQL Clone - version 1 available now!

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

 

Stairway to DAX and Power BI - Level 7: Function / Iterator Function Pairs: The DAX AVERAGE() and AVERAGEX() Functions

Bill Pearson from SQLServerCentral.com

Business Intelligence architect, Analysis Services Maestro, and author Bill Pearson explores the DAX AVERAGE() and AVERAGEX() functions, comparing and contrasting the two. He then provides some hands-on exposure to the use of each, particularly in combination with other DAX functions, in generating arithmetic means within our PowerPivot model designs. More »


 

Build Dynamic Backup Locations with Minion Backup

Sean McCown from Minionware

See how Minionware Backup gives you the ability to customize backup files and locations. More »


 

Free eBook: SQL Server Execution Plans, Second Edition

Press Release from Redgate

Every day, out in the various online forums devoted to SQL Server, and on Twitter, the same types of questions come up repeatedly: Why is this query running slowly? Why is SQL Server ignoring my index? Why does this query run quickly sometimes and slowly at others? My response is the same in each case: have you looked at the execution plan? More »


 

Why is my clone so small?

Additional Articles from Redgate

Using very few megabytes and taking very little time, SQL Clone can quickly creates multiple copies of very large databases. How? It might sound like magic, but it's not; in this blog post Redgate developer Chris Hurley goes into the details of how the technology works. More »


 

From the SQLServerCentral Blogs - The Birthday Problem – with T-SQL and R

Mala Mahadevan from SQLServerCentral Blogs

When I was on SQLCruise recently – Buck Woody (b|t) made a interesting statement – that in a room of 23 people,... More »


 

From the SQLServerCentral Blogs - SQL PowerShell 2017 IS HERE!

Aaron Nelson from SQLServerCentral Blogs

Cue Princess Jasmine. What do I mean “Cue Princess Jasmine”? Well because starting today, it’s a “Whole New World for You & Me” What... More »

Question of the Day

Today's Question (by Stanley Kapfunde):

Which of the following is NOT a Data Manipulation Language keyword?

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: data.

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

Exam Ref 70-761 Querying Data with Transact-SQL

Prepare for Microsoft Exam 70-761–and help demonstrate your real-world mastery of SQL Server 2016 Transact-SQL data management, queries, and database programming. Designed for experienced IT professionals ready to advance their status, Exam Ref focuses on the critical-thinking and decision-making acumen needed for success at the MCSA level. Get your copy from Amazon today.

Yesterday's Question of the Day

Yesterday's Question (by Carlo Romagnano):

What are the values returned by this query? (they could be in any order)

 USE tempdb CREATE TABLE MyStuff(t varchar(100)) INSERT INTO MyStuff SELECT * FROM ( VALUES ('a') ,('aa') ,('aaa') ) AS V([t]) SELECT STUFF(t,2,0,CASE WHEN LEN(t) <= 2 THEN 'b' ELSE NULL END) AS Result FROM MyStuff DROP TABLE MyStuff 

Answer: NULL,aba,aaa

Explanation:
 STUFF ( character_expression , start , length , replaceWith_expression ) 

STUFF - click here

start
If start is longer than the first character_expression, a null string is returned.

replaceWith_expression
Is an expression of character data. character_expression can be a constant, variable, or column of either character or binary data. This expression will replace length characters of character_expression beginning at start.
If expression is NULL, zero length data is inserted.

Row with 'a' is too short, so it returns NULL

Row with 'aa' become 'aba'

Row with 'aaa', because of CASE clause returns NULL as replaceWith_expression, is unchanged 'aaa'

Result:

NULL,aba,aaa.


» Discuss this question and answer on the forums

Featured Script

Fix Orphan Users for All databases - Fixed Collation Problem

Sivakumar Mohan from SQLServerCentral.com

Most comman scenario which we face on everyday basis is to fix the orphan database users at the database level. You need to go to each database and fix the orphan users at the each databases.
If you have hunderds of databases in the enterprise level environment , it is very hard to do that. I wrote the script
Thanks to the previous contributor SM who have wrote the orphan users script. I made modification to the scripts to go into each database and check the orphan users.
Thanks Prem Kumar

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

Slow Full Text Search on New Server - Got a new SQL Server, running SQL 2016 on Windows Server 2016. This VMWare at our hosting site. Server properties show...

Append json value - Hi all, I have json like this DECLARE @j NVARCHAR(max) = N'' i want to add  "size"="1000" to this array SET @j = JSON_MODIFY(@j,'append...

Export data in XML to import into Word - Hi Folks, I am building a one-click application to export information from SQL Server 2016 in XML format that will be...


SQL Server 2014 : Administration - SQL Server 2014

The permissions granted to user 'domain\abc' are insufficient for performing this operation. (rsAccessDenied) - ok, so I know there are tons of forums on this,but none are helping. I'm using SQL server 2014 and...

Deadlock with two update statements - Hi Guys, I am getting a deadlocks recently on one of my instance of SQL Server. Below are the two statements...


SQL Server 2012 : SQL 2012 - General

Invalid length paramter passed to substring function - hen I ran this query I am facing this error. Any advice please select

SQL help - help me write the SQL stmt - create table #t( admdt datetime, dischdt datetime, ID int ); INSERT INTO #t(admdt, dischdt,ID) VALUES ( GETDATE()-100, NULL,1 ); INSERT INTO #t(admdt, dischdt,ID)...

Table Changes - Does anyone know how to query changes made to any tables/rows made in a SQL database?


SQL Server 2012 : SQL Server 2012 - T-SQL

CASE, CONVERT NULL to 'Unknown' in a column with a datatype of int. - Hello, I have a column, and the data type is int, but there are some NULL's in there, and as I...

Is there a best way to combine data into a single output field - I need to create output that takes a list of names and combines them into one field. Here is an...

Do you need an order by when selecting TOP N from a clustered index? - Lets say you have a table with 2 columns, the first, an identity primary key column, the second a foreign...


SQL Server 2008 : SQL Server 2008 - General

Why is this user able to work even when the login doesn't exist? - I'm trying to figure out how permissions issues with SQL Server. I've added an Active Directory group to a SQL...

Federal Holiday Function - Thought this might be helpful. I've written a T-SQL function that returns a federal holiday name based on an input...


SQL Server 2008 : T-SQL (SS2K8)

Query for status - Hi guys, I am working on a requirement where I am not finding any efficient way to get the desired...


SQL Server 2008 : SQL Server 2008 Administration

Procedure Doing Only Select - I have a complex procedure having multiple case statements which only select data from multiple table. But when i ran...

Deleting .bak files - Greetings. I am using SQL Server 2008 R2 Express. I want to delete some old backup files, but I am...


Reporting Services : Reporting Services

Sharepoint Reporting services extentions not loading - Hi All, We have an issue with a development sharepoint server and reporting services addin. We tried adding the SQL 2016 add-in...


Reporting Services : SSRS 2012

Downgrade report from 2016 to 2012? - Is it possible to downgrade a report from SSRS 2016 to 2012?   There are a series of reports that were...


Data Warehousing : Integration Services

Visual Studio 2017 - SSDT - Hi, I'm hoping someone can tell me that I'm mistaken and have missed something but I've installed Visual Studio Professional 2017...


SQL Server 2005 : SQL Server 2005 Integration Services

Change column order in Flat File Destination - Hi there, I have several Flat File destinations and I need to change the output column order in each. I've opened...

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 ©2017 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
Contact: webmaster@sqlservercentral.com