SQLServerCentral Editorial

The Second Half of 2021

July is starting, and with it we move to the second half of 2021, or H2 2021 for those of you that like the planning shorthand on roadmaps and project manager boards. The first half of 2021 has felt like a big of progress in the world, as we try to recover from the pandemic […]

External Article

What does SET NOCOUNT ON do?

When you’re working with T-SQL, you’ll often see SET NOCOUNT ON at the beginning of stored procedures and triggers. What SET NCOUNT ON does is prevent the “1 row affected” messages from being returned for every operation. Read Brent's blog to see him demo it by writing a stored procedure in the Stack Overflow database.

SQLServerCentral Editorial

Happy Birthday USA!

This is the Fourth of July weekend here in the US when we celebrate the birth of the country based on the publication of the Declaration of Independence. For those who don't know, this celebration mostly consists of fireworks and outdoor cookouts. However, at our house we've always tried to do a little bit more […]

SQLServerCentral Editorial

Learning Intentionally with a List

We're coming up on the middle of the year, and I wonder if you are improving your career this year? Did you make plans and are you sticking to them? I've been tracking progress on my goals, and so far mediocre progress. It's tough to learn, but even tougher to learn when you don't have […]

Blogs

The Book of Redgate: We Value Teams

By

This value is something that I still hear today: our best work is done...

Troubleshooting TempDB Log Full Errors When SSMS Won’t Connect

By

Have you ever received the dreaded error from SQL Server that the TempDB log...

Accelerating AI with Confidence: Why Microsoft Purview is Key to Responsible Innovation

By

Artificial intelligence is no longer a distant concept. It is here, embedded in the...

Read the latest Blogs

Forums

Planning for tomorrow, today - database migrations

By John Martin

Comments posted to this topic are about the item Planning for tomorrow, today -...

Bottlenecks on SQL Server performance

By runarlan

We have a BI-application that connects to input tables on a SQL Server 2022...

Is there some good routines for updating SQL Server database objects with GitHub

By Rod at work

At work we've been getting better at writing what's known as GitHub Actions (workflows,...

Visit the forum

Question of the Day

The Tightly Linked View

I try to run this code on SQL Server 2022. All the objects exist in the database.

CREATE OR ALTER VIEW OrderShipping
AS
SELECT cl.CityNameID,
       cl.CityName,
       o.OrderID,
       o.Customer,
       o.OrderDate,
       o.CustomerID,
       o.cityId
 FROM dbo.CityList AS cl
 INNER JOIN dbo.[Order] AS o ON o.cityId = cl.CityNameID
GO
CREATE OR ALTER FUNCTION GetShipCityForOrder
(
    @OrderID INT
)
RETURNS VARCHAR(50)
WITH SCHEMABINDING
AS
BEGIN
    DECLARE @city VARCHAR(50);
    SELECT @city = os.CityName
    FROM dbo.OrderShipping AS os
    WHERE os.OrderID = @OrderID;
    RETURN @city;
END;
go
What is the result?

See possible answers