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

A Domain for Data

A domain is a set of possible values (among other definitions). I use this word a lot in my work, often with a problem domain (the thing you're trying to solve) or the domain of possible values (like the US States and Territories list). That last one is interesting, as this is often the set of data we stick in some reference or lookup table to use in a form on a screen.

There is a domain as part of the SQL specification, which I never knew about. I was reading an article from Joe Celko on the CREATE DOMAIN statement. This doesn't exist in SQL Server and T-SQL, but it has been a part of PostgreSQL for quite a few versions. The article talks about the definition of a domain from a few very experienced database design people.

What's interesting is that this could be a list of values, but it could be an expression against which values are checked. For example, we might choose the domain of positive integers, which might require that the value passes some x>=0 where x is the value. That seems OK, though this looks like a CHECK constraint to me, which we already have.

The article is a little light and doesn't give many examples of how or why a domain might be needed or why it might be better than a constraint. Perhaps there are good reasons, but I struggle to think of any. Certainly I am cautious of tightly binding which data is allowed, especially when I find many businesses have rules that often have exceptions.

Would you use a domain for any data in your system? Do you think you have business rules that are firm and set enough to add domains? Perhaps you do, and if you do, that's great. I suspect many of you are like me in that you are careful of where and how many check constraints you use. Those can be very hard to change and remove when an exception occurs, so the fewer the better.

Steve Jones - SSC Editor

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

 
 Featured Contents
SQLServerCentral Article

Windows Clustered MSDTC and SQL Server 2019 mishap

Johan Bijnens from SQLServerCentral

Introduction As you may know, in the early days of SQL Server Clustering, Microsoft advised to provide each clustered SQL Server instance with its own Microsoft Distributed Transaction Coordinator (MSDTC) resource. Since SQL Server 2012 this advice has been withdrawn. Microsoft now recommends to provide your instance with its own MSDTC resource, once you notice the […]

External Article

DAX CASE Statement Functionality using IF, SWITCH and SWITCH True

Additional Articles from MSSQLTips.com

If you don’t know, DAX (Data Analysis Expressions) is a language for creating custom calculations and aggregations in Power Pivot, Power BI, and other data analysis tools. Two functions in DAX come close to replicating the functionality but come with limitations. Which one of these functions should you use?

Technical Article

The State of the Database Landscape in 2025: Insights and trends

Steve Jones - SSC Editor from SQLServerCentral

How are you navigating the database landscape? Our latest report sheds light on the current state of database management and offers valuable insights into how organizations can navigate and simplify the growing complexities of the database landscape.

Blog Post

From the SQL Server Central Blogs - Can You Tell Why a Plan Didn’t Go Parallel?

Grant Fritchey from The Scary DBA

Let’s face it, most of the time, you probably don’t want your SQL Server execution plans to go parallel. After all, that’s why, instead of adjusting the Cost Threshold...

Blog Post

From the SQL Server Central Blogs - Friday Flyway Tips: State-based deployment with Flyway Teams

Steve Jones - SSC Editor from The Voice of the DBA

I was asked about state-based deployments in Flyway Teams, so I decided to show how this can work with a quick demo. This post walks through the process. I’ve...

Microsoft Power BI Quickstart Guide cover

Microsoft Power BI Quick Start Guide: The ultimate beginner's guide to data modeling, visualization, digital storytelling, and more, 3rd Edition

Site Owners from SQLServerCentral

Bring your data to life with this accessible yet fast-paced introduction to Power BI, now in color.

 

 Question of the Day

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

 

Rolling Back CUs

Can I rollback a cumulative update and remove it from my SQL Server instance?

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)

Replacing a NULL II

What is returned from this code in SQL Server 2022?

DECLARE
  @value INT = NULL
, @value2 VARCHAR(20) = NULL;
SELECT COALESCE (@value, @value2, 100.5) AS Result;
GO

Answer: 100.5

Explanation: Unlike ISNULL(), COALESCE() will return a datatype of the highest precedence. Ref: Coalesce - https://learn.microsoft.com/en-us/sql/t-sql/language-elements/coalesce-transact-sql?view=sql-server-ver16

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 - Administration
Log Shipping Not Able to Restore Log Files in Secondary - I'm attempting to set up log shipping from SQL Server 2005 Standard to SQL Server 2017 Standard. I have restored the database in the follow storage layout on the SQL Server 2017 machine: D:\Data\.mdf L:\Logs\.ldf When I execute the restore job and it skips all log backups. I ran restore verifyonly for the log backups […]
SQL Server 2016 - Development and T-SQL
SSIS - ADO Source Datetime Issue - I'm using an ADO Net Source to extract data and running into an issue with timestamps changing before reaching the destination. I can log directly into the source system and see a value should be 2025-03-01 00:03:14 but SSIS is brining it back as 2025-03-01 01:03:14. I put a data viewer on it so this […]
Where to see how a Partition schema and function is defined - Please see the below. The dependencies of a table(the table depends on) shows Partition function and partition scheme. However I cant seem to find how and where this function is defined? I can see only user defined functions? Please guide on this
SQL 2012 - General
DbaTools With Powershell - Omit The Id Column on CSV Export? - I am learning DbaTools in Powershell, and my current project is exporting a CSV file. I've managed to get the code to work; however, there are situations in which I will need to omit the Identity column when exporting.  Is there a way to do this programmatically in DbaTools, so that the CSV file won't […]
SQL Server 2019 - Development
Move Files SSIS Task - Hi I have a task in my SSIS package that moves files from source folder to destination folder.  It works if there are no duplicate files being processed.  That is, suppose fileABC.txt is found in both source and destination folder then something went wrong in the processing from earlier SSIS tasks so I want to […]
String or Binary Truncation Error Strange Behavior (SQL 2019) - Forgot I posted a similar issue back in 2020, String or Binary Truncation Error Strange Behavior, but here we are again, 5 years later with a somewhat similar issue. Here is the message from SQL Server: String or binary data would be truncated in table 'dbo.BAT_Test', column 'NewCode'. Truncated value: ''. Basically, a stored procedure […]
Cummulative Total - Hi I have below query and i want Cummulative Total . Total should be reset on change of Account SELECT ROW_NUMBER() OVER (PARTITION BY Account ORDER BY A."Account") AS "Row No", A."Account" AS "Account",(A."Debit") AS "Debit", (A."Credit") AS "Credit" From Master A Thanks
SQL Azure - Administration
Migrating mission critical database from SQL on Prem to Azure SQL - We are migrating our environments to Azure, it will be a mix of SQL managed instances and Azure SQL instances depending on the different system requirements. We offer realtime service to out clients and need to have minimal downtime hen we make the shift. The first database will be migrated to AzureSQL. Our on prem […]
Transactional Replication from Read replica - If I have Read replica (in Azure SQL MI), can it be used as a Publisher in transactional replication setup. I understand that Replication creates objects some objects in Publisher db, can we use listener name with applicationintent setting anywhere for it use Secondary instead of Primary. AWS DMS works similar to how transactional replication […]
Azure Data Factory
Is there a way to determine an Azure Data Factory Trigger's "next run time"? - Many job schedulers (e.g., SQL Agent, Airflow, Azure Logic Apps) can report when a scheduled trigger will run next. Is similar functionality available in ADF?
Anything that is NOT about SQL!
Fantasy Football 2025 - The thread for the league in 2025. Players from last year have priority.
SQLServerCentral.com Website Issues
Everyone is a Newbie? - Everyone seems to be a Newbie with zero points today! Browser = Chrome
SQL Server 2022 - Administration
SQL availability group and file server role answering from the same name - Hello, I'm tasked with setting up a 2 node server cluster that will host a MS SQL availability group. I have the servers setup and the AG looks to be working well. However, there is also a requirement to hang a share off of one of the drives. I'm not crazy about this requirement, but […]
Installing SQL FCI Instance certificates - SQL FCI Instance certificates I have a client who has a requirement for certificates bound to the instance in a FCI environment. I have create the certificate and installed on both nodes, but I get a cluster error when failing over. The environment setup Node1 Node2 FCI Instance name\SQLInstance   Have set the FCI and […]
SQL Server 2022 - Development
SSIS how to manage source control with multiple packages / projects - We've got upwards of 40 SSIS solutions all stored in one GIT repository in teams.  I thought this was the proper way to go.  The problem is managing this when I am in the middle of developing one of those solutions.  What I usually do is just make a copy of the folder the solution […]
 

 

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

 

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