Createprocedure [owner.] name [; program number] [(parameter #1, & hellip; parameter #1024)] [with {recompile | encryption | recompile, encryption}] [forreplication] as program line where the name of the stored procedure cannot exceed 128 words. In each stored procedure, a maximum of 1024 parameters can be set: create procedure [owner.] Name [; program number] [(parameter #1 ,... Parameter #1024)] [with {recompile | encryption | recompile, encryption}] [for replication] as program line where the stored procedure name cannot exceed 128 words. A maximum of 1024 parameters can be set in each stored procedure (SQL server 7.0 or later). The parameter usage is as follows: @ Parameter Name Data Type [varying] [= internal value] [output] each parameter name must have a "@" symbol before it. The parameters of each stored procedure are only used inside the program, the parameter type is applicable to data types supported by SQL server except image.
Declare @ mycounter int
Set @ mycounter = 0/* set variable */
While (@ mycounter <2)/* set the number of cycles */
Begin
Waitfor delay '000: 00: 10'/* delay Time: 10 seconds */
Insert into time_by_day
(Time_id, the_date, the_year, month_of_year, quarter, day_of_month)
Select top 1 time_id + 1 as time_id, the_date + 1 as the_date, year (the_date + 1)
As the_year, month (the_date + 1) as month_of_year, {fn quarter (the_date + 1)
} As quarter, day (the_date + 1) as day_of_month
From time_by_day
Order by time_id desc
Set @ mycounter = @ mycounter + 1
End
Use a cursor
Declare @ a int, @ B int
Declare ccc cursor for select * from test where id> @ id
Open ccc
Fetch next from ccc into @ a, @ B
While (@ fetch_status = 0)
Begin
.......
End
Close ccc
Declare ccc)
This is probably the case. I don't know if the syntax is correct. I haven't used sqlserver recently. I can see how to use cursor by looking at the system stored procedures.