Scripts

Technical Article

Finding the Nth Maximal Value

This procedure gets a tablename, column and an integer number N as parameters and finds the Nth maximum value of the column's value in a table for example :  running it with 'products', 'UnitPrice' , 13 ,  @reswill get the 13TH largest value of unitprice from products is no such N exist an error message […]

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

You rated this post out of 5. Change rating

2002-07-10

268 reads

Technical Article

Find Duplicated rows

This is a very simple and small stored procedure which will help you identify repeated rows on any given table.  This is specially useful for situations when you want to clean up a table and add a primary key on it, but you cannot until all duplication is eliminated.  Only two parameter are necessary; table […]

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

You rated this post out of 5. Change rating

2002-07-08

1,098 reads

Blogs

10 Decisions to Make Before You Create A Fabric Workspace

By

Creating a Fabric workspace takes about 30 seconds. Restructuring workspaces after people have built...

Flyway Tips: Object History

By

It’s a small change, but a handy one. Flyway Desktop (FWD) now includes the...

Car Update September 2026

By

Software is hard. While I love our Lucid Gravity, I realize that they are...

Read the latest Blogs

Forums

Alamat BCA KCP Cempaka Putih Telp:08218520153

By layanan_Bca88

WhatsApp CS 628218520153 Jl. Letjen Suprapto No.30 EF, RT.7/RW.2, Harapan Mulya, Kec. Kemayoran, Kota...

Alamat BCA KCP Menteng Telp:08218520153

By m4rt1n4

WhatsApp CS 628218520153 Jl. HOS. Cokroaminoto No.83, RT.3/RW.5, Menteng, Kec. Menteng, Kota Jakarta Pusat,...

Alamat BCA KCP Wahid Hasyim Telp:08218520153

By R4nt4u

WhatsApp CS 628218520153 Jl. K.H. Wahid Hasyim No.82, RT.15/RW.3, Kb. Sirih, Kec. Menteng, Kota...

Visit the forum

Question of the Day

Adding new column with DEFAULT II

Which number did the two COUNT(*) return:

DROP TABLE IF EXISTS #tmp
CREATE TABLE #tmp (id INT NOT NULL)

INSERT INTO #tmp (id) 
SELECT gs.value
  FROM GENERATE_SERIES(1, 5) AS gs

ALTER TABLE #tmp ADD my_value INT NOT NULL CONSTRAINT df_tmp_my_value DEFAULT 1

SELECT COUNT(*)  FROM #tmp AS t WHERE my_value = 1

ALTER TABLE #tmp DROP CONSTRAINT df_tmp_my_value

ALTER TABLE #tmp ADD CONSTRAINT df_tmp_my_value DEFAULT 2 FOR my_value

SELECT COUNT(*)  FROM #tmp AS t WHERE my_value = 1

See possible answers