Problems displaying this newsletter? View online.
SQL Server Central
The Voice of the DBA

Code Building Code

The dream for some people is to have an Artificial Intelligence (AI) system that you use to describe some requirements and it will build an application that meets your needs. Certainly some AI and ML systems have reduced the need to write code for portions of an application, but I don’t think there is any AI framework that can build an entire application from scratch.

I was reading a blog post recently on using metadata in our database to produce a CREATE TABLE statement that could hold the output of a query. It’s not AI, but this is something I’ve done in the past, using code to help me get work done.

Excel was one of my earliest helpers and still is. I find myself sometimes using Excel to build a series of statements that follow a pattern, but the contents of which might be based on some result set. A common example is a set of inserts based on some data. I use values in cells to build up a final statement and then copy these to SSMS or another tool and execute them. It’s quick and dirty, but it works well.

In the past I have written code that would build other object code, usually to provide some API constructs for developers. In a few environments, we have had some standards about how to structure tables, views, and stored procedures, including at times an API-like standard that required certain functionality be implemented in stored procedures. Using a code writing stored procedure allowed me to quickly ensure that the required stored procedures were created and modified as tables were added or altered. This also ensured that we kept all these changes in sync, without depending on my to review every part of the API.

I don’t know that I’ll see a true AI system that we can give a few specifications to and have it build a system, but the more we implement standards and known structures, the more we can use code to help us ensure those standards are implemented in a consistent manner. Using templates in our work, such as powerful snippets in SQL Prompt, along with code analysis that looks for poor practices can help us write better applications. Even if it doesn’t do all the work, these helper tools certainly improve the quality of the code we do write.

Steve Jones - SSC Editor

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

Redgate SQL Monitor
  Featured Contents

More On Column Order Indexes – Part 2

Mike Byrd from


Continued analysis of index architecture with revised clustered index. Part 2 of Column Order Indexes

Configuring Azure SQL Databases Using Azure Resource Manager Templates

Additional Articles from Database Journal

Azure SQL

Template-based provisioning simplifies deployment and promotes principles of DevOps and Infrastructure as Code, making it the recommended method for implementing cloud-based services. However, its benefits extend beyond initial implementation, since you can apply it to configuring and maintaining existing Azure SQL Database instances. In this article, you explore an example of this approach.

SQL in the City Summits – UK, US & Down Under

Press Release from Redgate


Redgate are inviting senior data professionals to attend one of the upcoming SQL in the City Summit events taking place in April, May and June. If you’re interested in learning how your business can benefit from implementing Compliant Database DevOps this event is for you. Find out who’s presenting and register for a Summit near you today. Register now

From the SQL Server Central Blogs - Delete activity in Azure Data Factory – Cleaning up your data files

Rayis Imayev from SQLServerCentral Blogs

(2019-Mar-20) File management may not be at the top of my list of priorities during data integration projects. I assume that…

From the SQL Server Central Blogs - Women in Tech Talk Tech

SQLEspresso from SQLServerCentral Blogs

March is Women’s History Month, to celebrate the PASS Women in Technology Virtual Group (@PASS_WIT) held a webcast featuring prominent…


  Question of the Day

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


Creating My Table

I create a new user in my database that only has the dbo schema with this code:
The user logs in and executes this:
CREATE TABLE JoeDev.Articles (someid INT)
What happens?

Think you know the answer? Click here, and find out if you are right.


Redgate Database Devops


  Yesterday's Question of the Day (by Steve Jones - SSC Editor)

Adding Custom Error Messages

Who can add custom error messages to the sys.messages table?

Answer: Users with sysadmin or serveradmin roles.

Explanation: The sysadmin and serveradmin roles allow adding custom error messages. Ref: sp_addmessage -

Discuss this question and answer on the forums


Database Pros Who Need Your Help

Here's a few of the new posts today on the forums. To see more, visit the forums.

Reverse engineering data model in Azure MSSQL - Hi, I have a database that has been created in Azure MSSQL Server. It has a lot of tables with Primary/Foreign Keys. I’d like to create an ER diagram automatically. Are there tools available that can do that? Please advise. Thank you!
Suggestion for newsletter format - I loved the old newsletter format:  To the left there was a table of contents that you could glance at to find topics of interest.  As a very busy developer, this helped me zoom in on what I was interested in.  The old format made very efficient use of space:  It was single-spaced and took […]
A new topic of code formatting - Copying text from a post Dear Experts, i need help in calculating time difference between two dates portion by Date, the difference will be calculated with the first day last Attendance = 1 with very next Attendance =1 of next day. and same will repeat second day last Attendance = 1 with very next Attendance […]
Prepopulate users Favourites in Reporting Services Web Portal - We’ve created a hierarchy of folders in the reporting services web portal for SQL Server 2016 to control security around reports at folder and subfolder level but some end users prefer to see all their reports in one long list! I’ve pointed out they can add their favourite reports to the Favourites page but is […]
Script which reports a user has access to in reporting services - Does anyone have a script I can run to return a list of all reports a user has access to please?
Forums Top Menu Options - Can we have a description on what the options for the forums display are? Most Popular, Most Replies, and Most Active seem almost the same thing. Are Latest Topics defined by the date/time the OP was posted or the last reply? If they’re defined by the OP, can we have an option for Latest Replies […]
Creating users with limited access - Hi all We’ve got a SQL-only account with too many permissions (and everybody knows the password!) that’s used for everything and I’m trying to have a tidy-up. It’s linked to an AD account (unfortunately with the same password that’s also got too many permissions on the server). What I want to do :- Create an […]
Report Server, Help with SQL, How to calculate NextRunTime for a subscription - Unfortunately the SQL server does not give any value in the column
Current day from current week of the year - I need help to find current day from current week of the year, and start and end dates of the current week. For eg – Today is Monday, April 8th, 2019. 1st day of the week. This is the 15th week. My output should be 1, 04/08/2019, 04/14/2019.
"Secure" BULK INSERT from Network File Share. - Hello, I have a scenario that requires the import of flat files from a Network File Share to a SQL server 2016 DB. There is an automated process that uses the BULK Insert functionality to load the files into tables based on some configuration tables. Recently this has been raised as a security exception as […]
Load azure data warehouse - Hi I have on-premises sql server database. I need to load data from this DB to azure DW. What is the best solution? I am good in classic ETL using SSIS. When I search google, there are many options like traditional ETL(SSIS), ADF, Polybase, Azure BLOBs I am confused which one to use. I need […]
MDF is not primary database file error - Simply, i am trying to attach mdf file using SSMS. Why I am getting this error: Regards, Damian
Missing Articles/Editorials - Hi, I always enjoy reading editorials created by community and usually go back and leverage from them since these are valuable contents and helping me immensely to make myself better. Now, I’m coming across some missing contents and when I tap on the link nothing shows up but an empty page. Here are some links; […]
Regarding DBA certification - Hi All, I have been working as a DBA and since one year, managing SQL Server 2016 servers including Always On etc. I would like to go for a certification related to DBA now. One I did was long ago on SQL Server 2005 MCTS. Hope Exam 70-764 is the most suitable for me, please […]
job fail because of the set options - Hi everybody, So i have an update query that works just fine when i execute it. However when i run it as a job, it displays the following error : “Update Failed because the following Set options have incorrect settings : ‘Quoted identifier’ Verify thatSET options are correct for use with indexed Views and/or indexes […]


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 This newsletter was sent to you because you signed up at
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.


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