Problems displaying this newsletter? View online.
SQL Server Central
Featured Contents
Question of the Day
The Voice of the DBA
 

Daily Coping Tip

Ask yourself, will this still matter a year from now?

I also have a thread at SQLServerCentral dealing with coping mechanisms and resources. Feel free to participate.

For many of you out there working in a new way, I'm including a thought of the day on how to cope in this challenging time from The Action for Happiness Coping Calendar. My items will be on my blog, feel free to share yours.

The Spookiest Year

Last Halloween I was in Chicago, in one of the biggest cities in the US visiting a customer. This was near the end of a very busy travel year, where I'd been to England 5 times, Australia twice, and was returning home for the weekend before heading back out on a trip to Seattle for the 2019 PASS Summit.

This year I expected more of the same, even into early February, before the COVID-19 pandemic hit the world. Since then, much of the world has changed, certainly travel, conferences, SQL Saturdays, and most other types of gatherings have changed. Not just work events, but work itself, with many of us, perhaps most, working from come. Concerts, comedy, sporting events, and more have been cancelled or changed to taking place without spectators. While some things are starting to come back, they've forever changed.

I have started coaching volleyball again, and while we've started competition, we do so without spectators, which is a very strange experience. As I sat between matches recently, my wife and I noticed how quiet it was and how calm. In a good way, but also a strange feeling for us.

Perhaps one of the strangest things is watching media more than in the past, and seeing people without masks, in crowds, living life in a way that I assumed would always exist a year ago. It's certainly jarring, and I wonder to what extent we'll return to that world in the future.

Tomorrow is Halloween, and while it's not an event I'll participate in, I'll think about the spooky feeling of this entire year, where nothing seems to have gone in the way I'd have expected. I hope that does change in 2021, but for now, I'm assuming we have at least seven more months, through at least April of 2021, living in the same world. Hopefully, I'm wrong.

Steve Jones - SSC Editor

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

 
 Featured Contents

Efficiently Polling Remote Data Sources

Additional Articles from SimpleTalk

In this article, Edward Pollack describes some of the issues when querying against remote data sources. He covers remote SQL Servers and also connecting to a PostgreSQL database.

Format your own SQL code using this free online formatter

Additional Articles from Redgate

Redgate have launched their very own Online SQL Formatter powered by SQL Prompt. Visit the page here to try formatting your SQL code with a few pre-defined styles, or find out how to create and share your own styles with SQL Prompt.

From the SQL Server Central Blogs - Power BI Monthly Digest – October 2020

Devin Knight from Devin Knight

In this month’s Power BI Digest Matt and I will again guide you through some of the latest and greatest Power BI updates this month.

From the SQL Server Central Blogs - Welcome to 3Cloud …

Steve Hughes from DataOnWheels

A little over a month ago, Pragmatic Works Consulting was a part of a merger that included 3Cloud and Applied Cloud Services over a period of a few months....

 

 Question of the Day

Today's question (by Steve Jones - SSC Editor):

 

The Best Query

I have a table full of various candies.
CREATE TABLE Candy
( CandyName VARCHAR(100)
, CountryName VARCHAR(50)
)
GO
INSERT dbo.Candy (CandyName, CountryName) 
VALUES 
 ('Meiji Kinoko no Yama', 'Japan'),
 ('Shokolad Para Pitzputzim', 'Israel'),
 ('Guayabitas', 'Costa Rica'),
 ('Caramello koalas', 'Australia'),
 ('Marabou Mjolkchoklad', 'Sweden'),
 ('Ptasie Mleczko', 'Poland'),
 ('Coffee Crisp', 'Canada'),
 ('Saft Goldbären', 'Germany'),
 ('Nestle Damak', 'Turkey'),
 ('Indy Dedos', 'Mexico'),
 ('Fazer''s Marianne', 'Finland'),
 ('Pascal Pineapple Lumps', 'New Zealand'),
 ('Percy Pig gummies', 'United Kingdom'),
 ('Salmiakki', 'Denmark'),
 ('Dorina Riža', 'Croatia'),
 ('Strawberry Kiss Yupi', 'Indonesia'),
 ('Regina', 'Portugal'),
 ('Mozart Kugeln', 'Austria'),
 ('ION', 'Greece'),
 ('Kinder Bueno', 'Italy')
GO
I have another table for pranks.
CREATE TABLE Prank
(PrankName VARCHAR(200))
GO
INSERT dbo.Prank (PrankName) 
VALUES 
 ('Give out a burger that looks like a cupcake'),
 ('Gift wrap a rock'),
 ('Shoot silly string'),
 ('Play recording of dog attacking the door'),
 ('Drop balloons from upper window'),
 ('Give out resume paper and pens'),
 ('Drop slime into their hand'),
 ('Turn out all lights')
 GO
I run this code to decide whether to give out a trick or treat to each person that comes to my door. How many people can I serve on Halloween night?
SELECT         CASE
                   WHEN RAND(CHECKSUM(NEWID())) > .5 THEN
                       c.CandyName
                   ELSE
                       p.PrankName
               END
FROM
               dbo.Candy AS c
    CROSS JOIN dbo.Prank AS p;

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

 

 

 Yesterday's Question of the Day (by Steve Jones - SSC Editor)

Funny code

I have this code in a script file that someone gave me at work.

DECLARE @List TABLE
(Number INT);
DECLARE @number INTEGER = 1234;
DECLARE @strNumber VARCHAR(8);
WHILE NOT EXISTS
              (SELECT * FROM @List WHERE Number = @Number)
BEGIN
    INSERT INTO @List (Number) VALUES (@Number);
    SET @strNumber = @Number * @Number;
    SET @strNumber
        = SUBSTRING(RIGHT('00000000' + @strNumber, 8), 3, 4);
    SET @number = @strNumber;
END;
SELECT * FROM @List;

What does this produce?

Answer: A pseudo random list of numbers between 0 and 9999

Explanation: This produces a pseudo random set of numbers between 0 and 9999. The seed value is 1234, and this can be changed to change the sequence. Ref: Random Thoughts - https://www.sqlservercentral.com/articles/random-thoughts

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 2016 - Administration
Moving DB file - I have Always ON setup between Server_A and Server_B (Primary server is Server_A and DR server is Server_B) I have DB called ManagementDB which has 3 Data file 2 on D drive and 1 on C drive. I need to moved Data file from C to d Drive. Since it has Always on Setup I […]
Read-only error in Primary AG replica, but the db is not read-only - Hello experts, I am trying to add db permissions (read/write) on the primary replica of an AOAG setup. For some reason I am getting this error: Failed to update database "MyDB" because the database is read-only. (Microsoft SQL Server, Error: 3906) I checked the MyDB options and Database Read-Only is set to False. Does anyone […]
identify sql backup strategies - how do I identify if the dbs are getting backed up (full,diff,log) without looking through sqljobs /maintenance plans etc..as they maybe getting backed up from a 3rd party tool. Any tables I can look through  
schedule a job in CMS - Is it possible to schedule a sql job in CMS ? As of now I have a query which captures data from all servers listed in CMS, but its is a manual process. Can I schedule it against multiple servers and capture that data and dump that data into  a single server/db/table.(Without using powershell or  […]
SQL Server 2016 - Development and T-SQL
Trying to get a arithmetic operation from an Variable - Hi, I am not sure if this can be done, but I seem to remember there is some format thing that can be done with quates. Thant would pull out the value so that I can use it in something like this: Declare @dd Varchar(2) = '<' SELECT *FROM SalesWhere [sale_id] + @dd + 2 […]
Dividing data equally in 4 sessions - Hi All I have a table which contains the transactions done by cards. Below is the table structure and sample data: create table CardTransactions(CardNo int, Transactionid int, Processed bit) Insert into CardTransactions values(1,1001,0) Insert into CardTransactions values(1,1002,0) Insert into CardTransactions values(1,1003,0) Insert into CardTransactions values(1,1004,0) Insert into CardTransactions values(1,1005,0) Insert into CardTransactions values(2,1006,0) Insert into […]
Unique value constraint among active records - I have a lookup table that implements a system-generated Id for DRI purposes.  The lookup table has columns defining the effective and obsolete dates of the record i.e. the period during which a lookup term is valid for business use.  Normally I would create a unique index on the lookup term to ensure that it […]
Development - SQL Server 2014
what does it mean for the following SQL Scripts - in a stored procedure, I found two line sql scripts "    if @@microsoftversion > 0x07320000 exec sp_MSreplraiserror 20598 " ,  what does it  "@@microsoftversion > 0x07320000"  and    "exec sp_MSreplraiserror 20598 " ? and when executing this "exec sp_MSreplraiserror 20598 ", what will be done by SQL Server ?   thanks so much!
SQL 2012 - General
'xp_sqlagent_notify' error on job run - Recently, our corporate office forced us to downgrade some non-prod servers from enterprise edition to dev (don't ask, long story). We did so, but now our QA team is having some problems running jobs on the servers. More specifically, a job set up by a vendor to backup & restore a database from server A […]
SQL Server 2012 - T-SQL
leave entitlement and balance - Hi all I need your advise for the below case: I’ve a leave request system that users request leaves through it and it differentiate between working days, weekends  & holidays means it counts only the working days I’ve already two tables one for employees data like (name number title dept.) and the other table for […]
SQL Server 2019 - Administration
Migration step-by-step from SQL Server 2014 to 2019 - We are going to migrate all our SQL Servers from 2014 to 2019. Where I can find step-by-step guide before, during, and after migration? Besides Database Migration Assistant, I could not find any. We have 80+ databases, BLOB images, using AlwaysOn, replication, SSIS packages, SSRS reports, some 3rd-party tools. We will use backup/restore methodology, but […]
SQL Server 2019 - Development
Textfield comparator. - A client would like to be able to recognize similar free-texts in a text field. So based on a field find similar texts in the same column. Result could be something like a percentual equalness. Could anybody point me towards a SQL-server geared solution. Or "search words" for Google for this. The free-texts are recipe […]
Other methods of getting the true length of UTF8 String? - Something I've been playing around with lately is the UTF8 functionality in 2019, and it dawned on me that getting the "true" length a string in a UTF8 string is actually not as easy as for a "normal" varchar (and nvarchar). Let's take the following table: CREATE TABLE dbo.TestTable (VarcharString varchar(30) COLLATE Latin1_General_100_CI_AS, NvarcharString nvarchar(30) […]
Integration Services
SSIS projects connection manager driver - Hi I am starting using the project deployment mode. I am using SQL server 2019 And I see when I add a connection in connection manager for a package, I cannot see the sql server native client driver any more. What connection manager type do you recommend for SQL server connections?   Thanks
Hardware
Are there any free resources/ebooks to develop database design and modeling ? -   I want to develop my skills in database design and modeling. I found out some books like "The data model resource book revised edition volume 1". But they are not free. Are there any books to learn these skills.    
 

 

RSS FeedTwitter

This email has been sent to {email}. 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.
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
webmaster@sqlservercentral.com

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -