Blog Post

#PASSVOTE 2014

Hello Dear Reader!  The PASS Board of Director elections are upon us again.  We have 3 spots open and 4...

2014-09-24

607 reads

Blogs

T-SQL Tuesday #202: 100 Hours

By

It’s time for T-SQL Tuesday again and this is a great prompt to start...

Exploring DiskANN: Part 2: PQ, SSDs, caching and beam search

By

How I used AI for this postChatGPT to generate images based on info specifically...

T-SQL Tuesday #202: The Two Outages I Won't Ever Forget

By

My T-SQL Tuesday #202 entry for Marlon Ribunal's invitation on memorable SQL Server outages....

Read the latest Blogs

Forums

Performance Regression After Upgrading from SQL Server 2016 to 2022

By abdalah.mehdoini

Bonjour à tous, La semaine dernière, nous avons effectué une mise à niveau de...

Adding new column with DEFAULT

By Thomas Franz

Comments posted to this topic are about the item Adding new column with DEFAULT

How do I connect to a SQL Server database on my ISP?

By Doctor Who 2

I've got a web application for my side business. I've added a SQL Server...

Visit the forum

Question of the Day

Adding new column with DEFAULT

Which number will the COUNT() return after executing the following statements:

DROP TABLE IF EXISTS #test;
CREATE TABLE #test (id INT)
INSERT INTO #test (id)
SELECT *
  FROM GENERATE_SERIES(1, 3) AS gs
;

ALTER TABLE #test ADD flag BIT CONSTRAINT DF_#test_flag DEFAULT 0;
go
UPDATE #test SET flag = 0 WHERE id = 1
UPDATE #test SET flag = 1 WHERE id = 2

INSERT INTO #test (id) VALUES (4)

SELECT COUNT(*)
  FROM #test AS t
 WHERE flag = 0
 

See possible answers