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

No Overtime

This editorial was originally published on Dec 5, 2011. It is being re-run as Steve is out of town.

It's been a long time since I received overtime at any job. Most of my IT work has been with a salary, and the expectation that I would work as needed to accomplish my assignments. Early in my career I worked as a contract for an hourly rate, and while it didn't necessarily lower the hours I worked, I did receive a little more pay on long weeks. From there I worked for a company that provided "comp time" when the hours exceeded 20 hours in a month. That seemed to help reduce hours more than anything.

There's a bill that's in the US Congress that adds some new job classifications to the exemptions for overtime pay. In addition to the system administrative jobs, it now includes database and network professionals. I'm not sure how many people this affects as the overtime requirements disappear once you make more than $27.63 an hour. That equates to about an annual salary of 57,491, without the benefits. If you make less than this, you should be getting overtime.

Does overtime pay matter to most IT workers? I don't know. There are lots of workers who make more than US$60,000 a year, and are exempt, but I suspect there are many others who make less than this amount and work long hours without any extra compensation. This bill is aimed squarely at reducing pay for those people in the industry that make the least amount of money.

I struggle with whether the benefits and abuses of a salary. On one hand salaries provide a level of security to workers, along with a guarantee of payment for work that cannot easily be measured in terms of output per unit of time. On the other hand, employers sometimes see a salary as a way to push workers to their limits, burn them out, and impose strict requirements on the work needed for deadlines, themselves often arbitrary.

I like the idea of allowing businesses to pay salaries, and stabilize their cost structures, but I do think we ought to implement a few bumpers that prevent abuses. Limiting hours across a month or quarter and ensuring that employees can take their vacations would be limits that I'd like to see implemented. This bill doesn't affect those and I'm not sure we'll see any limits implemented, but I do think it's up to each person to stand up to their employer and ensure they are not overworking themselves.

Steve Jones from SQLServerCentral.com

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

ADVERTISEMENT
DLM Automation Suite

Automate
database
changes
using

continuous integration
&
automated deployment

A fast, reliable way to test and deploy your SQL Server database changes.

Try it for free

Featured Contents

 

A SQL Server Patching Shortcut

Ajmer Dhariwal from SQLServerCentral.com

This post on SQL Server patching illustrates a quick and simple way of safely extracting SQL Server installation files in advance of patching a SQL Server instance. More »


 

The 2015/2016 Simple-Talk Awards

Additional Articles from SimpleTalk

Once more Simple-Talk invites its readers to vote on the top nominations for the Simple-Talk Awards. Find out who or what has been nominated for each of this year's nine categories, and cast your vote to decide the winners - voting closes tomorrow! More »


 

New – work better with Git using SQL Source Control 5 beta

Join the SQL Source Control 5 beta and get early access to the newest features: source control your database in Git and other version control systems, merge when working with multiple branches, and deploy data-only migration scripts. More »


 

SQL Server on Linux

Last month Microsoft not only announced that they’re bringing SQL Server to Linux, but also showed it off in a demo during the Data Driven keynote. Redgate are doing some research to understand what this news means to SQL Server users. So whether you’ve already downloaded the SQL Server on Linux preview, or you hadn’t heard about it until just now, you can help out by completing this short survey. More »


 

From the SQLServerCentral Blogs - Partitioning and filegroup restores

Andrew Pruski from SQLServerCentral Blogs

I’ve been playing around with partitioning quite a lot recently and wanted to write a quick post about how it... More »


 

From the SQLServerCentral Blogs - Configure SQL Server Database Mirroring: Step By Step

Hemantgiri S. Goswami from SQLServerCentral Blogs

Database Mirroring in SQL Server is deployed as a method to increase the availability of a SQL Server database in... More »

Question of the Day

Today's Question (by Steve Jones):

Which of these is not a valid property for the COLLATIONPROPERTY function in SQL Server 2012+?

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):

Which of these OpenXX statements is used against a linked server in the FROM clause of a query?

Answer: OPENQUERY

Explanation:

The OPENQUERY syntax allows you to access a linked server in the FROM clause as if it were a table.

Ref: OPENQUERY - https://msdn.microsoft.com/en-us/library/ms188427.aspx


» Discuss this question and answer on the forums

Featured Script

A new set-based T-SQL solution for Sudoku puzzle

Kevin Duan from SQLServerCentral.com

I’ve been using the set-based Sudoku solution as an example in my T-SQL class for a few years, and I found it very well in helping the students to understand:

·         The major difference between the procedural approach and set-based approach;

·         How the algorithm complexity could be affected by the choice of data structure;

·         Different aspects of the language syntax;

·         The performance comparison and considerations using different SQL objects.

The script in this post is a tuned version of T-SQL solution for Sudoku puzzle using the set-based approach. Its logic is straight forward, and does use any "not exists" logic. But it does contain a basic iteration loop. The assumption is the puzzle have a sigle solution. Most of the puzzles can be resolved within 20 iterations. Following is some of explanation of the script:

The Data Structure and the Terms used

A Cell: is the cell in the Sudoku puzzle. A resolved cell means we already know the final number in this cell in the solution. An unresolved cell means we still haven’t figured out which numbers should put in this cell yet. An unresolved cell must have multiple possible values. In the initial puzzle, all empty cells should have possible values from 1 to 9.

In this script, I used the binary number to present the possible value(s) in a cell, specifically, 1 =>21-1, 2=>22-1,…, 9=>28. E.g., if a cell has possible values of {4, 5}, its binary value should be 24-1+25-1=24 (in decimal format). In the initial puzzle, the decimal value of an empty cell should be 20+...+28=511.

I used the term Range to reference a row, or a column or a block. There are totally 27 ranges in the puzzle. Each of the 81 cells should be in exactly 3 range contexts: its row, its column and its block. By the game rule, there should be no duplicate number in any range in the solution.

A Combo means any non-empty combination of number 1, …, 9 (mapped to binary numbers of 20, ..., 28 respectively).  Simply put, it is a non-empty subset of the set {1, …, 9}. Obviously, the decimal values of all Combos are exactly from 1 to 511.

A fit-cell for a Combo means: all current possible values of that cell are within the Combo set ( i.e., the current possible value set is a subset of that Combo). The T-SQL verification expression is:  V - ( V & Combo) = 0, where V is the decimal number of possible values for the cell. While, The non-fit cells must have V - ( V & Combo) > 0.

An Encloded Range Combo, or interchangeably an Enclosed Combo, is a combo for a specific range, where the fit-cells in that range equals the possible numbers of that combo. For example, if in the first row of a puzzle, we have three cells with possible values of {1, 2, 3}, {2, 3} and {1, 3} respectively (decimal values are 7, 6 and 5 respectively), and all other cells has some possible values other than {1, 2, 3}. Then, these three cells are the only fit-cells for the combo {1, 2, 3} (V=7) in this row. So we say, the combo of 7 in the first row is an enclosed combo. You might already realize that number 1, 2 and 3 have to be arranged in these three cells, which further means, number 1, 2 and 3 should be taken out from all other cells’ possible values in the first row. As an extreme scenario, the number in a resolved cell should be taken out from any other cell’s possible values in the same row, column or a block (because a single value cell is enclosed by itself in any range context!)

The advantage of using binary number to present possible values in a cell is:

·         Maximum the usage of the bitwise operators. With data structure, I can easily detect whether a cell has certain possible value(s) at current, and I can take out multiple impossible values from a cell in one shot;

·         Saved one level of data structure break down when not necessary;

·         Faster in performance.

The algorithm and script notes

The main idea of the algorithm is to:

·         Repeat following iteration until all cells are resolved:

·         Find all enclosed range combo;

·         Take out the numbers in the combo from other related cells (non-fit cells in the same range).

In the script, the main workbench is the temp table #Sudoku which holds each cell as a record corresponding to the cells in the puzzle, from left to right, from top down. Of its columns, ID is the sequence number from 1 to 81, the Val column is the decimal format of the binary hash of all possible values in the cell. Other columns (row number, column number, … , etc.) are added only for facilitating the algorithm.

The #num table holds the possible value to binary hash mapping, 1=>21-1, … , 9=>28.

The #Combo table hold all 511 possible combos of {1, 2, … , 511}, with an extra column showing the number of possible values in that combo (for performance reason).

The #MapRange table is created to map each cell (by ID) into three ranges, so that I can do grouping on all ranges with one SQL rather than run the same SQL against rows, columns and blocks three times (in each iteration). I defined the range number as: row number; column number times 10; and block number times 100. So, e.g., for the second cell in the forth row (with ID=29) you will find 3 records in this mapping: 

·         ID=29, Range=4  (the forth row)

·         ID=29, Range=20 (the second column)

·         ID=29, Range =400 (the forth block)

The #temp that is created / dropped in each iteration, it can be included into the next CTE sentence right easily, but you will see the performance drops when you do that. You will also get some slow down if you create this temp table only once and keep truncating and inserting in each iteration. I will leave it for you to figure out why.

Performance Tweaks

For performance interests, you can tweak this script in many ways (e.g., use of indexes, table variables, different joins, … , etc.). But it’s the not the main purpose of this post anyway, I will leave it for you if you are interested. But please do let me know if you come up with better ideas and any suggestions.

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 2014 : Administration - SQL Server 2014

Trouble Truncating Table Referenced by Forien Key - ALTER TABLE ClientCoverage NOCHECK CONSTRAINT ALL ALTER TABLE ClientCoverageException NOCHECK CONSTRAINT ALL ALTER TABLE ContractorCoverage NOCHECK CONSTRAINT ALL ALTER TABLE ContractorCoverageException NOCHECK CONSTRAINT...

Error while mirroring database - When i try to mirror database i am getting following error.I checked database exist and permission. Database exists and sa is...


SQL Server 2014 : Development - SQL Server 2014

Handling xml data and formatting into separate table - I have xml data in table, here xml data looks mentioned below, And it’s taken from different table for each row [b][i]TableA[/i][/b] Tab_id xml_data 1 xml_data1...

TSQL query to get employee name from employee table by using id from user table - How to write a sql statement that can get the name from employee table by using id from user table...

Where to start? - I've just installed SQL Server Express 2014 on my development machine, and I'm looking at the Management Studio Object Explorer....

Nested Joins - Having syntax and bounding issues - Hello. My first post here and hope to get some help. It'll be obvious that I'm a newbie. I apologize for...


SQL Server 2012 : SQL 2012 - General

Login can't be deleted because it granted permissions - I'm trying to delete an individual login from a server but am failing because the login "has granted one or...

Sudden performance hit - Hi All, I am facing a performance issue on one of my SQL job. Job execution was completing by 40-45 minutes...


SQL Server 2012 : SQL Server 2012 - T-SQL

Help avoiding Dynamic SQL if possible? - I'm currently writing some code for a task at work where I need to return values for individual ID's stating...

Find out the record with that falls in the date range - So, I've a product price table. It can have multiple records for the date range depending on how customer wants...

Sort alphanumeric value based on condition - Can anyone help me to solve the below issue? Issue: I need to sort alphanumeric value based on the condition. Sample Table: TableA ID 1 2 2A 200 1000 11 90 20 2011 My table...


SQL Server 2008 : SQL Server 2008 - General

About Index - Can we create a nonclustered index on clustered index column - Hi All, I know that we can create a nonclustered index on a clustered index column. Can anyone let me know is...

help needed with query - i have a table with the following columns: StudentId, StudentName, DateofBirth, Category. i need to find out the number of distinct Studentnames in each category....

mysterious slowdown every 4 minutes - Hi I' ve a database used to a gaming application. 99% of procedure called by the application are 2 stored procedure...

By date - I would like to run for 100 days of data. getdate() - 6 april 7april - 14 april and so on.. How can I break into...

Processing strings. - Hello Processing strings. Examples are replace, DelimitedSplit8K. And lots more. What is a good way to process the string, but not process the...


SQL Server 2008 : SQL Server Newbies

log for tempdb is full - Job failed last night due to temp log consuming full disk space. Could you please advise on fixing this. Heard,Shrinking...


Data Warehousing : Analysis Services

installation issue-services - Hi all could you please suggest what is the error in installation,all the services are installed but i am unable to...


SQL Server 2005 : SQL Server 2005 Integration Services

Error while running SQL Agent job(SSIS) after set value in Set Values tab of package - Buddies, I created a job with five SSIS packages in SQL Server Agent->Jobs folder. If I run the job it is...


SQL Server 2005 : SQL Server Newbies

schedule SSIS package error - Hi, I'm trying to schedule a SSIS package and it fails with the following error: [i] Code: 0xC00291EC Source: Preparation SQL Task...

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