Viewing 15 posts - 1,936 through 1,950 (of 2,171 total)
Yes, I did benchmark your code Razvan. Did you try your test-code yourself?
Running your test-code above gives 763 milliseconds for my function and 1,563 milliseconds for your function.
Mine is faster and...
N 56°04'39.16"
E 12°55'05.25"
July 19, 2006 at 9:13 am
The best way would be to use this function
CREATE FUNCTION dbo.GetEasterSunday
(
@Y INT
)
RETURNS SMALLDATETIME
AS
BEGIN
DECLARE @EpactCalc INT,
@PaschalDaysCalc INT,
...
N 56°04'39.16"
E 12°55'05.25"
July 19, 2006 at 9:04 am
Right on spot, if not the case where original poster actually has an employee with id 0.
Change code above to
SELECT a.ApplicantName,
a.Specialization
FROM @Applicant a
LEFT JOIN @Shortlist s...
N 56°04'39.16"
E 12°55'05.25"
July 19, 2006 at 7:14 am
Ok, ok ok ![]()
Still don't get proper result with date range 1899-12-29 and 1900-01-03.
Running
select datediff(d, '19000101', '1900-01-03')/7 - datediff(d, '19000102', '1899-12-29')/7
gives...
N 56°04'39.16"
E 12°55'05.25"
July 19, 2006 at 6:35 am
Yes, it works well if not more than one of the two dates already is a monday. Using this code
select (datediff(d, '20060213', '20060724') + 1)/7 - datediff(d, '20060213',...
N 56°04'39.16"
E 12°55'05.25"
July 19, 2006 at 6:00 am
The formulas used in this topic assumes the Earth is a perfect sphere, which it is not.
The average radius of 3,958.755 miles is between the semi-major axis around the equator...
N 56°04'39.16"
E 12°55'05.25"
July 19, 2006 at 5:51 am
True, and it works too. But maybe not that versatile?
N 56°04'39.16"
E 12°55'05.25"
July 19, 2006 at 3:35 am
There is really no need for calculating the distance with the ACOS/ATAN formula, since the Earth's surface doesn't curve that much for 1.5 miles (2.4 km). Pythagoras theorem will suffice...
N 56°04'39.16"
E 12°55'05.25"
July 19, 2006 at 3:11 am
Another possibility is that you create a cartesian product (CROSS JOIN) between the two tables.
Something like
SELECT Categories.Category,
Groups.Group,
Groups.Block
FROM Categories
CROSS JOIN Groups
OR
SELECT DISTINCT Categories.Category,
Groups.Group,
Groups.Block
FROM Categories
CROSS JOIN ...
N 56°04'39.16"
E 12°55'05.25"
July 19, 2006 at 2:37 am
Here is a shorter version
-- Do the work
SELECT e.Employee,
c.Code,
c.Description,
c.Required,
ISNULL(h.Hours, 0) Hours
FROM @Employees e
CROSS JOIN @Codes c
LEFT JOIN @Hours h ON h.Code_ID = c.ID...
N 56°04'39.16"
E 12°55'05.25"
July 18, 2006 at 4:57 pm
-- Find duplicate data in history table
SELECT Terc,
Val,
COUNT(*)
FROM Historic
GROUP BY Terc,
Val
HAVING COUNT(*) > 1
-- Find duplicate values between the two tables
SELECT ...
N 56°04'39.16"
E 12°55'05.25"
July 18, 2006 at 4:47 pm
-- Prepare test data
declare @employees table (id tinyint, employee char(4))
insert @employees
select 1, 'Jack' union all
select 2, 'Jill'
declare @codes table (id tinyint, code smallint, description varchar(5),...
N 56°04'39.16"
E 12°55'05.25"
July 18, 2006 at 4:17 pm
Yes, I tried your code. I am using SQL Server 2000 with SP4. I copied all your code and pasted it into QA and ran it. The output above is what...
N 56°04'39.16"
E 12°55'05.25"
July 18, 2006 at 3:17 pm
More efficient?
I doubt that, since you concatenate and accumulated update all rows in @table, even the duplicates. Imagine you have thousands of UserIDs where all of them have a small number...
N 56°04'39.16"
E 12°55'05.25"
July 18, 2006 at 7:43 am
-- prepare test data
declare @table table (UserID tinyint, usertext char(3))
insert @table
select 1, 'ABC' union all
select 1, 'DEF' union all
select 2, 'ABC' union all
select 3, 'ABC' union...
N 56°04'39.16"
E 12°55'05.25"
July 18, 2006 at 3:30 am
Viewing 15 posts - 1,936 through 1,950 (of 2,171 total)