5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

任意のn行のダミーデータを作成する

Posted at

共通テーブル式(CTE)と再帰を使って書きます。
サンプルでは3行のデータを作成。

declare @num int = 3

;with CTE as
(
    select 1 as A
    union all
    select A + 1 from CTE where A < @num
)

select *
from CTE

###実行結果
A
-----------
1
2
3

join してデータをn倍にしたい場合などに使うとよさそうです。

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?