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

Archaic Commands

I was watching the San Diego Technology Immersion Group meeting in September, and found myself transported back into the past. This month was the first meeting of the Linux chapter, spending a few months working through The Linux Command Line.

Watching from home, I watched the hosts walking through the command line in Linux, showcasing various basic file comments. Seeing them explain and execute commands like ls, rm, alias, cat, tail, less, and other commands in a text session reminded me of learning Unix at university on SunOS. Slowly various bits of knowledge came back to me from my own experiments learning how to work with files, full of text data, interspaced with my regular visits to the "man" pages when something didn't work. In fact, seeing the man pages come up on the YouTube session made me smile.

It's funny to think how much the world has changed. Even now, I have an Ubuntu VM that I run at times, but it's mostly a GUI shell, and my interactions with the command line are fairly minimal. That's completely the opposite of my time at university and my first job where I pretty much lived in the command line. My code editors were vi and emacs that I ran across a dozen X Windows sessions open on various machines in the college computer lab. My interactions were really working with text and text commands. Even now, I might use SSMS and Visual Studio, but I'll pop into a command line to check my git repo or spend time playing with PowerShell and executing commands in text sessions. While working with Python I'm as likely to use the REPL from a command window as I am to use an editor like VS or PyCharm. I really just like the interaction of the command line.

Not everyone feels that way, and that's fine. I agree that GUI based systems are more convenient at times. In fact, I often use various GUI items in SSMS build up a task, such as an Extended Events session, and then script the result to give me code that I can execute. GUIs do some things extremely well, but allowing for repeatability is not one of them. They can also easily hide the actual commands and defaults being executed.

I think everyone working in technology needs to have some skill in working with a command line. Even if you want to use T-SQL to script all your tasks, you should be familiar enough with something like SQLCMD to execute a script in case you run into a situation where SSMS might not work. This might be especially true as you learn to automate more of the work your systems require and perhaps execute these scripts through other tools, like an Enterprise scheduler.

If nothing else, the command line teaches you how to work in a methodical, step by step process. However, I'd argue it develops new skills that might lead you to do solve a problem in more creative ways. Perhaps you'll even grow to use a command line language like PowerShell to accomplish some repeatable task. You might find it works better than the old way you used to work.

Steve Jones from SQLServerCentral.com

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


The Voice of the DBA Podcast

Listen to the MP3 Audio ( 4.1MB) podcast or subscribe to the feed at iTunes and Libsyn. feed

The Voice of the DBA podcast features music by Everyday Jones. No relation, but I stumbled on to them and really like the music.

ADVERTISEMENT

Compare
& deploy
SQL Server
schemas
fast.

Featured Contents

 

Time Traveling with Temporal Tables on SQL Server 2016

Johan Åhlén from SQLServerCentral.com

One of the new features of SQL Server 2016 is the ability to time travel in your databases and visit a specific table at a specific point of time in history. You can also use this feature to audit changes or “undo” whole data warehouse updates. More »


 

Automatically upload SQL Server Database Backups to Azure with Integration Services

Additional Articles from MSSQLTips.com

Daniel Calbimonte shows how the Feature pack in SQL Server Integration Services can connect to Azure to automatically copy your SQL Server database backups. More »


 

Developing Redgate’s SQL Toolbelt

Additional Articles from Redgate

Take a look behind the scenes to learn more about Redgate’s development challenges, what role the SQL Toolbelt plays, and which releases are coming up. More »


 

Free Webinar: Redgate DLM Demo

Learn how to use Redgate’s DLM solution to improve your database change management process in our free webinar on October 18th. Microsoft Data Platform MVPs, Steve Jones, and Grant Fritchey, will demonstrate how Redgate’s tools plug into Git, Jenkins & Octopus Deploy so that you can build, test and deploy your database alongside your application code. Register now. More »


 

From the SQLServerCentral Blogs - Power BI Custom Visuals Class (Module 20 – Word Cloud)

Devin Knight from SQLServerCentral Blogs

In this module you will learn how to use the Word Cloud Power BI Custom Visual.  The Word Cloud is... More »


 

From the SQLServerCentral Blogs - Thursday Night Networking Dinner Meetup at Summit 2016

Steve Jones from SQLServerCentral Blogs

This year PASS announced that Thursday night would be an open night at the PASS Summit, with no events scheduled.... More »

Question of the Day

Today's Question (by Steve Jones):

I live in the Mountain time zone and I have this batch of code executed at 1:24:02.313pm on October 1, 2016:

 SELECT GETDATE() at TIME ZONE 'UTC'

On a SQL Server 2016 instance, what time should be 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 2 points in this category: Datetime conversions.

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

Power Query for Power BI and Excel

Power Query for Power BI and Excel is a book for people who are tired of copying and pasting data into Excel worksheets. Power Query, part of the Microsoft Power BI suite, is a tool that automates the process of getting data into Excel and will save you hours of dull, repetitive, and error-prone work! Power Query makes it easy to extract data from many different data sources, filter that data, aggregate it, clean it and perform calculations on it, finally loading that data into either your worksheet. Get your copy from Amazon today.

Yesterday's Question of the Day

Yesterday's Question (by Steve Jones):

I've got these queries. Which of these will work for my insert statement? 

 -- query 1 INSERT dbo.Employee ( id, name, salary ) VALUES ( 4 -- id - int , 'Kendall' -- name - varchar(200) , 12 -- salary - numeric(10, 4) ) -- query 2 INSERT dbo.Employee ( id, name, salary ) VALUES ( 4 -- id - int , (SELECT firstname + ' ' + lastname FROM dbo.Employees WHERE EmployeeID = 3) , 12 -- salary - numeric(10, 4) ) -- query 3 INSERT dbo.Employee ( id, name, salary ) VALUES ( SELECT EmployeeID , firstname + ' ' + lastname , salary FROM dbo.Employees WHERE EmployeeID = 3 ) -- query 4 INSERT dbo.Employee ( id, name, salary ) VALUES ( (SELECT EmployeeID , firstname + ' ' + lastname , salary FROM dbo.Employees WHERE EmployeeID = 3 ) ) -- query 5 INSERT dbo.Employee ( id, name, salary ) VALUES ( (SELECT EmployeeID FROM dbo.Employees WHERE EmployeeID = 3) , (SELECT firstname + ' ' + lastname FROM dbo.Employees WHERE EmployeeID = 3) , (SELECT salary FROM dbo.Employees WHERE EmployeeID = 3) ) 

Answer: 1, 2, and 5

Explanation:

The Table Value Constructor has a few rules, one of which is that a subquery cannot contain multiple columns. Each row value constructor would need multiple subqueries to fill out the row. 

Query 1 has scalar values and works fine.

Query 2 uses a subquery with one column returned for the second vlaue, and this works fine.

Query 3 has multiple columns returns and fails.

Query 4 has multiple columns returns and fails.

Query 5 returns a scalar value for each column, and that is a valid statement.

Ref: Table Value Constructor - https://msdn.microsoft.com/en-us/library/dd776382.aspx


» Discuss this question and answer on the forums

Featured Script

Copy Backup Files to Remote Shared Location and Delete them periodically

S M from SQLServerCentral.com

Copy the script in SSMS

Change the PAth to the variable : @chkdirectory

Run it.

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 - Administration

SSRS 2016 Brand for manager portal - I read the article https://www.mssqltips.com/sqlservertip/4483/customize-sql-server-reporting-services-reports-manager-portal/ for SSRS 2016 brand, I think which is a good feature. But I could not find the...

DBCC CHECKDB error - Hi, I am getting the following error when i run DBCC CHECKDB on my database. Msg 7928, Level 16, State 1,...


SQL Server 2016 : SQL Server 2016 - Development and T-SQL

lookup value for each row - I have a table with currencies, and a table where each day the exchange rates for those currencies are downloaded....

How to get full name of the employer by getting rid of null values in between - HI, I have a table name EmployeeNames ID, FirstName, MiddleName, LastName 1, Sam, NULL, NULL 2, NULL, Todd, Tanzan 3, NULL, NULL, Sara 4, Ben, Parker, NULL 5, James, Paul, ...


SQL Server 2014 : Administration - SQL Server 2014

Differential backup too big - Since two weeks, my differential backups are getting too big. I have a 4 TB database. Our backup schedule: full...

Blocking by Insert - Found the below query causing blocking from different SPID. declare @0 bigint,@1 bigint,@2 varchar(50),@3 bit,@4 varchar(50),@5 datetime2(7),@6 varchar(50),@7 datetime2(7) INSERT [dbo].[Transaction] ([TransactionId], [ConId],...

finding the current ID value compared to the IDENTITY value - Hi I need to find the current identity value compared to the current column value of tables with identity fields - in...

Displaying Multiple rows clock event Under a different Column view - I would like to query the data were table output is by each row but i need need display the...

SSRS 2014 just randomly slow response for a while - I have 6xSSRS 2014 servers running same set of reports. All reports point to the same SQL Server 2008 Database....


SQL Server 2014 : Development - SQL Server 2014

Display Live clock event - Hi Experts, I need to solve below two issues in my SQL query, 1. query should not show any duplicate clock event(ex: if...

Dynamically checking for columns and update - Hi All, I have to update target table and I am good with below logic. MERGE testdb.dbo.targettable r using dbo.sourcetable s on...


SQL Server 2008 : SQL Server 2008 - General

With recompile in the master stored proc - Dear all, If I have a procedure like: sp_1 (@par1, @par2) AS begin exec sp2 exec sp3 end if I add the expression "with recompile" on the master...

Sql Send_Db_mail Vertical Table - Hi guys, Sorry about my english.... I have this code below to send a mail with send_db_mail. DECLARE @Body NVARCHAR(MAX), @TableHead VARCHAR(1000), @TableTail...

Split String On Delimiter - I've a string as follows: 45 | 00055 | 9/30/2016 | Vodafone | Jack Morris | Newyork | Test Msg | TBL101 | PC | 1.00 | COMP101 | CS | 1.00.............. etc I...


SQL Server 2008 : T-SQL (SS2K8)

Using SP in UDF - I am trying to create a function that will generate a random datetime value. Due to being unable to use...


SQL Server 2008 : Security (SS2K8)

grant execute overrides user permissions - Hi. It looks like granting a user permission to execute a proc overrides that user's insert/update/delete permissions they'd otherwise have...


Reporting Services : Reporting Services

Can I allow a user to select nothing a multi-valued parm? - We have a report where a user can search for persons. One of the parameters allows the user to select which...


Reporting Services : SSRS 2014

User does not have required permissions. Verify that sufficient permissions have been granted and Windows User Account Control (UAC) restrictions have been addressed. - Can somebody assist me please? I tried to correct this error with no luck!(please see https://connect.microsoft.com/SQLServer/feedback/details/622737/user-does-not-have-required-permissions-verify-that-sufficient-permissions-have-been-granted-and-windows-user-account-control-uac-restrictions-have-been-addressed) Please explain to me what "Folder...


Data Warehousing : Integration Services

Environment variables set up - I have created a project parameters at my solution level and after i deploy the solution to the server ,at...


SQL Server 2005 : SQL Server 2005 Integration Services

Execute Process Task - The process exit code was "2" while the expected was "0" - I have an SSIS that includes an Execute Process Task. The task has the executable, arguments, and working directory properties...

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