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

Embrace Stored Procedures

This editorial was originally published on Apr 20, 2015. It is being republished as Steve is on vacation.

I've read a lot of pieces on stored procedures. Most of the articles were for using stored procedures, quite a few were against their use, and a handful with extreme opinions. This piece from Rob Conery, while perhaps NSFW, is one of the latest, and more entertaining, pieces I've read that discusses the value stored procedures bring to an application.

For the most part I agree with the presentation, though not completely. It's an interesting discussion about business logic v data logic, and while I do think that some logic isn't really central to your business, there are ways you manipulate data that might be necessary in multiple parts of your business. Those manipulations might make more sense in the database as a stored procedure rather than trying to ensure every application implements (and updates) the logic in its own code.

I do like Mr. Conery pointing out the fact that ORMs or custom applications might be extremely wasteful in implementing a process with multiple calls, and stored procedures handle these functions more efficiently. We have fast networks and powerful hardware, but those calls do add up, especially if your system gets popular and has lots of users.

Ultimately I think the last sentence sums things up nicely: let's wake up to the power of our relational systems. That's something that developers should embrace. Why only use half the power of a tool you have? I do think the judgment of how much business logic to include in the database is worth debating, but not at an application by application basis. Think about whether each call, page, form, whatever makes sense as having the programming in the front end or the back end. Whatever you decide, you should be able to explain and justify your choice to the others you work with.

Steve Jones from SQLServerCentral.com

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

ADVERTISEMENT
Database DevOps

Continuous Delivery for SQL Server Databases

Spend less time managing deployment pain and more time adding value. Find out how with database DevOps

SQL Monitor

What’s the top challenge faced by SQL Server professionals in 2018?

Learn how 626 SQL Server professionals monitor their estates in our new report on the State of SQL Server Monitoring. Discover the challenges currently facing the industry, and what is coming next.  Download your free copy of the report

Featured Contents

 

Your SQL Servers Are Misconfigured...

Kevin3NF from SQLServerCentral.com

It's probably not your fault, but relying on the defaults of a SQL Server installation might be impacting the performance of your instance. More »


 

The 4 pillars of SQL Server Monitoring

In this new whitepaper, 5 SQL Server experts; Grant Fritchey, Rodney Landrum, Kathi Kellenberger, Phil Factor and Tony Davis, use their many years of experience working and maintaining data systems to explain the 4 key strategies required for a successful, estate-wide monitoring solution. More »


 

HIPAA and Database Administration – Part 2

Additional Articles from SimpleTalk

HIPAA was signed into law in the United States in 1996. In this article, Robert Sheldon discusses how the act affects the day-to-day responsibilities of database administrators. More »


 

From the SQLServerCentral Blogs - Three ways a virtual Database Administrator (vDBA) could be just what your business needs

Jakub Dvorak from SQLServerCentral Blogs

How often have you felt like you need an extra pair of hands? When you’re planning a party? Maybe. When... More »


 

From the SQLServerCentral Blogs - Keeping Large Table Statistics Current -TF2371

SQLEspresso from SQLServerCentral Blogs

Statistics are the magic ingredient that helps the query optimizer create its best guess for generating an execution plan. Keeping... More »

Question of the Day

Today's Question (by Steve Jones):

I want to use NEWSEQUENTIALID() to get incremental GUIDs for my application, but I am concerned about them getting out of sequence. If my user runs the application and gets a GUID, and then runs the same application again to get another GUID, when can they not be sequential?

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: NEWSEQUENTIALID().

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

Extract, Transform, and Load with SQL Server Integration Services: With Microsoft SQL Server, Oracle, and IBM DB2

Readers will learn by example how to use Microsoft SQL Server 2016 Integration Services (SSIS) as they design and implement extract, transform, and load (ETL) solutions to support a business application that integrates with a data warehouse and an online Web store across a heterogeneous system. This volume describes proven methods to support common ETL needs, such as databases communicating directly with each other, using files to exchange data, or performing database operations using Web services.

Pick up your copy of this great book today at Amazon today.

Yesterday's Question of the Day

Yesterday's Question (by Steve Jones):

It's Halloween, and the founders of SQLServerCentral are dressing up for a party, but they chose some unusual colors. Their names, costumes, and costume colors are listed in this tuple.

 Costumes = (("Steve", "Batman", ("Black", "Green")), ("Andy", "Superman", ("Blue", "Orange")), ("Brian", "Flash", ("Red", "Brown"))) 

I want to get the unusual color of Andy's costume, so I can find him. The unusual color is the second color listed. How can I get Andy's color if I query the tuple in Python?

Answer: Costumes[1][2][1]

Explanation:

Python is 0 based, so the tuple that contains Andy is costumes[1]. To further address the the inside tuple, this would be element 2. I would get this with costumes[1][2]. I add a third set of brackets to get the second element, which has index 1.

Ref: Python Typles - click here


» Discuss this question and answer on the forums

Featured Script

sp_what

Nicholas Williams from SQLServerCentral.com

Greetings! 
Do you hate scrolling unnessarily? Do you tire of looking through loads of blocking chains to find the head/root of the block? Do you have to deal with negative spids? Do you want to see the sql text of sessions activity? Do you want to filter to particular logins or see all connections through a particular database ? *
*Without having to switch paramaters, cuz you are lazy? (Efficient*) 
If you enjoy being lazy *Efficient*, and like looking like a SQL Badass and confusing your developers?  Do you want to capture sessions over a period of time?
..But mostly, Do you like memes? 

Well, then this is for you!

Description
Displays helpful info on what is currently happening, without the pain of searching for the blocking root/head and dbcc inputbuffer combined.
Also allows the filtering of sessions to either a spid, or a login, or a database name. (Active or inactive.)
Limitations:If a process is a job from another server, the call to search for the job id will fail - hiding this session. Will fix.
Also... prob need to hard code collation to get around some potential issues.
Maybe include a min version as standard (with minimal columns returned?) and then a "max" version with more info if required.
Output:
Be Aware that if there are no blocks/blocking - then the blocking column will not show up - minimalism being a design goal. (Want only info that I commonly use in troubleshooting/understanding sp_whats happening.)
So the columns  and data that show on the final result will change depending upon what activity is actually happening on the instance.
If there are any negative spids, then it will pull info about the source transaction and provide the kill command, for convenience. 
How to use:
Can be called on its own, without input and will display the active sessions, with any blocks.
Other inputs for the first parameter include:
  • Any valid login
  • Any Valid SPID
  • Any valid database
And the results will filter onto those sessions. (AND I really enjoy using conjunctions as the starting point of sentences. AND NO ONE CARES ANYMORE, Mrs Kazinsky!**)
  • EXEC sp_what --will be default return active sessions on the instance.
  • EXEC sp_what 'domain\login'--includes data on all active sessions from this login.
  • EXEC sp_what 'domain\login',0--includes data on all sessions (inactive and active) from this login.
  • EXEC sp_what 115--includes data on the session id 115
  • EXEC sp_what 'master'--includes all active sessions that are connected to the msdb database.
  • EXEC sp_what 'msdb', 0--includes all sessions (inactive and active) that are connected to the msdb database.
  • EXEC sp_what 'msdb', 0, 5--Executes the search 5 times, with a 0.5 delay per search, then reports on all data captured. (in this case all session for the msdb database.)
Included is the option to include or exclude only active sessions - and the option to run it multiple times and collect the results over a 
period of time.
Confusing your Developers
I like to save sp_what to my keyboard shortcuts of ctrl+3.
Its fun to highlight a string with a login name, or a spid and hit ctrl+3... and watch the developers faces as they try to see how a string or a spid can be sent to the same input. lol.*
*yes, i know this is sad. I get my laughs where i can.
**Finally, relief from english class.

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 2017 : SQL Server 2017 - Development

Creating Columns from multiple values in rows - One of the tables I am working with contains a column with string values like this: 3,4,6,9,12,24 1,6,9,12 1,2,3,4,5,6,7,8,9,10,11,12 These basically represent month terms. I...

Data modelling: how do you handle child records when doing a soft-delete? - I'm facing an dilemma in something similar to a sales database with parent-child relationships between the tables "Country", "Region" and...

How to build an app with GUI that works with SQL Server? - I have to create a project which should have a GUI because people who gonna use it don't know TSQL....


SQL Server 2016 : SQL Server 2016 - Administration

Full Backup Files - Fastest Way to Copy Over WAN - Hi, I am trying to Robocopy large .bak files over the WAN and it's going terribly slow.  The full backup files...

How To Truncate Log with Transaction Replication - I am running a transactional replication and seeing the transaction log growing in the publisher database; it is a little...

SQL job step to copy backup file not working - Hello All, I'm trying to copy a recent backup file from one server to another using the syntax below as part of...


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

T SQL Question sd.name ? - The purpose of the code is to; Model an additional script to setthe Database Recovery Mode to ‘FULL’. Your script shall...

Update and Calculate FIFO - Hi , I have a table that I want to calculate FIFO and update each price of items in table. in table...

Changing 1 or + in a telephone number to the correct format - Hi everyone I have various records in a database that contain US telephone numbers in different formats. Some are correctly formatted...

seperate data in 1 row - Hello HOw can I separate  this data I have buch of emails in a row, I need to keep just one and...

Importing from XML to SQL 2014 - This is my 4th day on SQL so I am a newbie. I created a query to import from an...


SQL Server 2012 : SQL 2012 - General

Error converting data type DBTYPE_DBDATE to date - Every night we run an import from an IBM Informix DB to our server via a Linked Server.  A few...

Exponential values conversion - Hi, I have this task to convert the Exponential values to numeric(20,15) format. The problem I am facing is the values...

Database often in Restore/Recovery mode - Hi  Abit of background, we use a software provider for entering our data and each night they send over a backup...


SQL Server 2012 : SQL Server 2012 - T-SQL

Re-granting Permissions - I've got a group of developers who insist of dropping a view or sp when deploying changes. For some reason...

Column data type - Msg 207 Invalid column name - Hello ,  Can someone point me in the right direction here.  I'm having a hard time figuring this out. I have a...

NOT IN vs NOT EXISTS - A little while a go I was told that NOT EXISTS will "never perform better" than NOT IN, and that...


SQL Server 2008 : SQL Server 2008 - General

ssis package succesffuly executes when we run from visual studio, but when we run from sql server agent it still is sucessfully running but doesnt pull any data - I have 3 packages that run by a Proxy account who has all the permissions to access the files in...


SQL Server 2008 : T-SQL (SS2K8)

Left Join madness - Hi I'm trying to figure out a "simple" join that's got me going in circles.  I'd joining on two tables, but...


Data Warehousing : Integration Services

SSIS 2008R2 to 2014 upgrade - the requested OLE DB provider Microsoft.ACE.OLEDB.15.0 is not registered ... - We were using 2008R2 and developed multiple packages in BIDS - all of them taking data from Excel into SQL. When...

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