SQLServerCentral - www.sqlservercentral.com

A community of more than 1,600,000 database professionals and growing

Featured Contents

The Voice of the DBA

The Master of the Schema

"The database ... should be the master of the schema".

It's not often I see an application developer talk about the importance of the database, or at least that the database (and data) are very important to the success of the application, but in this case, that's what I saw. The quote is from this blog, which talks about the problems of the code first approach to building an application. It's from a Java development company, though it's their jooQ product blog that actually generates Java code from the database, so they get the need to pay some attention to the database.

The thrust of the article is that using an ORM is fine, but this isn't necessarily the best way to design your datastore if you need a relational system. There will be mistakes made in naming objects, in structuring them and ensuring indexes exist and more. The longer you go with generated database code from some code-first type system, the more issues you might have later as you try to modify both the application and database, especially the database, since you can't drop it and recreate it.

If we could drop the tables and rebuild them, life would be great. Maybe we should keep copies of data on the clients, and just reload the necessary data after a deployment... It would make my life easier as a database professional, but I suspect this isn't the best way to ensure data quality and consistency (not to mention completeness).

I agree that if you're building an application, you should go database first. At least start with some basic structures and learn to modify them. The practice you get modifying code, with scripts not GUIs, will be invaluable later to both developers and DBAs/admins. You'll start getting practice and understand what it means to deploy scripts to your database. After all, making schema changes with scripts in your development database is the first "practice" you get for deployment. If you can't get the scripts to work here, how would you have any confidence they'll work in production?

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.1MB) 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
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

Webinar

SQL Server monitoring for a streamlined development process

Redgate’s James King will talk you through the process of monitoring your SQL Servers to ensure you are ready and able to efficiently keep track of your estate.
Register now

Featured Contents

 

Using pw-inspector in Brute Force attack on SQL Server

Anil Kuhat from SQLServerCentral.com

In this article we're going to explore the world of brute force attacks and pwd-inspector for tests with SQL Server More »


 

How to Remove Transparent Data Encryption From a Database

Additional Articles from Database Journal

There may be a time when you want to turn off transparent data encryption on one of your TDE enabled databases. In this tip, Greg Larsen shows you how simple it is to remove Transparent Data Encryption. More »


 

Practical PowerShell Processes with SQL Change Automation

How to use the PowerShell cmdlets of SQL Change Automation to take the source code of a database from a directory, validate it, document it and then create a NuGet package of it. More »


 

From the SQLServerCentral Blogs - ArcGIS Maps for Power BI: Free vs. Paid version

Rayis Imayev from SQLServerCentral Blogs

(2018-July-25) I like the ESRI company slogan, "The Science of Where". Hopefully, it will help someone not to get lost in... More »


 

From the SQLServerCentral Blogs - Power BI Custom Visuals Class (Module 112 – Acterys Matrix Light)

Devin Knight from SQLServerCentral Blogs

In this module you will learn how to use the Acterys Matrix Light. Acterys Matrix Light is designed primarily for... More »

Question of the Day

Today's Question (by Steve Jones):

I started tracking sales for my side business by weeks. Since the volume is low, I decided to store the data in a table that tracks the total sales for each week of the year. Here is a sample of some data:

 SalesWeek SaleTotal 1 50.00 2 70.00 4 60.00 7 40.00 8 80.00

I send some marketing emails out, but I'm not very consistent.  I want to see if I'm missing sales on those weeks where I didn't send an email. I decide to write this code that will help me analyze the sales for all weeks, populating 0s in the weeks where there are no sales.

 WITH myTally(n) AS (SELECT n = ROW_NUMBER() OVER (ORDER BY (SELECT null)) FROM (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10)) a(n) CROSS JOIN (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10)) b(n) ) SELECT xxxx ,        COALESCE(s.SaleTotal, 0) AS SalesTotal FROM myTally m yyyy dbo.Sales s ON m.n = s.SalesWeek ORDER BY m.n

What should I replace the xxxx and yyyy with to get the report of sales for all weeks, both passed and future? (choose 2)

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 2 points 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

The Phoenix Project: A Novel about IT, DevOps, and Helping Your Business Win

The company's new IT initiative, code named Phoenix Project, is critical to the future of Parts Unlimited, but the project is massively over budget and very late. The CEO wants Bill to report directly to him and fix the mess in ninety days or else Bill's entire department will be outsourced.  Get your copy from Amazon today.

Yesterday's Question of the Day

Yesterday's Question (by Steve Jones):

If I run this statement in SQL Server 2017,

 SET FIPS_FLAGGER

What are the options for the values I can use as a parameter?

Answer: OFF, ENTRY, INTERMEDIATE, FULL

Explanation:

There are four possible settings.

  • OFF
  • ENTRY
  • INTERMEDIATE
  • FULL

These correspond to the level of checking the FIPS ISO standard.

Ref: SET FIPS_FLAGGER - click here


» 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.

SQL Server 2017 : SQL Server 2017 - Development

error in STRING_SPLIT - Hello everyone Who has an idea please about the exact error of the STRING_SPLIT command CREATE TABLE .(      (50) NOT NULL,     ...

How to split a | delimited string into multiple columns in a query? - Hi, I have the following query: SELECT     rc. AS ,    cd. AS ,    CASE         WHEN CHARINDEX(':', cd.Name) <> 0 THEN   &

Duplicate records - Hi All: I appreciate your help with this situation: After creating a union between 2 tables in a CTE, there are some contracts...


SQL Server 2016 : SQL Server 2016 - Administration

SSMS failing to install on windows 10 - Ssms keeps hanging on the isolated VS step and fails with error 80070643

Index rebuilding on a AWS RDS SQL server instance - Hi, Is there a need for Index rebuilding for the AWS RDS SQL server -2016 version, considering RDS SQL server...

What does your backup process look like? - Hi, I'd be interested to hear how most of you have your backups set up. I know a lot of it...


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

Joins clarification - Let's say I have Table A and Table B. Table A can join onto Table B because both tables have a...

SSRS Report version compatibility issue with 2016 to 2012 - Hi Every one, I hope, you are doing good.  I am facing a challenges in SQL Server Reporting Services when uploading...

Partioning Huge Table (650GB about) - Hi all, in my data warehouse (SQL Server 2016 Std) I need to maintain 36 (!!) versions of a table in order...


SQL Server 2014 : Administration - SQL Server 2014

Urgent:Transaction Rollback - Hi Experts, We have a procedure in database A which is inserting 10 millions records from a table in a database...

Error 7929, Check statement aborted. Database contains deferred transactions. - Around 12:51 this morning I was paged because the mssql service had restarted unexpectedly.  I investigate and found what appear...

Problem Converting DATE. Trying to Purge Data Oldest than 30 days from Performance Counter Table where date column is char (24) - Hello Acttually i have a regular MSFT performance monitor counter running, which counters are being collected into a SQL Server table. Because...


SQL Server 2014 : Development - SQL Server 2014

Count the amount of times values appear in the database - Hello, I have a table of "jobs" which I need to export to an online accounting software. What I need to...


SQL Server 2012 : SQL 2012 - General

Copy all objects (tables, views, functions, stored procedures) from one DB to another DB - I need to copy some selected objects (tables, views, functions, stored procedures) from one DB (Order) to another DB (OrderHistory) Which...

Huge number of tables - Hi all, I've inherited a situation where we have a business critical system with gigantic number of tables, 240,000 - yes, nearly...

BCP Error - Hi All: I'm trying to import data using bcp however, my I keep getting the below  message. I have checked the...


SQL Server 2012 : SQL Server 2012 - T-SQL

Looking for an idea how to construct this T-SQL Select Statement - I have 3 Joined tables in a following select statement: Select A.AgentID, B.AgentSupervisorID, HADDR.AgentAddress From TableA  A Join TableB B  on <...>...


SQL Server 2008 : SQL Server 2008 - General

DATEADD YYYYMM - This gives me last month, can't figure out next month.  DECLARE @yrMo

Difference between Fragementation in percent vs Page count in Index physical stats. - I would like to know about Fragementation in percent vs Page count. Whenever I tried to reorganize or rebuild the...


Career : Events

The SQL Saturday Thread - As popular as SQL Saturday is, I'm surprised that nobody created a thread dedicated to SQL Saturday, so I created...

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