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 |
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2006-07-19 : 14:31:08
|
| I need to create a table in a stored procedure that has all dates incremented by 1 week between a start date and today. This is done because I am builing a system with recurring billing for weekly,monthly,yearly,etc. For each Customer I need to make sure to bill them for the next incremented billing period. I decided to have a table that does nothing besides keep track of the customers billing dates.Basically I want to say --Declare @Date datetime,@StartDate datetime ,@EndDate Datetime,@CustID intset CustID = 1set @Startdate = cast('01/01/2000' as datetime)set @Enddate = Getdate()Set @Date = @StartDatewhile @Date <= @EndDateBegininsert into #Table(Customer,Date)Value(@CustID,@Date)@Date = DateAdd(week,1,@Date)End---and do the same for monthly,yearly,etc.Is this the best way to do that, I need to do this for a lot of differant records, so I need to approach this the most efficiant way. Do I have any other options?ThanksAlso this is likly a very easy question, but if I wanted to set 3 variables at one time of a query, how would I do that.For a single item I can do set @variable1 = Select a from Table1orSelect @Variable1 = Select a from table1but what if I wanted to set 3Select @Variable1,@Variable2,@Variable3 = Select a,b,c from Table1Will this work? |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-07-19 : 15:14:13
|
| >> but what if I wanted to set 3declare @a varchar(3), @b varchar(30)Select @a = Code, @b = [Name] from table1Print @aPrint @bSrinika |
 |
|
|
|
|
|
|
|