Viewing 15 posts - 166 through 180 (of 429 total)
Vasc can give an elegent solution. I guess this will solve the problem.
SET NOCOUNT ON
DECLARE @F TABLE
(
[Key] INT NULL,
X1 INT NULL,
X2 INT NULL,
X3 INT NULL,
X4 INT NULL
)
INSERT @F
SELECT 1, 12,...
August 19, 2005 at 11:16 am
SET NOCOUNT ON
DECLARE @F TABLE
(
[Key] INT NULL,
X1 INT NULL,
X2 INT NULL,
X3 INT NULL,
X4 INT NULL
)
INSERT @F
SELECT 1, 12, 1, 2, null UNION ALL
SELECT 2, 1, 2, null, null UNION ALL
SELECT 12, 2, null, null, null UNION ALL
SELECT 14, null, null,...
August 19, 2005 at 8:49 am
That application resides on SQL Server 6.5
Still Formula step lenths are different some elements use all steps and some only a few.
August 18, 2005 at 2:57 pm
How will you determine how many variables to declare
var1, var2 ... varn
Since you declare the variables already. I don't see a need for a loop to assign values to them.
Provide...
August 18, 2005 at 2:53 pm
We have one such situation
One Invoice will have 100 or more elements upto 2000 now
We have to calculate the invoice amount based on a formula slected for each element
users...
August 18, 2005 at 2:45 pm
CREATE PROCEDURE usp_WeekDays
(
@pMonth INT = NULL,
@pYear INT = NULL
)
AS
SET NOCOUNT ON
DECLARE @Days INT
DECLARE @CurDate DATETIME
DECLARE @MyDates TABLE
(
MyDate DATETIME
)
SET DATEFORMAT MDY
SELECT @pMonth = COALESCE(@pMonth, DATEPART(MONTH, GETDATE()))
SELECT @pYear = COALESCE(@pYear, DATEPART(YEAR, GETDATE()))
SELECT @Days = 0
SET...
August 18, 2005 at 12:47 pm
You are welcome(d).
Function returning dates is hard coded for year 2005. You might want to change it to the dates you need.
August 18, 2005 at 12:28 pm
Here is the view with function
SET NOCOUNT ON
GO
CREATE FUNCTION myDates()
RETURNS @myDates TABLE
(
myDate DATETIME
)
AS
BEGIN
DECLARE @AA INT SET @AA = 0
WHILE @AA < 365
BEGIN
INSERT @myDates VALUES (DATEADD(DAY, @AA, '01/01/2005'))
SET @AA = @AA +...
August 18, 2005 at 11:00 am
Yes Noel considering if we have a table @MyDates with dates. The Select statement can be in a view.
SET NOCOUNT ON
DECLARE @myDates TABLE
(
myDate DATETIME
)
DECLARE @AA INT SET @AA = 0
WHILE @AA...
August 18, 2005 at 10:52 am
CREATE VIEW myView
AS
SELECT CASE WHEN (DATEPART(DAY,GETDATE()) < 8 AND DATENAME(WEEKDAY,GETDATE()) = 'Monday')
OR
(DATEPART(DAY, DATEADD(DAY, 7, GETDATE())) < 8 AND DATENAME(WEEKDAY,GETDATE()) = 'Friday')
THEN 'EVENT'
ELSE
NULL
END
To list all dates...
August 18, 2005 at 10:24 am
SELECT Product, SUM(SaleQty)/COUNT(DISTINCT CONVERT(VARCHAR, DATEPART(MONTH, SaleDate)) + CONVERT(VARCHAR, DATEPART(YEAR, SaleDate))) AvgSalesPerMonth
FROM
orderdetail
GROUP BY Product
Will be more accurate
DateDiff Remi posted is better since if there are no sales on a...
August 18, 2005 at 9:17 am
Noel is right Query should be
SELECT Product, SUM(SaleQty)/12.0 AvgSalesPerMonth
FROM
orderdetail
GROUP BY Product
Corrected in next post.
August 18, 2005 at 9:13 am
DECLARE @MyDate TABLE
(
DateID INT,
myDate DATE
)
DECLARE @myTime TABLE
(
DateID INT, -- Referencing MyDate.DateID
MyTime TIME
)
Just wondering how to use Time DataType
August 18, 2005 at 9:11 am
I can think a date type. We may need to store just the date not time. I don't see a need to have just Time without a date. Is to...
August 18, 2005 at 9:03 am
You don't remember Remi. Check this.
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=207434#bm207636
August 18, 2005 at 8:50 am
Viewing 15 posts - 166 through 180 (of 429 total)