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

An Age of AI?

This editorial was originally published on Feb 15, 2016. It is being re-run as Steve is traveling.

It’s been a good week for AI rights, as Google’s self-driving cars are on the verge of being declared legal drivers. Up until this point, the cars have had to have a human driver and controls that can be taken over at any point, but this change clears the way for truly autonomous vehicles on the roads.

Our robot overlords have done pretty well financially recently, with an Elon Musk-backed group donating $1bn to OpenAI, a non-profit AI consortium. Musk has spoken out against the threat he perceives from artificial intelligences, though it’s possible this is just a smokescreen to distract us from what he’s really up to with all those rockets.

In a similar way to virtual reality, it does feel like AI is starting to move from being a nice idea with no real chance of becoming a mainstream technology to something that’s on the cusp of genuine usefulness. A proliferation of cheap sensors and network technology, and some sane-ish standards make automation easier and more powerful for a huge variety of applications. When I first started dabbling in computing, fuzzy logic was the thing that was going to revolutionize AI, but the promised proliferation of thinking machines never really came about.

The dawn of science fiction promised robots that would walk and talk, the reality was grounded in the prosaic - robotic production lines with highly-specialised machines. Similarly the reality of AI has been bundled off into discrete packages - locomotion in Boston Dynamics’ machines, natural language processing in smartphone assistant applications. IBM’s Watson, one of the few generalist AI projects out there, now has a commercial role as a backend to business - effectively an API for machine learning apps. The superintelligent sci fi AIs will just have to wait for someone to create a good application layer between all these disparate parts.

Dave Convery

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

Redgate Data Masker
 
 Featured Contents

Data Transfer Strategies between MongoDB and SQL Server

Phil Factor from SQLServerCentral

There are a variety of days to move data between MongoDB and SQL Server. This article covers some of your options and gives you ideas on which method might work best for you.

How to find Updated Column in SQL Server Trigger

Additional Articles from MSSQLTips.com

In this tip we look at how to which columns have been updated when using a SQL Server trigger by using the update and columns_updated functions

From the SQL Server Central Blogs - Error: ‘misaligned log IOs which required falling back to synchronous IO’ And Slow AG Synchronisation

david.fowler 42596 from SQL Undercover

I recently hit this rather interesting issue when migrating a bunch of SQL Servers onto a nice, shiny new SAN. The plan was simple enough, take the secondary servers...

From the SQL Server Central Blogs - Is That Database in Use?

SQLRNNR from SQL RNNR

This article demonstrates how to use Extended Events to determine if a database is being used by someone or something.
Related Posts:

Finding Deprecated Uses in SQL Server November 7, 2016...

 

 Question of the Day

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

 

Container Ports

When I run SQL Server in a container, I may have a parameter that looks like this:
-p 51433:41433
What port would I my SQL Server instance inside the container need to be listening on for a connection to work?

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)

Intersection

If I have two sets and want an intersection of their members, which join do I choose?

Answer: inner join

Explanation: An inner join will give us the intersection of two sets. Ref: Stairway to T-SQL DML Level 4- The Mathematics of SQL - https://www.sqlservercentral.com/steps/stairway-to-t-sql-dml-level-4-the-mathematics-of-sql-part-1

Discuss this question and answer on the forums

 

Featured Script

VIEW to list running and completed jobs

zbodean from SQLServerCentral.com

This view will list all completed and running jobs. It give running times, current step (if active) and average run times for steps.

CREATE VIEW [dbo].[v_View_Agent_Job_Run_History] AS
/*
Dean Bell
March 2019
deanbell2000@hotmail.com

--You'll need to have 'ad hoc distributed queries' permission to run.
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO
*/
With [TIMES] As (
SELECT [Instance_ID],[Job_ID]
,CONVERT(datetime,CONVERT(varchar,[Run_DATE]))[Run_DATE]
,CONVERT(time,STUFF(STUFF(RIGHT('00000'+CONVERT(varchar,[Run_TIME]),6),3,0,':'),6,0,':'))[Start_TIME]
,CONVERT(time,(Case
When [Run_Duration]=0 Then CONVERT(varchar,'00:00:01')
When [Run_Duration]>=240000
Then CONVERT(varchar,'23:59:59')
Else STUFF(STUFF(RIGHT('00000'+CONVERT(varchar,[Run_Duration]),6),3,0,':'),6,0,':')
End))[Duration]
FROM [msdb].[dbo].[sysjobhistory]
),[DATES] As (
SELECT *,[Run_DATE]+Cast([Start_TIME] as datetime)+Cast([Duration] as datetime)[End_DATETIME]
FROM [TIMES]
),[JOBS] As (
SELECT H.[Server],H.[Job_ID],J.[name][Job_Name],H.[Instance_ID]
,(CASE H.[Run_Status]
WHEN 0 THEN 'Failed'
WHEN 1 THEN 'Succeeded'
WHEN 2 THEN 'Retry'
WHEN 3 THEN 'Cancelled'
ELSE Cast(H.[Run_Status] as varchar(5)) END)[Run_Status]
,CONVERT(date,T.[Run_DATE])[Run_DATE]
,LEFT(T.[Start_TIME],8)[Start_TIME]
,LEFT(CONVERT(time,T.[End_DATETIME]),8)[End_TIME]
,LEFT(T.[Duration],8)[Run_Time]
,H.[step_id][Step_Num]
,H.[Step_Name]
,H.[MESSAGE][Log_Msg]
FROM [msdb].[dbo].[sysjobs][J]
JOIN [msdb].[dbo].[sysjobhistory][H] ON H.[job_id]=J.[job_id]
JOIN [DATES][T] ON T.[Instance_ID]=H.[Instance_ID]
WHERE H.[Run_Status]4
-----------------------------------------------------------------
--This UNION retrieves jobs actively RUNNING which requires advanced permissions
--to run OPENROWSET. Comment this UNION out if you don't need to include RUNNING jobs.
UNION ALL
Select O.[Originating_Server][Server],A.[Job_ID],
J.[name][Job_Name],'9999999'[Instance_ID],'Running'[Run_Status]
,CONVERT(date,(Case When A.[Start_execution_date]>T.[End_DATETIME]
Then A.[Start_execution_date] Else T.[End_DATETIME] End))[Run_DATE]
,LEFT(CONVERT(time,(Case When A.[Start_execution_date]>T.[End_DATETIME]
Then A.[Start_execution_date] Else T.[End_DATETIME] End)),8)[Start_TIME]
,''[End_TIME]
,CONVERT(varchar,DATEDIFF(ss,Case When A.[Start_execution_date]>T.[End_DATETIME]
Then A.[Start_execution_date] Else T.[End_DATETIME] End,getdate())/86400) -- # of Days in case goes over 24hrs
+':'
+CONVERT(varchar,DATEADD(ms,(DATEDIFF(ss,Case When A.[Start_execution_date]>T.[End_DATETIME]
Then A.[Start_execution_date] Else T.[End_DATETIME] End,getdate())%86400)*1000,0)
,108)[Run_Time]
,LEFT(O.[Current_Execution_Step],CharIndex('(',O.[Current_Execution_Step])-1)[Step_Num]
,SubString(LEFT(O.[Current_Execution_Step],LEN(O.[Current_Execution_Step])-1),CharIndex('(',O.[Current_Execution_Step])+1,999)[Step_Name]
,'Running step: '+O.[Current_Execution_Step][Log_Msg]
FROM [msdb].[dbo].[sysjobactivity][A]
JOIN [msdb].[dbo].[sysjobs][J] ON J.[Job_ID]=A.[Job_ID]
--Get active running jobs.
JOIN --OPENROWSET('SQLNCLI','Server=(local);Trusted_Connection=yes;','msdb.dbo.sp_help_job @execution_status=1')[O]
OPENROWSET('sqloledb', 'server=(local);trusted_connection=yes'
,'set fmtonly off;
DECLARE
@job_id UNIQUEIDENTIFIER = NULL,
@job_name SYSNAME = NULL,
@job_aspect VARCHAR(9) = NULL,
@job_type VARCHAR(12) = NULL,
@owner_login_name SYSNAME = NULL,
@subsystem NVARCHAR(40) = NULL,
@category_name SYSNAME = NULL,
@enabled TINYINT = NULL,
@execution_status INT = NULL,
@date_comparator CHAR(1) = NULL,
@date_created DATETIME = NULL,
@date_last_modified DATETIME = NULL,
@description NVARCHAR(512) = NULL

EXEC msdb.dbo.sp_help_job @job_id,
@job_name,
@job_aspect,
@job_type,
@owner_login_name,
@subsystem,
@category_name,
@enabled,
@execution_status,
@date_comparator,
@date_created,
@date_last_modified,
@description
WITH RESULT SETS
((
job_id UNIQUEIDENTIFIER,
originating_server NVARCHAR(30),
name SYSNAME,
[enabled] TINYINT,
[description] NVARCHAR(512),
start_step_id INT,
category SYSNAME,
[owner] SYSNAME,
notify_level_eventlog INT,
notify_level_email INT,
notify_level_netsend INT,
notify_level_page INT,
notify_email_operator SYSNAME,
notify_netsend_operator SYSNAME,
notify_page_operator SYSNAME,
delete_level INT,
date_created DATETIME,
date_modified DATETIME,
version_number INT,
last_run_date INT,
last_run_time INT,
last_run_outcome INT,
next_run_date INT,
next_run_time INT,
next_run_schedule_id INT,
current_execution_status INT,
current_execution_step SYSNAME,
current_retry_attempt INT,
has_step INT,
has_schedule INT,
has_target INT,
[type] INT
))')[O]
ON O.[Job_ID]=A.[Job_ID] AND A.[start_execution_date]>'2000-01-01' AND A.[job_history_id] is NULL
AND A.[Start_execution_date]>DATEADD(dd,-30,getdate())
LEFT JOIN [DATES][T] ON T.[job_id]=J.[Job_ID]
AND T.[INSTANCE_ID]=(Select MAX([INSTANCE_ID]) From [TIMES] Where [Job_ID]=J.[Job_ID])
-----------------------------------------------------------------
),[AVG_RUNTIME] As (
SELECT [Job_ID],[Step_Name]
,LEFT(CONVERT(time,CONVERT(datetime,AVG(CONVERT(float,CONVERT(datetime,isNULL([Run_Time],'00:00:00')))))),8)[Avg_RunTime]
FROM [JOBS]
WHERE [Run_Status]='Succeeded'
GROUP BY [Job_ID],[Step_Name]
)
SELECT Top 10000
[Server],J.[Job_ID],[Job_Name],[Instance_ID],[Run_Status]
,[Run_DATE][Start_DATE],[Start_TIME],[End_TIME]
,[Run_Time],isNULL([Avg_Runtime],'')[Avg_Runtime]
,[Step_Num],J.[Step_Name],[Log_Msg]
FROM [JOBS][J]
LEFT JOIN [AVG_RUNTIME][A] ON A.[Job_ID]=J.[Job_ID] AND A.[Step_Name]=J.[Step_Name]
ORDER BY J.[Instance_ID] DESC;
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 - Administration
Existing logins get mapped to new databases - Pretty new with SQL but working my may up:-) When I create a new database all existing SQL-logins automatically get mapped to the new database. How to avoid that? I can remove them afterwards but since I'm about to add 60+ databases I will be a pain in the ass to remove them manually or […]
Grant permissions to execute jobs owned by user - Hey gurus, I'm novice to SQL Server and in need of your help! I need to create a SQL Login for use by few people to run jobs created by 'xyz' account. Is there an easy way to do this? I don't want to add them to the SQL Agent roles in MSDB as I […]
SQL Server 2016 - Administration
SSMS connection attempt results in "Errors in the metadata manager. ..." - Hello experts, I have a colleague who's trying to connect to one of our dev database servers, and when they launch SQL Server Management Studio, they see this error after clicking connect: Errors in the metadata manager. Either the trace with the ID of 'MicrosoftProfilerTrace156...' does not exist in the server with the ID of […]
Db went to suspect in AG - One of my db went to suspect in secondary replica  when i checked in  events  lock_redo_blocked , how can i trouble shoot these issue . In sql Logs we find deadlock info at that time  
Query to check the latest windows patch detaisl and last reboot - i need a query to check the latest windows patch details and last reboot  of the server .any one help ?   Thanks
Geography methods causing syntax error in job - So...I'm trying to work with some geography in a job step. The entire step runs fine in the query window, but when put into the job the step fails. Here are a few examples from the job...does anything jump out? SET @point = (select "geo" FROM "objectLocation" where "objectId" = @objectId).MakeValid() SET @objarea = (select […]
Administration - SQL Server 2014
Non-yielding scheduler error in SQL-2014 with SP-3 - Every once in a while we receive a "non-yielding scheduler" error in SQL Server 2014.  We already upgraded to SP-3 which is suppose to resolve this issue.  What exactly this error means? SQL Server doesn't crash immediately, but natively compiled stored procedures start faltering about 1-2 days following this error.  What should be done to […]
AG secondary TEMPDB growing hugely - Hi, We configured the Alwayson on 3 servers. A -primary(Synchronous),B-Secondary-(Async-Readable),C-Secondary(Asyn-Not readable).Fail over mode is Manual. from 2 days the secondary server tempdb is growing hugely. When we checked the Primary server the tempdb is fine.Not growing. i am not able to understand why secondary server tempdb is growing hugely. Yesterday night we restarted the Secondary […]
SQL Server 2012 - T-SQL
Convert smallint to Date - Hello! I have column in SQL 2012 DB of datatype smallint. Could you please let me know how to convert smallint to date? Here's the example of smallint data "12940".   Thanks.
TempDB filling up - Hello all, We have a SQL Server 2012 Enterprise SP1 running our ERP system.   We have 15 production databases with approx 570GB in size.  Our Tempdb has an initial size of 100GB and sits on a 450GB drive.  Every day it seems to grow in size until all 450GB is consumed in approx. 2-3 weeks.  […]
SQL Server 2008 - General
Remove SQL Server from Failover Cluster - Hi, I'm having a problem with a Windows Server 2008 R2 Failover Cluster with a SQL Server 2008 Instance losing connection to the shared storage disks. It's an all flash netapp san which has been working fine. To solve I was thinking about removing the SQL Instance from the failover cluster and just running the […]
T-SQL (SS2K8)
Upsert operation between servers - Hello Everyone, We need to perform UpSert operation between multiple tables belongs to different server , can you please suggest any Technical design for this. Suppose a consultant made some changes in UAT  at some point of time then later he wants to migrate same in Production. It may be a new records , updated […]
SQL Azure - Administration
Managed Instance Error Creating Recurring Schedule - BUG??? - When we try to create a SQL Server Agent job schedule that has a recurring frequency type we get the following error: SQL Server Agent feature Schedule job ONIDLE is not supported in SQL Database Managed Instance. Review the documentation for supported options. If we click ok to the message and then edit the unsaved […]
SSRS 2014
Page can't be displayed while accessing the Report server in other Computer - I have set up a Report Server in a Windows 10 client, everything is fine when you try to access it locally, but when I try to access it using another computer, "This page can't be displayed" is the only result that I get. I can ping the computer where the report server is installed, […]
SQLServerCentral.com Website Issues
Unable to subscribe to newsletter using the email entered - I am one of those users that have not received a newsletter since the new site went active.  Can you please reset my email to be OK? Thanks.
 

 

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

 

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