Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
darms21
Yak Posting Veteran
54 Posts |
Posted - 2012-06-18 : 15:33:32
|
Can someone assist in forumulating a store procedure that will take a parameter "NumberOfTimes" and create that many entries into a table? |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-06-18 : 15:51:00
|
[code]CREATE TABLE #a(i INT);GOCREATE PROCEDURE #b @i INT=0 ASSET NOCOUNT ON;WITH n(n) AS (SELECT 1 UNION ALL SELECT n+1 FROM n WHERE n<@i)INSERT #a(i)SELECT n FROM n WHERE @i>0;GOEXEC #b -- inserts nothingEXEC #b 1 -- inserts 1 rowEXEC #b 2 -- inserts 2 rows[/code] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-18 : 22:51:59
|
[code]CREATE PROCEDURE #b @i INT=0 ASINSERT #aSELECT numberFROM master..spt_valuesWHERE type = 'p'AND number BETWEEN 1 AND @iGO[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|