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

IoT Success

After quite a bit of press the last few years, the IoT crazy has slowed a bit. I suspect this is because many of the consumer type IoT devices, such as refrigerators and washing machines, haven't proven to be as useful or exciting as their developers originally thought. With all of the security issues that we've seen as well, having more interconnected "things" doesn't seem to be so desirable for many individuals.

In the industrial world, IoT is still thriving and growing, as businesses see just how inefficient they have been in the past. The way that many people have gotten business done is with lots of hard work and good luck along the way. Certainly farmers and ranchers have counted on instincts and good weather more often than science. Those items still matter, but smaller sensors and connected IoT devices can help reduce some of the risk and ensure better yields from your efforts.

There's an example of this in a short article about how various IoT devices are being used to help shrimp farmers in Columbia. Some of the uses, such as cameras to detect theft, are obvious, but the additional use of computing power and logic to reduce the need for a human to stare at a screen, vastly increases the chances of knowing when a theft is about to occur. Others sensors are used to check weather and actually monitor the shrimp in their environment, tasks which weren't feasible for individual companies in the past to perform cost effectively.

The key here really is being able to gather more data and process it efficiently. Lower hardware costs, better algorithms  and a variety of programmable sensors enable the capture and examination of this data in a way that can be customized for individual companies. Data can be very powerful for most organizations that perform actions in the analog world. IoT is helping them learn to better understand data they they wouldn't previously have been able to capture.

There are certainly still potential security problems with off the shelf sensors and grid connections. Anyone that wants to start to use these types of devices needs to understand the networking and potentially limit access to your main databases and systems, perhaps with tightly controlled ETL processes to funnel the data to staging areas. If you can do that, however, there are going to be opportunities to increase the efficiency of your operations, with plenty of data analysis and visualization jobs for the data professionals.

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 ( 3.9MB) 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
SQL Compare

The industry standard for comparing and deploying SQL Server database schemas

Trusted by 71% of Fortune 100 companies, SQL Compare is the fastest way to compare changes, and create and deploy error-free scripts in minutes. Plus you can easily find and fix errors caused by database differences. Download your free trial

SQL Monitor

Don’t just fix SQL Server problems, prevent them from happening

SQL Monitor helps teams looking after SQL Server be more proactive. Not only does SQL Monitor alert you to current issues, it gives you the information you need to stop them happening in the future. Download SQL Monitor now and get a 14 day free trial

Featured Contents

 

Row-Level Security Predicate Functions - Level 2 of the Stairway to Row Level Security

Steve Jones from SQLServerCentral.com

In this level, we dive deeper into predicates and the various ways to structure them in an RLS environment. More »


 

Free eBook: Fundamentals of SQL Server 2012 Replication

Press Release from Redgate

Fundamentals of SQL Server 2012 Replication provides a hands-on introduction to SQL Server replication. The book introduces you to the technologies that make up replication, and then walks you through setting up different replication scenarios. When you've finished reading, you should be able to implement your own multi-server replication setup while following the principle of least privilege. More »


 

Software Testing Skills Must Shift with AI

Additional Articles from SimpleTalk

Artificial intelligence (AI) is touching many parts of our lives and careers. Rama Anem discusses the impact of AI on software testing and how testers’ skills must adapt. More »


 

From the SQLServerCentral Blogs - Did you know…you can’t do arithmetic operations with datetime2 like with datetime?

Cláudio Silva from SQLServerCentral Blogs

I’m currently working on a SQL code migration from Firebird to SQL Server and I hit an error that I... More »


 

From the SQLServerCentral Blogs - The Uni-Code: The Search for the True List of Valid Characters for T-SQL Regular Identifiers, Part 2

Solomon Rutzky from SQLServerCentral Blogs

(last updated: 2018-04-06) Recap In Part 1 of this 2 part series, I started with the loose definition in Microsoft’s documentation for... More »

Question of the Day

Today's Question (by Steve Jones):

I build a basic Python list like this:

 SQLServer = [["Express", "Standard", "Enterprise", "Evaluation"], [2005, 2008, "2008R2", 2012, 2014, 2016, 2017]] 

If I enter this code in the REPL, what is returned?

 SQLServer[1] 

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

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

SQL Server T-SQL Recipes

SQL Server T-SQL Recipes is an example-based guide to the Transact-SQL language that is at the core of SQL Server. This edition has been lightly updated for SQL Server 2014 and provides ready-to-implement solutions to common programming and database administration tasks. Learn to create databases, create in-memory tables and stored procedures, insert and update data, generate reports, secure your data, and more. Get your copy from Amazon today.

Yesterday's Question of the Day

Yesterday's Question (by Steve Jones):

I have this code to create and load a table:

 CREATE TABLE CastTest ( Myval VARCHAR(20) ); GO INSERT CastTest ( Myval ) VALUES ('A') , ('123') , ('123.5') , ('20180301') , ('Mar 23, 2000'); GO 

I now run this query. How many rows are returned?

 SELECT CASE WHEN TRY_CAST(ct.Myval AS INT) IS NOT NULL THEN CAST(Myval AS INT) ELSE -1 END FROM dbo.CastTest AS ct; 

Answer: 5

Explanation:

This query will return these values:

NULL

123

NULL

20180301

NULL

The TRY_CAST will work with all rows and for those that can't be returned, it will return a NULL. The WHEN clause in the CASE will return a NULL for all rows that aren't matched in a WHEN clause.

Ref: TRY_CAST - click here


» Discuss this question and answer on the forums

Featured Script

Login restriction from selected applications and users

Subhash Chandra from SQLServerCentral.com

As in DBA life every organization have different -2 kind of user’s login tracking and login auditing requirement.

This trigger I had tested in SQL 2005 and later versions and its working fine till latest version

Requirements to enable this trigger.

Please make complete testing of this trigger on testing environment as per your need before implementing it on production. if you implement it on production without testing may have you face many kind of issues and challenges on daily life.

  1. Make 1 MonitorDB or you can make it in master DB as well.
  2. Create table as given below

create table tbl_login_hstry

(Login_name  varchar(100),

 Applicationname varchar(100),

 HostName varchar(100),

 SYSTEMUSER varchar(100),

 Date  datetime ,

 DbName  varchar(100)

)

  1. Now create the trigger ---Default trigger will be in disabled as per your need and filtered programmes and after all requirement full fill you can enable it from management studio ----server objects and ----triggers –select trigger [Login_restriction_and_tracking_trigger] and right click on trigger name and make it enable.
  2. Before enabling it please be careful and first enable the DAC (RemoteDacEnabled)setting from facts and surface area configuration or script.

Use master

GO

/* 0 = Allow Local Connection, 1 = Allow Remote Connections*/

sp_configure 'remote admin connections', 1

GO

RECONFIGURE

GO

After implanting it now you can run select in tbl_login_hstry and see the user’s login history

  1. If you face any issue you can drop this trigger by below commands.

C:\Users\Pinal>sqlcmd -S LocalHost -d master -A

1> DROP TRIGGER Login_restriction_and_tracking_trigger ON ALL SERVER

2> GO

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

Migration from SQL 2008 to 2017 - Hi All, I need some assistance in the process of migrating from 2008 to 2017.  This is the first time doing...


SQL Server 2017 : SQL Server 2017 - Development

Convert Negative values -2.56 to (2.56) in excel - hi ,  I have a package right now which loads data from Table to a  .csv flatfile. When loaded to excel...

Error Processing Cube from SSIS package run as a SQL Job - Hi, I am trying to upgrade a SQL server with Analysis Services to SQL 2017 cu5, 14.0.3023.8, (I tried CU4 before...

Removing stored procedures to move to cloud - I got an interesting email today about cutting back on the reliance of the applications on databases and plans to...


SQL Server 2016 : SQL Server 2016 - Administration

Reporting/HA design advice- FCI with AG - Looking for advice on design for Reporting solution. What we currently have- WSFC1 with 2 nodes (Act/Act) and 2 FCIs (sqlserver 2016 Ent Ed)....

SSL Certificate for SQL Server 2016 not appearing in MMC - Dear Everyone I followed the required steps to request a certificate for using SSL in SQL Server 2016 and i...

SQL Server Agent stops running after changing the default listening port - Dear Everyone I changed the default listening port for SQL Server 2016 standard edition on windows 2012 R2 then i...

Unauthorised action - installing sql 2016 on Windows 10 - Hi All I have been trying for four days now to install sql 2016 on Windows 10. I previous had a...


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

Convert ORACLE code to SQL - Hi guys I am struggling to convert this into SQL SELECT sum( case when table1.sale_Id Is Null And table2.status In ('D1','E1','P1') And table3.Code...


SQL Server 2014 : Administration - SQL Server 2014

Client and Server cannot communicate...they do not posses a common algorithm - Hi, has anyone encountered this error when trying to connect from a SQL Server 2014 instance to a SQL Server 2008...

Find end user who is running sql query using SQLCMD. - Hello Folks,  I'm trying to find a user/developer who is trying to execute queries using SQLCMD. When I check using DMVs,...

Assigning VIEW SERVER STATE to an account (preferably WITHOUT LOGIN) - I'm looking at a function that has been passed to me, to assign VIEW SERVER STATE, because of the access...

Shrunk Database - I had a developer remove a bunch of data from a database and free up a big amount of space. ...

Troubleshooting MEMORY ALLOCATION EXT wait type - I am getting this wait type on my DB Server, please let me know the reason y it caused and...


SQL Server 2014 : Development - SQL Server 2014

Use uniqueidentifier field in place of int - Hi All, I'm trying to populate a temp table. Here is the temp table: CREATE TABLE #SESDMVESEnrollData (   ContractNumber nvarchar(50) not null,  ...


SQL Server 2012 : SQL Server 2012 - T-SQL

last entry, first entry - Hello I want to prepare a stock list of last entry , first entry DECLARE @IN TABLE (STOCK INT,ID INT, DATE_ DATETIME,AMOUNT...

Update Trigger - Hello all, I have a table: CREATE TABLE .(      NOT NULL,      NULL,      NOT NULL,      NULL,      (max) NULL ) ON TEXTIMAGE


SQL Server 2008 : T-SQL (SS2K8)

Auto shrink Log file. - I can't seem to get the log file to auto shrink. It is set to auto shrink in the properties, but...


SQL Server 2008 : SQL Server Newbies

Using CASE in a View - I have created an employee View to which I need to add a calculated field called Calendar. All my internet...


Reporting Services : Reporting Services

ssrs migration - I had to do a SSRS migration, I did a back up and restore to migration the SSRS data. Everything...

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