Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

2005 to 2000

 
   Database Help (Home) -> Programming RSS
Next:  update query help  
Author Message
Paulo Roberto Bianchi de

External


Since: Jul 14, 2010
Posts: 1



(Msg. 1) Posted: Wed Jul 14, 2010 1:25 pm
Post subject: 2005 to 2000
Archived from groups: microsoft>public>sqlserver>programming (more info?)

Is it possible to convert a sql2005 features to sql2000?
Because the ISP server there's no way to install the 2k5 server. Or do you
have a statment that can generate a table filled only with the workdays of a
year on ms sql 2000. THank you very much
------------------------------------------------------------------------------------------

SET STATISTICS IO ON
GO

SET DATEFIRST 7 -- Default é 7 (Domingo)
GO

DECLARE @StartYear AS INT
DECLARE @EndYear AS INT

SET @StartYear = 2010;
SET @EndYear = 2010;

WITH Holidays
AS ( -- Alimentar com os Feriados
SELECT Date = CAST('19000101' AS DATETIME)
UNION ALL
SELECT Date = CAST('19001225' AS DATETIME)
UNION ALL
SELECT Date = CAST('19001102' AS DATETIME)
UNION ALL
SELECT Date = CAST('19001115' AS DATETIME)
) ,
Years
AS ( SELECT YYYY = @StartYear
UNION ALL
SELECT YYYY + 1
FROM Years
Where YYYY < @EndYear
) ,
Months
AS ( SELECT MM = 1
UNION ALL
SELECT MM + 1
FROM Months
WHERE MM < 12
) ,
Days
AS ( SELECT DD = 1
UNION ALL
SELECT DD + 1
FROM Days
WHERE DD < 31
) ,
DatesRaw
AS ( SELECT YYYY = YYYY,
MM = MM,
DD = DD,
ID_Date = YYYY * 10000 + MM * 100 + DD,
DateString = CAST(YYYY * 10000 + MM * 100 + DD AS
VARCHAR),
Date = CASE WHEN ISDATE(YYYY * 10000 + MM * 100 +
DD) = 1
THEN CAST(CAST(YYYY * 10000 + MM * 100 +
DD AS VARCHAR) AS DATETIME)
ELSE NULL

END
FROM Years
CROSS JOIN Months
CROSS JOIN Days
WHERE ISDATE(YYYY * 10000 + MM * 100 + DD) = 1
)
SELECT DatesRaw.*,
DayOfWeek = DATEPART(dw, DatesRaw.Date),
CalendarDaySequential = CAST(DatesRaw.Date AS INT),
WorkingDay = CAST(CASE DATEPART(dw, DatesRaw.Date)
WHEN 1 THEN 0 -- Sunday
WHEN 7 THEN 0 -- Saturday
ELSE CASE
WHEN recurring.Date IS NULL AND
fixed.Date IS NULL THEN 1
ELSE 0
END
END AS BIT)
INTO #Calendar
FROM DatesRaw
LEFT JOIN Holidays recurring
ON recurring.Date = DATEADD(Year, 1900 - YEAR(DatesRaw.Date),
DatesRaw.Date)
LEFT JOIN Holidays fixed
ON fixed.Date = DatesRaw.Date
GO

-----------------------------------------------------------------------------------------------------------

select Date
FROM #Calendar wd1 where workingDay=1 and date >= '20100701' and date <=
'20100731' --->mostra apenas July/2010
ORDER BY ID_Date
GO

drop table #Calendar

 >> Stay informed about: 2005 to 2000 
Back to top
Login to vote
Erland Sommarskog2

External


Since: May 30, 2004
Posts: 2061



(Msg. 2) Posted: Wed Jul 14, 2010 7:25 pm
Post subject: Re: 2005 to 2000 [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Paulo Roberto Bianchi de Oliveira (poliveira@intectecnologia.local) writes:
> Is it possible to convert a sql2005 features to sql2000? Because the ISP
> server there's no way to install the 2k5 server. Or do you have a
> statment that can generate a table filled only with the workdays of a
> year on ms sql 2000. THank you very much

But for crying out loud! Find a new ISP, and the current rot away
with its SQL 2000!

In this particular case, it's fairly easy. Rather than using a number
of CTEs, use a number nested derived tables:

FROM (SELECT ...
FROM (SELECT ...
FROM ...) AS Years
CROSS JOIN (SELECT FROM ... ) AS Months
...) AS DatesRaw
LEFT JOIN ( ) As Holidays

But you cannot do recursive derived tables. But you can easily replace
them if you use a table number of numbers to span years, months and
days. See http://www.sommarskog.se/arrays-in-sql-2005.html#tblnum



--
Erland Sommarskog, SQL Server MVP, esquel.RemoveThis@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 >> Stay informed about: 2005 to 2000 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
SQL Server 2005 Reporting 2000 to 2005 - Hello I have some databases on sql 2000 Developer Ed SP4 version 8.00.2039 and it work with reporting services Developer Ed version 8.0.1038.00. I need upgrade it to sql2005 and reporting services 2005 too SP2. But I want to do upgrade without..

From 2000 to 2005 - Hello We will migrate from SQL Server 2000 to 2005 , side by side installation so will keep both instances running at first , Is there an easy way of transferring all logins from 2000 to 2005 AND associate them with database users in the database tha...

2000 to 2005 - I have a database, written for 2000. I have ~all my scripts used to create the database, tables, views, usp's, udf's , etc. (usp = User Stored Procedure and udf = User Defined Function) As in, I can create a new db from scratch completely from tsql code....

New Table - 2000 vs 2005 - In sql server 2000, I could connect to a database with Windows Authentication, create a table (through the user interface, not with DDL ), and it would automatically be assigned to DBO Now, in SQL 2005, I right click on Tables, Create New table, and i...

upgrate from 2000 to 2005 - I have some databases on sql 2000 Developer Ed SP4 version 8.00.2039 and it work with reporting services Developer Ed version 8.0.1038.00. I need upgrade it to sql2005 and reporting services 2005 too SP2. But I want to do upgrade without backup/restor...
   Database Help (Home) -> Programming All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]