Showing posts with label back. Show all posts
Showing posts with label back. Show all posts

Thursday, March 29, 2012

Converting datetime to integer and back

Hi all,

I have a problem converting datetime to integer (and than back to
datetime).
Depending whether the time is AM or PM, same date is converted to two
different integer representations, which holds as true on reversal
back to datetime.

AM Example:

declare @.DI integer; declare @.DD datetime
set @.DI = cast(cast('3/12/2003 11:34:02 AM' as datetime) as integer)
set @.DD = cast (@.DI as datetime)
print @.DI; print @.DD

Result:
37690
Mar 12 2003 12:00AM

PM Example:

declare @.DI integer; declare @.DD datetime
set @.DI = cast(cast('3/12/2003 11:34:02 PM' as datetime) as integer)
set @.DD = cast (@.DI as datetime)
print @.DI; print @.DD

Result:
37691
Mar 13 2003 12:00AM

Now, this is not a big problem if I knew that this is how it is
supposed to work. Is this how SQL Server is supposed to work?Nikola (nigel35@.hotmail.com) writes:
> AM Example:
> declare @.DI integer; declare @.DD datetime
> set @.DI = cast(cast('3/12/2003 11:34:02 AM' as datetime) as integer)
> set @.DD = cast (@.DI as datetime)
> print @.DI; print @.DD
> Result:
> 37690
> Mar 12 2003 12:00AM
> PM Example:
> declare @.DI integer; declare @.DD datetime
> set @.DI = cast(cast('3/12/2003 11:34:02 PM' as datetime) as integer)
> set @.DD = cast (@.DI as datetime)
> print @.DI; print @.DD
> Result:
> 37691
> Mar 13 2003 12:00AM
> Now, this is not a big problem if I knew that this is how it is
> supposed to work. Is this how SQL Server is supposed to work?

Apparently, SQL Server rounds to the nearest wholest int. I wouldn't
say this makes much sense to me.

Then again, I have to admit that I don't really see the point with
converting datetime values to integer.

In any case, the workaround should be simple, first chop of the
time portion.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||"Erland Sommarskog" <sommar@.algonet.se> wrote:
> Nikola (nigel35@.hotmail.com) writes:
> > AM Example:
> > declare @.DI integer; declare @.DD datetime
> > set @.DI = cast(cast('3/12/2003 11:34:02 AM' as datetime) as integer)
> > set @.DD = cast (@.DI as datetime)
> > print @.DI; print @.DD
> > Result:
> > 37690
> > Mar 12 2003 12:00AM
> > PM Example:
> > declare @.DI integer; declare @.DD datetime
> > set @.DI = cast(cast('3/12/2003 11:34:02 PM' as datetime) as integer)
> > set @.DD = cast (@.DI as datetime)
> > print @.DI; print @.DD
> > Result:
> > 37691
> > Mar 13 2003 12:00AM
> > Now, this is not a big problem if I knew that this is how it is
> > supposed to work. Is this how SQL Server is supposed to work?
> Apparently, SQL Server rounds to the nearest wholest int. I wouldn't
> say this makes much sense to me.
> Then again, I have to admit that I don't really see the point with
> converting datetime values to integer.
> In any case, the workaround should be simple, first chop of the
> time portion.

VB6 will allow a similar translation and it has the same problem: a real
number is returned where the fractional (i.e. right of the decimal point)
part represents the time. So, converting from datetime to an int carries a
hidden conversion that rounds to get the integer. Check this out (I used
money, although I assume float or real would suffice).

declare @.d datetime
declare @.n money

set @.d = '3/12/2003'
set @.n = convert(money, @.d)
print convert(varchar, @.n) + ' - ' + convert(varchar, @.d)

set @.d = '3/12/2003 11:34 AM'
set @.n = convert(money, @.d)
print convert(varchar, @.n) + ' - ' + convert(varchar, @.d)

set @.d = '3/12/2003 11:34 PM'
set @.n = convert(money, @.d)
print convert(varchar, @.n) + ' - ' + convert(varchar, @.d)

set @.d = '3/13/2003'
set @.n = convert(money, @.d)
print convert(varchar, @.n) + ' - ' + convert(varchar, @.d)

Craig|||Erland Sommarskog (sommar@.algonet.se) writes:
> Apparently, SQL Server rounds to the nearest wholest int. I wouldn't
> say this makes much sense to me.
> Then again, I have to admit that I don't really see the point with
> converting datetime values to integer.
> In any case, the workaround should be simple, first chop of the
> time portion.

Actually there is an even simpler workaround:

declare @.d datetime
declare @.i int

SELECT @.d = '20020202 11:59:00'
SELECT @.i = convert(float, @.d)
SELECT @.i

SELECT @.d = '20020202 12:01:00'
SELECT @.i = convert(float, @.d)
SELECT @.i

This works, because when convering from float to int, truncation occurs...

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.aspsqlsql

Tuesday, March 27, 2012

Converting Data from Access 2000 to SQL Server 2000

Hi,
I worked on a project in ASP.NET using SQL server 2000 as the back end. Its a conversion application that I rewrote in ASP.NET using C#. I need to import the old data in Access db into SQL server 2000 and I have very little knowledge about doing it. The data in not a direct one -one transformation. There are considerable changes to the Database design and data types. Any help and suggestions wud be really helpful. Also, any article links wud be great.

Thanks.
HOW TO: Convert an Access Database to SQL Server

Sunday, March 11, 2012

Convert System tables to User table in SQL 2000

Hi
I have some tables created as system tables by mistake. How do I
convert them back to user tables.
Thanks
HP
I'm not too sure how you could have done this 'by mistake', but please take
a look at this http://www.transactsql.com/html/sp_M...temobject.html
to switch objects back.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .
|||Paul Ibison wrote:
> I'm not too sure how you could have done this 'by mistake', but please take
> a look at this http://www.transactsql.com/html/sp_M...temobject.html
> to switch objects back.
> Cheers,
> Paul Ibison SQL Server MVP, www.replicationanswers.com .
It is test server and somebody has messed up something that was causing
all object created as system object. I ran the script this morning to
switch but tables are created in last 2 days with this config are still
showing as system tables.
Thanks
Hp
|||HP wrote:
> Paul Ibison wrote:
>
> It is test server and somebody has messed up something that was causing
> all object created as system object. I ran the script this morning to
> switch but tables are created in last 2 days with this config are still
> showing as system tables.
> Thanks
> Hp
Hi Paul,
I looked the link you suggested. I want to do opposite to that script
Thanks
Hp
|||Have a look at the text in the procedure: sp_helptext
'sp_MS_marksystemobject'.
You'll need to do the reverse to unflag the tables. You might want to have a
PSS engineer work through this with you as it's a pretty unsupported method.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .

Convert System tables to User table in SQL 2000

Hi
I have some tables created as system tables by mistake. How do I
convert them back to user tables.
Thanks
HPI'm not too sure how you could have done this 'by mistake', but please take
a look at this http://www.transactsql.com/html/sp_...stemobject.html
to switch objects back.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .|||Paul Ibison wrote:
> I'm not too sure how you could have done this 'by mistake', but please tak
e
> a look at this http://www.transactsql.com/html/sp_...stemobject.html
> to switch objects back.
> Cheers,
> Paul Ibison SQL Server MVP, www.replicationanswers.com .
It is test server and somebody has messed up something that was causing
all object created as system object. I ran the script this morning to
switch but tables are created in last 2 days with this config are still
showing as system tables.
Thanks
Hp|||HP wrote:
> Paul Ibison wrote:
>
> It is test server and somebody has messed up something that was causing
> all object created as system object. I ran the script this morning to
> switch but tables are created in last 2 days with this config are still
> showing as system tables.
> Thanks
> Hp
Hi Paul,
I looked the link you suggested. I want to do opposite to that script
Thanks
Hp|||Have a look at the text in the procedure: sp_helptext
'sp_MS_marksystemobject'.
You'll need to do the reverse to unflag the tables. You might want to have a
PSS engineer work through this with you as it's a pretty unsupported method.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .

Convert System tables to User table in SQL 2000

Hi
I have some tables created as system tables by mistake. How do I
convert them back to user tables.
Thanks
HPI'm not too sure how you could have done this 'by mistake', but please take
a look at this http://www.transactsql.com/html/sp_MS_marksystemobject.html
to switch objects back.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .|||Paul Ibison wrote:
> I'm not too sure how you could have done this 'by mistake', but please take
> a look at this http://www.transactsql.com/html/sp_MS_marksystemobject.html
> to switch objects back.
> Cheers,
> Paul Ibison SQL Server MVP, www.replicationanswers.com .
It is test server and somebody has messed up something that was causing
all object created as system object. I ran the script this morning to
switch but tables are created in last 2 days with this config are still
showing as system tables.
Thanks
Hp|||HP wrote:
> Paul Ibison wrote:
> > I'm not too sure how you could have done this 'by mistake', but please take
> > a look at this http://www.transactsql.com/html/sp_MS_marksystemobject.html
> > to switch objects back.
> > Cheers,
> > Paul Ibison SQL Server MVP, www.replicationanswers.com .
>
> It is test server and somebody has messed up something that was causing
> all object created as system object. I ran the script this morning to
> switch but tables are created in last 2 days with this config are still
> showing as system tables.
> Thanks
> Hp
Hi Paul,
I looked the link you suggested. I want to do opposite to that script
Thanks
Hp|||Have a look at the text in the procedure: sp_helptext
'sp_MS_marksystemobject'.
You'll need to do the reverse to unflag the tables. You might want to have a
PSS engineer work through this with you as it's a pretty unsupported method.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .

Thursday, March 8, 2012

Convert sql2005 database to sql200

Can somebody tell me, it is possible to convert a database developed in sql2005 back to sql2000?

I am desperatly trying to do so, but...

please help...

Create a blank database in 2000 use 2000 DTS to get your tables and objects from 2005. Hope this helps.

|||

Here is a solution, please follow these steps.

1. Create a blank database in SQL Server 2000.


2. In SQL 2005 Management Console Studio , from Database -> tasks -> Generate Script -> select Database ->Script for Server Version -> Change it from SQL Server 2005 to SQL Server 2000


3. Do the process as per wizard.


4. We can run that Script into SQL Query Analyzer 2000 for that selected database where you want to move it.

You should be able to get whole database table creation and whole relationship which was made into SQL Server 2005.

If you have data, use bcp utilities to export and import.

Please check this thread for detail.

Wednesday, March 7, 2012

Convert SQL 2005 to SQL 2000

I started a project using SQL 2005 and now the customer has decided they can't go to 2005 yet so I need to convert it back to 2000. I didn't use any new features of 2005. How do I move it back to SQL 2000?Hi Steve,

Well, backup of 2005 doesn't restore on SQL 2000. However, you can generate SQL Script from objtecs and run into SQL Server 2000 Database.

Follow this steps:

1. Create new database in SQL 2000
2. Genarete script from objtects on the SQL 2005
3. Execute this script on the SQL 2000

If you have data, use bcp utilities to export and import.

Nilton Pinheiro|||

I am have problems with the syntax on the sql05 scripts. They are not running in 2000.

Has anyone else had problems?

|||socalmp, can you give some examples? Hard to say without them.|||

I have a db I imported into sql05 and now I need to transfer that db to a hosting company using sql2000.

I go right click on db >Tasks > generate scripts > and a wizard pops up to walk thru the settings for the script. I turn everything to false except script foreign keys, primary keys and unique keys because I have some relationships in the tables. The script version is sql2000 and the behavior is to generate create statements only. this is what I get:

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [patients](

[patientID] [int] IDENTITY(1,1) NOT NULL,

[last] [text] NULL,

[first] [text] NULL,

[dob] [datetime] NULL,

[gender] [text] NULL,

[sexuality] [text] NULL,

[ethnicity] [text] NULL,

[job] [varchar](50) NULL,

[company] [varchar](50) NULL,

[homephone] [varchar](50) NULL,

[homephone2] [varchar](50) NULL,

[mobile] [varchar](50) NULL,

[businessphone] [varchar](50) NULL,

[streetadd] [varchar](50) NULL,

[state] [text] NULL,

[zip] [nvarchar](50) NULL,

[country] [varchar](50) NULL,

[email] [varchar](50) NULL,

[email2] [varchar](50) NULL,

[webpage] [varchar](50) NULL,

[im] [varchar](50) NULL,

[reffered] [varchar](50) NULL,

[type] [varchar](50) NULL,

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

[patientID] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [treatment](

[patientID] [int] NOT NULL,

[treatmentdate] [datetime] NULL,

[product] [varchar](50) NULL,

[amount] [numeric](18, 0) NULL

) ON [PRIMARY]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [notes](

[patientID] [int] NOT NULL,

[notes] [varchar](50) NOT NULL

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[treatment] WITH CHECK ADD CONSTRAINT [FK_treatment_patients] FOREIGN KEY([patientID])

REFERENCES [patients] ([patientID])

GO

ALTER TABLE [dbo].[notes] WITH CHECK ADD CONSTRAINT [FK_notes_patients] FOREIGN KEY([patientID])

REFERENCES [patients] ([patientI

When You run this in query analyzer I get this error:

Line 29: Incorrect syntax near '('.

And that is from this line:

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

I have tried many times with no success to get the script wizard to make a script compatible with SQL2000. My t-sql skills need improvement obviously, but I don't know why this has to be so difficult. Enterprise manager seemed easier to work with then the new sql05. I am sure I just need to get up to speed with its features

Any suggestions? I am trying to migrate a db from sql05 to sql 2000 using Query Analyser or csv import wizard only. I was able to previoulsy generate scripts from enterpirse manager to create the db with Query Analyser.

|||

Here's a script from Sql2000 made with enterprise manager and it ran just fine in the query anaylzer:

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_notes_patients]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)

ALTER TABLE [dbo].[notes] DROP CONSTRAINT FK_notes_patients

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_treatment_patients]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)

ALTER TABLE [dbo].[treatment] DROP CONSTRAINT FK_treatment_patients

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[notes]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[notes]

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[patients]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[patients]

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[treatment]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[treatment]

GO

CREATE TABLE [dbo].[notes] (

[patientID] [int] NOT NULL ,

[notes] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL

) ON [PRIMARY]

GO

CREATE TABLE [dbo].[patients] (

[patientID] [int] IDENTITY (1, 1) NOT NULL ,

[last] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[first] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[dob] [datetime] NULL ,

[gender] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[sexuality] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[ethnicity] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[job] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[company] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[homephone] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[homephone2] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[mobile] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[businessphone] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[streetadd] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[state] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[zip] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[country] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[email2] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[webpage] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[im] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[reffered] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[type] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

CREATE TABLE [dbo].[treatment] (

[patientID] [int] NOT NULL ,

[treatmentdate] [datetime] NULL ,

[product] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[amount] [numeric](18, 0) NULL

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[patients] WITH NOCHECK ADD

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

[patientID]

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[notes] ADD

CONSTRAINT [FK_notes_patients] FOREIGN KEY

(

[patientID]

) REFERENCES [dbo].[patients] (

[patientID]

)

GO

ALTER TABLE [dbo].[treatment] ADD

CONSTRAINT [FK_treatment_patients] FOREIGN KEY

(

[patientID]

) REFERENCES [dbo].[patients] (

[patientID]

)

GO

So I am not sure What the difference is betwen the scripts?

|||

Maybe your default collation is not set to SQL_Latin1_General_CP1_CI_AS

I noticed in the 2000 script it is being specified all the way down. That might need to be specified in your 2000 instance. Try adding the collation statement to your columns in the 2005 script and see.

|||There is an easy way to solve the problem.

Open the Microsoft SQL Management Studio, then in "Object Explorer" right click on your Database->Tasks->Generate Scripts

In the Wizard

Script Window Click Next, Select You DB, Click Next and in the Choose

Script Option Step, Change the value of "Script for Server Version"

from "SQL Server 2005" to "SQL Server 2000" and go on.

When you click "Finish" button, your script will SQL 2000 compatible.

Good luck.

|||I tried this and the first script is a product of SQL 2005 and their acript generator. I made sure it was SQL 2000 compatible and it will not run in a SQL 2000 query analyzer. Strange!|||

On the script side, I looked more closely and I think the (IGNORE_DUP_KEY = OFF) syntax is incorrect. I believe you either have IGNORE_DUP_KEY specified or it is absent (which is the equivalent of OFF).

Another way you could accomplish your goal is to set your database to a 2000 version format, make a backup, and send it to your hosting provider to restore on their server. That solution should at least solve any script problems.

Run the following command against your database in SQL Management Studio and then create your backup.

sp_dbcmptlevel 'MyDatabaseName', 80

Hope that helps.
Hugh

|||

While generating the Script

We have to select option

Script for Server version as SQL Server 2000

|||

Created the databse with compatibility level set to sql200.

restored my client database from sql2005

i run the command "sp_dbcmptlevel 'MyDatabaseName', 80"

backup the database

everyrhing was ok.

I go to the enterprise manager of my sql2000 and restore the backed up database and this is the error i got.

"Too many backup devices specified for backup or restore; only 64 are allowed. Restore Database is terminating abnormally."

|||Has anybody found useful input on the 64 backup device limit? Same problem here moving a SQL 2005 db to SQL 2005 or 2000.|||

Hi Byrnie,

In my case I have SQL2005 running on my laptop. I needed to move the database onto my server which is currently running SQL 2000. On the laptop and in SQL Server Management Studio I selected the import/export Wizard. Using the wizard I was able to export my SQL2005 tables across to the SQL2000 server. I have not yet completed the process and have just started the job. I will have to verify the data as soon as the job has completed. This is the first time I am contributing anything to a forum. I hope it helps

|||Hi frnds,

I have done the process of Converting SQL 2005 Database into SQL 2000 Database.

1.Create Database in SQL Server 2000 which is the name into SQL 2005.
2.From SQL 2005 Mgmt Console Studio , from Database - tasks - Generate Script
-then select Database -Script for Server Version - Change it from SQL Server 2005 to SQL Server 2000
3. Do the process as per wizard.
4.We can run that Script into SQL Query Analyzer 2000 for that selected database where you want to move it.

Its working fine.I got whole database table creation and whole relationship which was made into SQL Server 2005.

Gr8t.. thanks for your help.

Convert SQL 2005 to SQL 2000

I started a project using SQL 2005 and now the customer has decided they can't go to 2005 yet so I need to convert it back to 2000. I didn't use any new features of 2005. How do I move it back to SQL 2000?Hi Steve,

Well, backup of 2005 doesn't restore on SQL 2000. However, you can generate SQL Script from objtecs and run into SQL Server 2000 Database.

Follow this steps:

1. Create new database in SQL 2000
2. Genarete script from objtects on the SQL 2005
3. Execute this script on the SQL 2000

If you have data, use bcp utilities to export and import.

Nilton Pinheiro|||

I am have problems with the syntax on the sql05 scripts. They are not running in 2000.

Has anyone else had problems?

|||socalmp, can you give some examples? Hard to say without them.|||

I have a db I imported into sql05 and now I need to transfer that db to a hosting company using sql2000.

I go right click on db >Tasks > generate scripts > and a wizard pops up to walk thru the settings for the script. I turn everything to false except script foreign keys, primary keys and unique keys because I have some relationships in the tables. The script version is sql2000 and the behavior is to generate create statements only. this is what I get:

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [patients](

[patientID] [int] IDENTITY(1,1) NOT NULL,

[last] [text] NULL,

[first] [text] NULL,

[dob] [datetime] NULL,

[gender] [text] NULL,

[sexuality] [text] NULL,

[ethnicity] [text] NULL,

[job] [varchar](50) NULL,

[company] [varchar](50) NULL,

[homephone] [varchar](50) NULL,

[homephone2] [varchar](50) NULL,

[mobile] [varchar](50) NULL,

[businessphone] [varchar](50) NULL,

[streetadd] [varchar](50) NULL,

[state] [text] NULL,

[zip] [nvarchar](50) NULL,

[country] [varchar](50) NULL,

[email] [varchar](50) NULL,

[email2] [varchar](50) NULL,

[webpage] [varchar](50) NULL,

[im] [varchar](50) NULL,

[reffered] [varchar](50) NULL,

[type] [varchar](50) NULL,

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

[patientID] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [treatment](

[patientID] [int] NOT NULL,

[treatmentdate] [datetime] NULL,

[product] [varchar](50) NULL,

[amount] [numeric](18, 0) NULL

) ON [PRIMARY]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [notes](

[patientID] [int] NOT NULL,

[notes] [varchar](50) NOT NULL

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[treatment] WITH CHECK ADD CONSTRAINT [FK_treatment_patients] FOREIGN KEY([patientID])

REFERENCES [patients] ([patientID])

GO

ALTER TABLE [dbo].[notes] WITH CHECK ADD CONSTRAINT [FK_notes_patients] FOREIGN KEY([patientID])

REFERENCES [patients] ([patientI

When You run this in query analyzer I get this error:

Line 29: Incorrect syntax near '('.

And that is from this line:

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

I have tried many times with no success to get the script wizard to make a script compatible with SQL2000. My t-sql skills need improvement obviously, but I don't know why this has to be so difficult. Enterprise manager seemed easier to work with then the new sql05. I am sure I just need to get up to speed with its features

Any suggestions? I am trying to migrate a db from sql05 to sql 2000 using Query Analyser or csv import wizard only. I was able to previoulsy generate scripts from enterpirse manager to create the db with Query Analyser.

|||

Here's a script from Sql2000 made with enterprise manager and it ran just fine in the query anaylzer:

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_notes_patients]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)

ALTER TABLE [dbo].[notes] DROP CONSTRAINT FK_notes_patients

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_treatment_patients]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)

ALTER TABLE [dbo].[treatment] DROP CONSTRAINT FK_treatment_patients

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[notes]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[notes]

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[patients]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[patients]

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[treatment]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[treatment]

GO

CREATE TABLE [dbo].[notes] (

[patientID] [int] NOT NULL ,

[notes] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL

) ON [PRIMARY]

GO

CREATE TABLE [dbo].[patients] (

[patientID] [int] IDENTITY (1, 1) NOT NULL ,

[last] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[first] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[dob] [datetime] NULL ,

[gender] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[sexuality] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[ethnicity] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[job] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[company] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[homephone] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[homephone2] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[mobile] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[businessphone] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[streetadd] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[state] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[zip] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[country] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[email2] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[webpage] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[im] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[reffered] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[type] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

CREATE TABLE [dbo].[treatment] (

[patientID] [int] NOT NULL ,

[treatmentdate] [datetime] NULL ,

[product] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[amount] [numeric](18, 0) NULL

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[patients] WITH NOCHECK ADD

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

[patientID]

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[notes] ADD

CONSTRAINT [FK_notes_patients] FOREIGN KEY

(

[patientID]

) REFERENCES [dbo].[patients] (

[patientID]

)

GO

ALTER TABLE [dbo].[treatment] ADD

CONSTRAINT [FK_treatment_patients] FOREIGN KEY

(

[patientID]

) REFERENCES [dbo].[patients] (

[patientID]

)

GO

So I am not sure What the difference is betwen the scripts?

|||

Maybe your default collation is not set to SQL_Latin1_General_CP1_CI_AS

I noticed in the 2000 script it is being specified all the way down. That might need to be specified in your 2000 instance. Try adding the collation statement to your columns in the 2005 script and see.

|||There is an easy way to solve the problem.
Open the Microsoft SQL Management Studio, then in "Object Explorer" right click on your Database->Tasks->Generate Scripts
In the Wizard Script Window Click Next, Select You DB, Click Next and in the Choose Script Option Step, Change the value of "Script for Server Version" from "SQL Server 2005" to "SQL Server 2000" and go on.
When you click "Finish" button, your script will SQL 2000 compatible.
Good luck.
|||I tried this and the first script is a product of SQL 2005 and their acript generator. I made sure it was SQL 2000 compatible and it will not run in a SQL 2000 query analyzer. Strange!|||

On the script side, I looked more closely and I think the (IGNORE_DUP_KEY = OFF) syntax is incorrect. I believe you either have IGNORE_DUP_KEY specified or it is absent (which is the equivalent of OFF).

Another way you could accomplish your goal is to set your database to a 2000 version format, make a backup, and send it to your hosting provider to restore on their server. That solution should at least solve any script problems.

Run the following command against your database in SQL Management Studio and then create your backup.

sp_dbcmptlevel 'MyDatabaseName', 80

Hope that helps.
Hugh

|||

While generating the Script

We have to select option

Script for Server version as SQL Server 2000

|||

Created the databse with compatibility level set to sql200.

restored my client database from sql2005

i run the command "sp_dbcmptlevel 'MyDatabaseName', 80"

backup the database

everyrhing was ok.

I go to the enterprise manager of my sql2000 and restore the backed up database and this is the error i got.

"Too many backup devices specified for backup or restore; only 64 are allowed. Restore Database is terminating abnormally."

|||Has anybody found useful input on the 64 backup device limit? Same problem here moving a SQL 2005 db to SQL 2005 or 2000.|||

Hi Byrnie,

In my case I have SQL2005 running on my laptop. I needed to move the database onto my server which is currently running SQL 2000. On the laptop and in SQL Server Management Studio I selected the import/export Wizard. Using the wizard I was able to export my SQL2005 tables across to the SQL2000 server. I have not yet completed the process and have just started the job. I will have to verify the data as soon as the job has completed. This is the first time I am contributing anything to a forum. I hope it helps

|||Hi frnds,

I have done the process of Converting SQL 2005 Database into SQL 2000 Database.

1.Create Database in SQL Server 2000 which is the name into SQL 2005.
2.From SQL 2005 Mgmt Console Studio , from Database - tasks - Generate Script
-then select Database -Script for Server Version - Change it from SQL Server 2005 to SQL Server 2000
3. Do the process as per wizard.
4.We can run that Script into SQL Query Analyzer 2000 for that selected database where you want to move it.

Its working fine.I got whole database table creation and whole relationship which was made into SQL Server 2005.

Gr8t.. thanks for your help.

Convert SQL 2005 to SQL 2000

I started a project using SQL 2005 and now the customer has decided they can't go to 2005 yet so I need to convert it back to 2000. I didn't use any new features of 2005. How do I move it back to SQL 2000?Hi Steve,

Well, backup of 2005 doesn't restore on SQL 2000. However, you can generate SQL Script from objtecs and run into SQL Server 2000 Database.

Follow this steps:

1. Create new database in SQL 2000
2. Genarete script from objtects on the SQL 2005
3. Execute this script on the SQL 2000

If you have data, use bcp utilities to export and import.

Nilton Pinheiro|||

I am have problems with the syntax on the sql05 scripts. They are not running in 2000.

Has anyone else had problems?

|||socalmp, can you give some examples? Hard to say without them.|||

I have a db I imported into sql05 and now I need to transfer that db to a hosting company using sql2000.

I go right click on db >Tasks > generate scripts > and a wizard pops up to walk thru the settings for the script. I turn everything to false except script foreign keys, primary keys and unique keys because I have some relationships in the tables. The script version is sql2000 and the behavior is to generate create statements only. this is what I get:

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [patients](

[patientID] [int] IDENTITY(1,1) NOT NULL,

[last] [text] NULL,

[first] [text] NULL,

[dob] [datetime] NULL,

[gender] [text] NULL,

[sexuality] [text] NULL,

[ethnicity] [text] NULL,

[job] [varchar](50) NULL,

[company] [varchar](50) NULL,

[homephone] [varchar](50) NULL,

[homephone2] [varchar](50) NULL,

[mobile] [varchar](50) NULL,

[businessphone] [varchar](50) NULL,

[streetadd] [varchar](50) NULL,

[state] [text] NULL,

[zip] [nvarchar](50) NULL,

[country] [varchar](50) NULL,

[email] [varchar](50) NULL,

[email2] [varchar](50) NULL,

[webpage] [varchar](50) NULL,

[im] [varchar](50) NULL,

[reffered] [varchar](50) NULL,

[type] [varchar](50) NULL,

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

[patientID] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [treatment](

[patientID] [int] NOT NULL,

[treatmentdate] [datetime] NULL,

[product] [varchar](50) NULL,

[amount] [numeric](18, 0) NULL

) ON [PRIMARY]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [notes](

[patientID] [int] NOT NULL,

[notes] [varchar](50) NOT NULL

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[treatment] WITH CHECK ADD CONSTRAINT [FK_treatment_patients] FOREIGN KEY([patientID])

REFERENCES [patients] ([patientID])

GO

ALTER TABLE [dbo].[notes] WITH CHECK ADD CONSTRAINT [FK_notes_patients] FOREIGN KEY([patientID])

REFERENCES [patients] ([patientI

When You run this in query analyzer I get this error:

Line 29: Incorrect syntax near '('.

And that is from this line:

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

I have tried many times with no success to get the script wizard to make a script compatible with SQL2000. My t-sql skills need improvement obviously, but I don't know why this has to be so difficult. Enterprise manager seemed easier to work with then the new sql05. I am sure I just need to get up to speed with its features

Any suggestions? I am trying to migrate a db from sql05 to sql 2000 using Query Analyser or csv import wizard only. I was able to previoulsy generate scripts from enterpirse manager to create the db with Query Analyser.

|||

Here's a script from Sql2000 made with enterprise manager and it ran just fine in the query anaylzer:

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_notes_patients]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)

ALTER TABLE [dbo].[notes] DROP CONSTRAINT FK_notes_patients

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_treatment_patients]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)

ALTER TABLE [dbo].[treatment] DROP CONSTRAINT FK_treatment_patients

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[notes]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[notes]

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[patients]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[patients]

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[treatment]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[treatment]

GO

CREATE TABLE [dbo].[notes] (

[patientID] [int] NOT NULL ,

[notes] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL

) ON [PRIMARY]

GO

CREATE TABLE [dbo].[patients] (

[patientID] [int] IDENTITY (1, 1) NOT NULL ,

[last] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[first] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[dob] [datetime] NULL ,

[gender] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[sexuality] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[ethnicity] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[job] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[company] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[homephone] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[homephone2] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[mobile] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[businessphone] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[streetadd] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[state] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[zip] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[country] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[email2] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[webpage] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[im] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[reffered] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[type] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

CREATE TABLE [dbo].[treatment] (

[patientID] [int] NOT NULL ,

[treatmentdate] [datetime] NULL ,

[product] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[amount] [numeric](18, 0) NULL

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[patients] WITH NOCHECK ADD

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

[patientID]

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[notes] ADD

CONSTRAINT [FK_notes_patients] FOREIGN KEY

(

[patientID]

) REFERENCES [dbo].[patients] (

[patientID]

)

GO

ALTER TABLE [dbo].[treatment] ADD

CONSTRAINT [FK_treatment_patients] FOREIGN KEY

(

[patientID]

) REFERENCES [dbo].[patients] (

[patientID]

)

GO

So I am not sure What the difference is betwen the scripts?

|||

Maybe your default collation is not set to SQL_Latin1_General_CP1_CI_AS

I noticed in the 2000 script it is being specified all the way down. That might need to be specified in your 2000 instance. Try adding the collation statement to your columns in the 2005 script and see.

|||There is an easy way to solve the problem.
Open the Microsoft SQL Management Studio, then in "Object Explorer" right click on your Database->Tasks->Generate Scripts
In the Wizard Script Window Click Next, Select You DB, Click Next and in the Choose Script Option Step, Change the value of "Script for Server Version" from "SQL Server 2005" to "SQL Server 2000" and go on.
When you click "Finish" button, your script will SQL 2000 compatible.
Good luck.
|||I tried this and the first script is a product of SQL 2005 and their acript generator. I made sure it was SQL 2000 compatible and it will not run in a SQL 2000 query analyzer. Strange!|||

On the script side, I looked more closely and I think the (IGNORE_DUP_KEY = OFF) syntax is incorrect. I believe you either have IGNORE_DUP_KEY specified or it is absent (which is the equivalent of OFF).

Another way you could accomplish your goal is to set your database to a 2000 version format, make a backup, and send it to your hosting provider to restore on their server. That solution should at least solve any script problems.

Run the following command against your database in SQL Management Studio and then create your backup.

sp_dbcmptlevel 'MyDatabaseName', 80

Hope that helps.
Hugh

|||

While generating the Script

We have to select option

Script for Server version as SQL Server 2000

|||

Created the databse with compatibility level set to sql200.

restored my client database from sql2005

i run the command "sp_dbcmptlevel 'MyDatabaseName', 80"

backup the database

everyrhing was ok.

I go to the enterprise manager of my sql2000 and restore the backed up database and this is the error i got.

"Too many backup devices specified for backup or restore; only 64 are allowed. Restore Database is terminating abnormally."

|||Has anybody found useful input on the 64 backup device limit? Same problem here moving a SQL 2005 db to SQL 2005 or 2000.|||

Hi Byrnie,

In my case I have SQL2005 running on my laptop. I needed to move the database onto my server which is currently running SQL 2000. On the laptop and in SQL Server Management Studio I selected the import/export Wizard. Using the wizard I was able to export my SQL2005 tables across to the SQL2000 server. I have not yet completed the process and have just started the job. I will have to verify the data as soon as the job has completed. This is the first time I am contributing anything to a forum. I hope it helps

|||Hi frnds,

I have done the process of Converting SQL 2005 Database into SQL 2000 Database.

1.Create Database in SQL Server 2000 which is the name into SQL 2005.
2.From SQL 2005 Mgmt Console Studio , from Database - tasks - Generate Script
-then select Database -Script for Server Version - Change it from SQL Server 2005 to SQL Server 2000
3. Do the process as per wizard.
4.We can run that Script into SQL Query Analyzer 2000 for that selected database where you want to move it.

Its working fine.I got whole database table creation and whole relationship which was made into SQL Server 2005.

Gr8t.. thanks for your help.

Convert SQL 2005 to SQL 2000

I started a project using SQL 2005 and now the customer has decided they can't go to 2005 yet so I need to convert it back to 2000. I didn't use any new features of 2005. How do I move it back to SQL 2000?Hi Steve,

Well, backup of 2005 doesn't restore on SQL 2000. However, you can generate SQL Script from objtecs and run into SQL Server 2000 Database.

Follow this steps:

1. Create new database in SQL 2000
2. Genarete script from objtects on the SQL 2005
3. Execute this script on the SQL 2000

If you have data, use bcp utilities to export and import.

Nilton Pinheiro|||

I am have problems with the syntax on the sql05 scripts. They are not running in 2000.

Has anyone else had problems?

|||socalmp, can you give some examples? Hard to say without them.|||

I have a db I imported into sql05 and now I need to transfer that db to a hosting company using sql2000.

I go right click on db >Tasks > generate scripts > and a wizard pops up to walk thru the settings for the script. I turn everything to false except script foreign keys, primary keys and unique keys because I have some relationships in the tables. The script version is sql2000 and the behavior is to generate create statements only. this is what I get:

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [patients](

[patientID] [int] IDENTITY(1,1) NOT NULL,

[last] [text] NULL,

[first] [text] NULL,

[dob] [datetime] NULL,

[gender] [text] NULL,

[sexuality] [text] NULL,

[ethnicity] [text] NULL,

[job] [varchar](50) NULL,

[company] [varchar](50) NULL,

[homephone] [varchar](50) NULL,

[homephone2] [varchar](50) NULL,

[mobile] [varchar](50) NULL,

[businessphone] [varchar](50) NULL,

[streetadd] [varchar](50) NULL,

[state] [text] NULL,

[zip] [nvarchar](50) NULL,

[country] [varchar](50) NULL,

[email] [varchar](50) NULL,

[email2] [varchar](50) NULL,

[webpage] [varchar](50) NULL,

[im] [varchar](50) NULL,

[reffered] [varchar](50) NULL,

[type] [varchar](50) NULL,

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

[patientID] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [treatment](

[patientID] [int] NOT NULL,

[treatmentdate] [datetime] NULL,

[product] [varchar](50) NULL,

[amount] [numeric](18, 0) NULL

) ON [PRIMARY]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [notes](

[patientID] [int] NOT NULL,

[notes] [varchar](50) NOT NULL

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[treatment] WITH CHECK ADD CONSTRAINT [FK_treatment_patients] FOREIGN KEY([patientID])

REFERENCES [patients] ([patientID])

GO

ALTER TABLE [dbo].[notes] WITH CHECK ADD CONSTRAINT [FK_notes_patients] FOREIGN KEY([patientID])

REFERENCES [patients] ([patientI

When You run this in query analyzer I get this error:

Line 29: Incorrect syntax near '('.

And that is from this line:

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

I have tried many times with no success to get the script wizard to make a script compatible with SQL2000. My t-sql skills need improvement obviously, but I don't know why this has to be so difficult. Enterprise manager seemed easier to work with then the new sql05. I am sure I just need to get up to speed with its features

Any suggestions? I am trying to migrate a db from sql05 to sql 2000 using Query Analyser or csv import wizard only. I was able to previoulsy generate scripts from enterpirse manager to create the db with Query Analyser.

|||

Here's a script from Sql2000 made with enterprise manager and it ran just fine in the query anaylzer:

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_notes_patients]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)

ALTER TABLE [dbo].[notes] DROP CONSTRAINT FK_notes_patients

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_treatment_patients]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)

ALTER TABLE [dbo].[treatment] DROP CONSTRAINT FK_treatment_patients

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[notes]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[notes]

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[patients]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[patients]

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[treatment]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[treatment]

GO

CREATE TABLE [dbo].[notes] (

[patientID] [int] NOT NULL ,

[notes] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL

) ON [PRIMARY]

GO

CREATE TABLE [dbo].[patients] (

[patientID] [int] IDENTITY (1, 1) NOT NULL ,

[last] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[first] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[dob] [datetime] NULL ,

[gender] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[sexuality] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[ethnicity] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[job] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[company] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[homephone] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[homephone2] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[mobile] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[businessphone] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[streetadd] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[state] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[zip] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[country] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[email2] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[webpage] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[im] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[reffered] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[type] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

CREATE TABLE [dbo].[treatment] (

[patientID] [int] NOT NULL ,

[treatmentdate] [datetime] NULL ,

[product] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[amount] [numeric](18, 0) NULL

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[patients] WITH NOCHECK ADD

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

[patientID]

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[notes] ADD

CONSTRAINT [FK_notes_patients] FOREIGN KEY

(

[patientID]

) REFERENCES [dbo].[patients] (

[patientID]

)

GO

ALTER TABLE [dbo].[treatment] ADD

CONSTRAINT [FK_treatment_patients] FOREIGN KEY

(

[patientID]

) REFERENCES [dbo].[patients] (

[patientID]

)

GO

So I am not sure What the difference is betwen the scripts?

|||

Maybe your default collation is not set to SQL_Latin1_General_CP1_CI_AS

I noticed in the 2000 script it is being specified all the way down. That might need to be specified in your 2000 instance. Try adding the collation statement to your columns in the 2005 script and see.

|||There is an easy way to solve the problem.

Open the Microsoft SQL Management Studio, then in "Object Explorer" right click on your Database->Tasks->Generate Scripts

In the Wizard

Script Window Click Next, Select You DB, Click Next and in the Choose

Script Option Step, Change the value of "Script for Server Version"

from "SQL Server 2005" to "SQL Server 2000" and go on.

When you click "Finish" button, your script will SQL 2000 compatible.

Good luck.

|||I tried this and the first script is a product of SQL 2005 and their acript generator. I made sure it was SQL 2000 compatible and it will not run in a SQL 2000 query analyzer. Strange!|||

On the script side, I looked more closely and I think the (IGNORE_DUP_KEY = OFF) syntax is incorrect. I believe you either have IGNORE_DUP_KEY specified or it is absent (which is the equivalent of OFF).

Another way you could accomplish your goal is to set your database to a 2000 version format, make a backup, and send it to your hosting provider to restore on their server. That solution should at least solve any script problems.

Run the following command against your database in SQL Management Studio and then create your backup.

sp_dbcmptlevel 'MyDatabaseName', 80

Hope that helps.
Hugh

|||

While generating the Script

We have to select option

Script for Server version as SQL Server 2000

|||

Created the databse with compatibility level set to sql200.

restored my client database from sql2005

i run the command "sp_dbcmptlevel 'MyDatabaseName', 80"

backup the database

everyrhing was ok.

I go to the enterprise manager of my sql2000 and restore the backed up database and this is the error i got.

"Too many backup devices specified for backup or restore; only 64 are allowed. Restore Database is terminating abnormally."

|||Has anybody found useful input on the 64 backup device limit? Same problem here moving a SQL 2005 db to SQL 2005 or 2000.|||

Hi Byrnie,

In my case I have SQL2005 running on my laptop. I needed to move the database onto my server which is currently running SQL 2000. On the laptop and in SQL Server Management Studio I selected the import/export Wizard. Using the wizard I was able to export my SQL2005 tables across to the SQL2000 server. I have not yet completed the process and have just started the job. I will have to verify the data as soon as the job has completed. This is the first time I am contributing anything to a forum. I hope it helps

|||Hi frnds,

I have done the process of Converting SQL 2005 Database into SQL 2000 Database.

1.Create Database in SQL Server 2000 which is the name into SQL 2005.
2.From SQL 2005 Mgmt Console Studio , from Database - tasks - Generate Script
-then select Database -Script for Server Version - Change it from SQL Server 2005 to SQL Server 2000
3. Do the process as per wizard.
4.We can run that Script into SQL Query Analyzer 2000 for that selected database where you want to move it.

Its working fine.I got whole database table creation and whole relationship which was made into SQL Server 2005.

Gr8t.. thanks for your help.

Convert SQL 2005 to SQL 2000

I started a project using SQL 2005 and now the customer has decided they can't go to 2005 yet so I need to convert it back to 2000. I didn't use any new features of 2005. How do I move it back to SQL 2000?Hi Steve,

Well, backup of 2005 doesn't restore on SQL 2000. However, you can generate SQL Script from objtecs and run into SQL Server 2000 Database.

Follow this steps:

1. Create new database in SQL 2000
2. Genarete script from objtects on the SQL 2005
3. Execute this script on the SQL 2000

If you have data, use bcp utilities to export and import.

Nilton Pinheiro|||

I am have problems with the syntax on the sql05 scripts. They are not running in 2000.

Has anyone else had problems?

|||socalmp, can you give some examples? Hard to say without them.|||

I have a db I imported into sql05 and now I need to transfer that db to a hosting company using sql2000.

I go right click on db >Tasks > generate scripts > and a wizard pops up to walk thru the settings for the script. I turn everything to false except script foreign keys, primary keys and unique keys because I have some relationships in the tables. The script version is sql2000 and the behavior is to generate create statements only. this is what I get:

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [patients](

[patientID] [int] IDENTITY(1,1) NOT NULL,

[last] [text] NULL,

[first] [text] NULL,

[dob] [datetime] NULL,

[gender] [text] NULL,

[sexuality] [text] NULL,

[ethnicity] [text] NULL,

[job] [varchar](50) NULL,

[company] [varchar](50) NULL,

[homephone] [varchar](50) NULL,

[homephone2] [varchar](50) NULL,

[mobile] [varchar](50) NULL,

[businessphone] [varchar](50) NULL,

[streetadd] [varchar](50) NULL,

[state] [text] NULL,

[zip] [nvarchar](50) NULL,

[country] [varchar](50) NULL,

[email] [varchar](50) NULL,

[email2] [varchar](50) NULL,

[webpage] [varchar](50) NULL,

[im] [varchar](50) NULL,

[reffered] [varchar](50) NULL,

[type] [varchar](50) NULL,

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

[patientID] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [treatment](

[patientID] [int] NOT NULL,

[treatmentdate] [datetime] NULL,

[product] [varchar](50) NULL,

[amount] [numeric](18, 0) NULL

) ON [PRIMARY]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [notes](

[patientID] [int] NOT NULL,

[notes] [varchar](50) NOT NULL

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[treatment] WITH CHECK ADD CONSTRAINT [FK_treatment_patients] FOREIGN KEY([patientID])

REFERENCES [patients] ([patientID])

GO

ALTER TABLE [dbo].[notes] WITH CHECK ADD CONSTRAINT [FK_notes_patients] FOREIGN KEY([patientID])

REFERENCES [patients] ([patientI

When You run this in query analyzer I get this error:

Line 29: Incorrect syntax near '('.

And that is from this line:

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

I have tried many times with no success to get the script wizard to make a script compatible with SQL2000. My t-sql skills need improvement obviously, but I don't know why this has to be so difficult. Enterprise manager seemed easier to work with then the new sql05. I am sure I just need to get up to speed with its features

Any suggestions? I am trying to migrate a db from sql05 to sql 2000 using Query Analyser or csv import wizard only. I was able to previoulsy generate scripts from enterpirse manager to create the db with Query Analyser.

|||

Here's a script from Sql2000 made with enterprise manager and it ran just fine in the query anaylzer:

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_notes_patients]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)

ALTER TABLE [dbo].[notes] DROP CONSTRAINT FK_notes_patients

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_treatment_patients]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)

ALTER TABLE [dbo].[treatment] DROP CONSTRAINT FK_treatment_patients

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[notes]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[notes]

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[patients]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[patients]

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[treatment]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[treatment]

GO

CREATE TABLE [dbo].[notes] (

[patientID] [int] NOT NULL ,

[notes] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL

) ON [PRIMARY]

GO

CREATE TABLE [dbo].[patients] (

[patientID] [int] IDENTITY (1, 1) NOT NULL ,

[last] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[first] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[dob] [datetime] NULL ,

[gender] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[sexuality] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[ethnicity] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[job] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[company] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[homephone] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[homephone2] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[mobile] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[businessphone] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[streetadd] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[state] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[zip] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[country] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[email2] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[webpage] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[im] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[reffered] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[type] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

CREATE TABLE [dbo].[treatment] (

[patientID] [int] NOT NULL ,

[treatmentdate] [datetime] NULL ,

[product] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[amount] [numeric](18, 0) NULL

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[patients] WITH NOCHECK ADD

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

[patientID]

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[notes] ADD

CONSTRAINT [FK_notes_patients] FOREIGN KEY

(

[patientID]

) REFERENCES [dbo].[patients] (

[patientID]

)

GO

ALTER TABLE [dbo].[treatment] ADD

CONSTRAINT [FK_treatment_patients] FOREIGN KEY

(

[patientID]

) REFERENCES [dbo].[patients] (

[patientID]

)

GO

So I am not sure What the difference is betwen the scripts?

|||

Maybe your default collation is not set to SQL_Latin1_General_CP1_CI_AS

I noticed in the 2000 script it is being specified all the way down. That might need to be specified in your 2000 instance. Try adding the collation statement to your columns in the 2005 script and see.

|||There is an easy way to solve the problem.
Open the Microsoft SQL Management Studio, then in "Object Explorer" right click on your Database->Tasks->Generate Scripts
In the Wizard Script Window Click Next, Select You DB, Click Next and in the Choose Script Option Step, Change the value of "Script for Server Version" from "SQL Server 2005" to "SQL Server 2000" and go on.
When you click "Finish" button, your script will SQL 2000 compatible.
Good luck.
|||I tried this and the first script is a product of SQL 2005 and their acript generator. I made sure it was SQL 2000 compatible and it will not run in a SQL 2000 query analyzer. Strange!|||

On the script side, I looked more closely and I think the (IGNORE_DUP_KEY = OFF) syntax is incorrect. I believe you either have IGNORE_DUP_KEY specified or it is absent (which is the equivalent of OFF).

Another way you could accomplish your goal is to set your database to a 2000 version format, make a backup, and send it to your hosting provider to restore on their server. That solution should at least solve any script problems.

Run the following command against your database in SQL Management Studio and then create your backup.

sp_dbcmptlevel 'MyDatabaseName', 80

Hope that helps.
Hugh

|||

While generating the Script

We have to select option

Script for Server version as SQL Server 2000

|||

Created the databse with compatibility level set to sql200.

restored my client database from sql2005

i run the command "sp_dbcmptlevel 'MyDatabaseName', 80"

backup the database

everyrhing was ok.

I go to the enterprise manager of my sql2000 and restore the backed up database and this is the error i got.

"Too many backup devices specified for backup or restore; only 64 are allowed. Restore Database is terminating abnormally."

|||Has anybody found useful input on the 64 backup device limit? Same problem here moving a SQL 2005 db to SQL 2005 or 2000.|||

Hi Byrnie,

In my case I have SQL2005 running on my laptop. I needed to move the database onto my server which is currently running SQL 2000. On the laptop and in SQL Server Management Studio I selected the import/export Wizard. Using the wizard I was able to export my SQL2005 tables across to the SQL2000 server. I have not yet completed the process and have just started the job. I will have to verify the data as soon as the job has completed. This is the first time I am contributing anything to a forum. I hope it helps

|||Hi frnds,

I have done the process of Converting SQL 2005 Database into SQL 2000 Database.

1.Create Database in SQL Server 2000 which is the name into SQL 2005.
2.From SQL 2005 Mgmt Console Studio , from Database - tasks - Generate Script
-then select Database -Script for Server Version - Change it from SQL Server 2005 to SQL Server 2000
3. Do the process as per wizard.
4.We can run that Script into SQL Query Analyzer 2000 for that selected database where you want to move it.

Its working fine.I got whole database table creation and whole relationship which was made into SQL Server 2005.

Gr8t.. thanks for your help.

Convert SQL 2005 to SQL 2000

I started a project using SQL 2005 and now the customer has decided they can't go to 2005 yet so I need to convert it back to 2000. I didn't use any new features of 2005. How do I move it back to SQL 2000?Hi Steve,

Well, backup of 2005 doesn't restore on SQL 2000. However, you can generate SQL Script from objtecs and run into SQL Server 2000 Database.

Follow this steps:

1. Create new database in SQL 2000
2. Genarete script from objtects on the SQL 2005
3. Execute this script on the SQL 2000

If you have data, use bcp utilities to export and import.

Nilton Pinheiro|||

I am have problems with the syntax on the sql05 scripts. They are not running in 2000.

Has anyone else had problems?

|||socalmp, can you give some examples? Hard to say without them.|||

I have a db I imported into sql05 and now I need to transfer that db to a hosting company using sql2000.

I go right click on db >Tasks > generate scripts > and a wizard pops up to walk thru the settings for the script. I turn everything to false except script foreign keys, primary keys and unique keys because I have some relationships in the tables. The script version is sql2000 and the behavior is to generate create statements only. this is what I get:

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [patients](

[patientID] [int] IDENTITY(1,1) NOT NULL,

[last] [text] NULL,

[first] [text] NULL,

[dob] [datetime] NULL,

[gender] [text] NULL,

[sexuality] [text] NULL,

[ethnicity] [text] NULL,

[job] [varchar](50) NULL,

[company] [varchar](50) NULL,

[homephone] [varchar](50) NULL,

[homephone2] [varchar](50) NULL,

[mobile] [varchar](50) NULL,

[businessphone] [varchar](50) NULL,

[streetadd] [varchar](50) NULL,

[state] [text] NULL,

[zip] [nvarchar](50) NULL,

[country] [varchar](50) NULL,

[email] [varchar](50) NULL,

[email2] [varchar](50) NULL,

[webpage] [varchar](50) NULL,

[im] [varchar](50) NULL,

[reffered] [varchar](50) NULL,

[type] [varchar](50) NULL,

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

[patientID] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [treatment](

[patientID] [int] NOT NULL,

[treatmentdate] [datetime] NULL,

[product] [varchar](50) NULL,

[amount] [numeric](18, 0) NULL

) ON [PRIMARY]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [notes](

[patientID] [int] NOT NULL,

[notes] [varchar](50) NOT NULL

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[treatment] WITH CHECK ADD CONSTRAINT [FK_treatment_patients] FOREIGN KEY([patientID])

REFERENCES [patients] ([patientID])

GO

ALTER TABLE [dbo].[notes] WITH CHECK ADD CONSTRAINT [FK_notes_patients] FOREIGN KEY([patientID])

REFERENCES [patients] ([patientI

When You run this in query analyzer I get this error:

Line 29: Incorrect syntax near '('.

And that is from this line:

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

I have tried many times with no success to get the script wizard to make a script compatible with SQL2000. My t-sql skills need improvement obviously, but I don't know why this has to be so difficult. Enterprise manager seemed easier to work with then the new sql05. I am sure I just need to get up to speed with its features

Any suggestions? I am trying to migrate a db from sql05 to sql 2000 using Query Analyser or csv import wizard only. I was able to previoulsy generate scripts from enterpirse manager to create the db with Query Analyser.

|||

Here's a script from Sql2000 made with enterprise manager and it ran just fine in the query anaylzer:

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_notes_patients]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)

ALTER TABLE [dbo].[notes] DROP CONSTRAINT FK_notes_patients

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_treatment_patients]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)

ALTER TABLE [dbo].[treatment] DROP CONSTRAINT FK_treatment_patients

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[notes]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[notes]

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[patients]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[patients]

GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[treatment]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop table [dbo].[treatment]

GO

CREATE TABLE [dbo].[notes] (

[patientID] [int] NOT NULL ,

[notes] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL

) ON [PRIMARY]

GO

CREATE TABLE [dbo].[patients] (

[patientID] [int] IDENTITY (1, 1) NOT NULL ,

[last] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[first] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[dob] [datetime] NULL ,

[gender] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[sexuality] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[ethnicity] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[job] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[company] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[homephone] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[homephone2] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[mobile] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[businessphone] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[streetadd] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[state] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[zip] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[country] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[email2] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[webpage] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[im] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[reffered] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[type] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

CREATE TABLE [dbo].[treatment] (

[patientID] [int] NOT NULL ,

[treatmentdate] [datetime] NULL ,

[product] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

[amount] [numeric](18, 0) NULL

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[patients] WITH NOCHECK ADD

CONSTRAINT [PK_patients] PRIMARY KEY CLUSTERED

(

[patientID]

) ON [PRIMARY]

GO

ALTER TABLE [dbo].[notes] ADD

CONSTRAINT [FK_notes_patients] FOREIGN KEY

(

[patientID]

) REFERENCES [dbo].[patients] (

[patientID]

)

GO

ALTER TABLE [dbo].[treatment] ADD

CONSTRAINT [FK_treatment_patients] FOREIGN KEY

(

[patientID]

) REFERENCES [dbo].[patients] (

[patientID]

)

GO

So I am not sure What the difference is betwen the scripts?

|||

Maybe your default collation is not set to SQL_Latin1_General_CP1_CI_AS

I noticed in the 2000 script it is being specified all the way down. That might need to be specified in your 2000 instance. Try adding the collation statement to your columns in the 2005 script and see.

|||There is an easy way to solve the problem.

Open the Microsoft SQL Management Studio, then in "Object Explorer" right click on your Database->Tasks->Generate Scripts

In the Wizard

Script Window Click Next, Select You DB, Click Next and in the Choose

Script Option Step, Change the value of "Script for Server Version"

from "SQL Server 2005" to "SQL Server 2000" and go on.

When you click "Finish" button, your script will SQL 2000 compatible.

Good luck.

|||I tried this and the first script is a product of SQL 2005 and their acript generator. I made sure it was SQL 2000 compatible and it will not run in a SQL 2000 query analyzer. Strange!|||

On the script side, I looked more closely and I think the (IGNORE_DUP_KEY = OFF) syntax is incorrect. I believe you either have IGNORE_DUP_KEY specified or it is absent (which is the equivalent of OFF).

Another way you could accomplish your goal is to set your database to a 2000 version format, make a backup, and send it to your hosting provider to restore on their server. That solution should at least solve any script problems.

Run the following command against your database in SQL Management Studio and then create your backup.

sp_dbcmptlevel 'MyDatabaseName', 80

Hope that helps.
Hugh

|||

While generating the Script

We have to select option

Script for Server version as SQL Server 2000

|||

Created the databse with compatibility level set to sql200.

restored my client database from sql2005

i run the command "sp_dbcmptlevel 'MyDatabaseName', 80"

backup the database

everyrhing was ok.

I go to the enterprise manager of my sql2000 and restore the backed up database and this is the error i got.

"Too many backup devices specified for backup or restore; only 64 are allowed. Restore Database is terminating abnormally."

|||Has anybody found useful input on the 64 backup device limit? Same problem here moving a SQL 2005 db to SQL 2005 or 2000.|||

Hi Byrnie,

In my case I have SQL2005 running on my laptop. I needed to move the database onto my server which is currently running SQL 2000. On the laptop and in SQL Server Management Studio I selected the import/export Wizard. Using the wizard I was able to export my SQL2005 tables across to the SQL2000 server. I have not yet completed the process and have just started the job. I will have to verify the data as soon as the job has completed. This is the first time I am contributing anything to a forum. I hope it helps

|||Hi frnds,

I have done the process of Converting SQL 2005 Database into SQL 2000 Database.

1.Create Database in SQL Server 2000 which is the name into SQL 2005.
2.From SQL 2005 Mgmt Console Studio , from Database - tasks - Generate Script
-then select Database -Script for Server Version - Change it from SQL Server 2005 to SQL Server 2000
3. Do the process as per wizard.
4.We can run that Script into SQL Query Analyzer 2000 for that selected database where you want to move it.

Its working fine.I got whole database table creation and whole relationship which was made into SQL Server 2005.

Gr8t.. thanks for your help.

convert SQL 2005 back to SQL 2000

Dear Sir,
Our new test environment running MS SQL 2005. We have finished an
application and need to migrate that to a live server which run SQL 2000.
I have tried enough but with no luck. How can I convert our new SQL 2005
back to 2000 server? The new database contain table schema and quiet some
initial data already. How should I do this?
regards,
Guoqi Zheng
http://www.ureader.com"guoqi zheng" <no@.sorry.com> wrote in message
news:2ea036c11bb84a0eba336a26d25d5624@.ur
eader.com...
> Dear Sir,
> Our new test environment running MS SQL 2005. We have finished an
> application and need to migrate that to a live server which run SQL 2000.
> I have tried enough but with no luck. How can I convert our new SQL 2005
> back to 2000 server? The new database contain table schema and quiet some
> initial data already. How should I do this?
There's no real easy way to do this.
Best bet is to script out the schema, bulk copy out the data and rebuild on
the new box.

> regards,
> Guoqi Zheng
> http://www.ureader.com|||You have to script out all of the objects and then transfer the data using
either BCP, DTS, or SSIS. A 2005 database can not be loaded into 2000 and
it can NOT be downgraded.
Mike
http://www.solidqualitylearning.com
Disclaimer: This communication is an original work and represents my sole
views on the subject. It does not represent the views of any other person
or entity either by inference or direct reference.
"guoqi zheng" <no@.sorry.com> wrote in message
news:2ea036c11bb84a0eba336a26d25d5624@.ur
eader.com...
> Dear Sir,
> Our new test environment running MS SQL 2005. We have finished an
> application and need to migrate that to a live server which run SQL 2000.
> I have tried enough but with no luck. How can I convert our new SQL 2005
> back to 2000 server? The new database contain table schema and quiet some
> initial data already. How should I do this?
> regards,
> Guoqi Zheng
> http://www.ureader.com|||It can be downgraded by setting the DB options to 80 compatibility level IF
the DB doesn't use any of the newer 2005 features.
However, I think it is a mistake to not just upgrade the other server to
2005. Upgrading takes so much work, and if the DB is already working in
2005, then why go through all the hassle downgrading and upgrading when that
same fundamental expense can be borne one time to just pay for the 2005
license.
"Michael Hotek" <mike@.solidqualitylearning.com> wrote in message
news:ec7TGrEYGHA.3328@.TK2MSFTNGP02.phx.gbl...
> You have to script out all of the objects and then transfer the data using
> either BCP, DTS, or SSIS. A 2005 database can not be loaded into 2000 and
> it can NOT be downgraded.
> --
> Mike
> http://www.solidqualitylearning.com
> Disclaimer: This communication is an original work and represents my sole
> views on the subject. It does not represent the views of any other person
> or entity either by inference or direct reference.
>
> "guoqi zheng" <no@.sorry.com> wrote in message
> news:2ea036c11bb84a0eba336a26d25d5624@.ur
eader.com...
>|||Changing the database compatibility level will not allow Guoqi Zheng to go
back to SQL 2000. The on-disk database format will still be SQL 2005 and
will not be recognized by older versions of SQL Server.
Hope this helps.
Dan Guzman
SQL Server MVP
"AFN" <replywithingroup@.notreal.com> wrote in message
news:EL90g.3630$3W1.59@.tornado.socal.rr.com...
> It can be downgraded by setting the DB options to 80 compatibility level
> IF the DB doesn't use any of the newer 2005 features.
> However, I think it is a mistake to not just upgrade the other server to
> 2005. Upgrading takes so much work, and if the DB is already working in
> 2005, then why go through all the hassle downgrading and upgrading when
> that same fundamental expense can be borne one time to just pay for the
> 2005 license.
>
> "Michael Hotek" <mike@.solidqualitylearning.com> wrote in message
> news:ec7TGrEYGHA.3328@.TK2MSFTNGP02.phx.gbl...
>|||If you're not using any SQL 2005 specific features, you can use
Transactional Replication to keep a warm SQL 2000 fallback option open.
Regards,
Greg Linwood
SQL Server MVP
"guoqi zheng" <no@.sorry.com> wrote in message
news:2ea036c11bb84a0eba336a26d25d5624@.ur
eader.com...
> Dear Sir,
> Our new test environment running MS SQL 2005. We have finished an
> application and need to migrate that to a live server which run SQL 2000.
> I have tried enough but with no luck. How can I convert our new SQL 2005
> back to 2000 server? The new database contain table schema and quiet some
> initial data already. How should I do this?
> regards,
> Guoqi Zheng
> http://www.ureader.com

convert SQL 2005 back to SQL 2000

Dear Sir,
Our new test environment running MS SQL 2005. We have finished an
application and need to migrate that to a live server which run SQL 2000.
I have tried enough but with no luck. How can I convert our new SQL 2005
back to 2000 server? The new database contain table schema and quiet some
initial data already. How should I do this?
regards,
Guoqi Zheng
http://www.ureader.com"guoqi zheng" <no@.sorry.com> wrote in message
news:2ea036c11bb84a0eba336a26d25d5624@.ureader.com...
> Dear Sir,
> Our new test environment running MS SQL 2005. We have finished an
> application and need to migrate that to a live server which run SQL 2000.
> I have tried enough but with no luck. How can I convert our new SQL 2005
> back to 2000 server? The new database contain table schema and quiet some
> initial data already. How should I do this?
There's no real easy way to do this.
Best bet is to script out the schema, bulk copy out the data and rebuild on
the new box.
> regards,
> Guoqi Zheng
> http://www.ureader.com|||You have to script out all of the objects and then transfer the data using
either BCP, DTS, or SSIS. A 2005 database can not be loaded into 2000 and
it can NOT be downgraded.
--
Mike
http://www.solidqualitylearning.com
Disclaimer: This communication is an original work and represents my sole
views on the subject. It does not represent the views of any other person
or entity either by inference or direct reference.
"guoqi zheng" <no@.sorry.com> wrote in message
news:2ea036c11bb84a0eba336a26d25d5624@.ureader.com...
> Dear Sir,
> Our new test environment running MS SQL 2005. We have finished an
> application and need to migrate that to a live server which run SQL 2000.
> I have tried enough but with no luck. How can I convert our new SQL 2005
> back to 2000 server? The new database contain table schema and quiet some
> initial data already. How should I do this?
> regards,
> Guoqi Zheng
> http://www.ureader.com|||It can be downgraded by setting the DB options to 80 compatibility level IF
the DB doesn't use any of the newer 2005 features.
However, I think it is a mistake to not just upgrade the other server to
2005. Upgrading takes so much work, and if the DB is already working in
2005, then why go through all the hassle downgrading and upgrading when that
same fundamental expense can be borne one time to just pay for the 2005
license.
"Michael Hotek" <mike@.solidqualitylearning.com> wrote in message
news:ec7TGrEYGHA.3328@.TK2MSFTNGP02.phx.gbl...
> You have to script out all of the objects and then transfer the data using
> either BCP, DTS, or SSIS. A 2005 database can not be loaded into 2000 and
> it can NOT be downgraded.
> --
> Mike
> http://www.solidqualitylearning.com
> Disclaimer: This communication is an original work and represents my sole
> views on the subject. It does not represent the views of any other person
> or entity either by inference or direct reference.
>
> "guoqi zheng" <no@.sorry.com> wrote in message
> news:2ea036c11bb84a0eba336a26d25d5624@.ureader.com...
>> Dear Sir,
>> Our new test environment running MS SQL 2005. We have finished an
>> application and need to migrate that to a live server which run SQL 2000.
>> I have tried enough but with no luck. How can I convert our new SQL 2005
>> back to 2000 server? The new database contain table schema and quiet some
>> initial data already. How should I do this?
>> regards,
>> Guoqi Zheng
>> http://www.ureader.com
>|||Changing the database compatibility level will not allow Guoqi Zheng to go
back to SQL 2000. The on-disk database format will still be SQL 2005 and
will not be recognized by older versions of SQL Server.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"AFN" <replywithingroup@.notreal.com> wrote in message
news:EL90g.3630$3W1.59@.tornado.socal.rr.com...
> It can be downgraded by setting the DB options to 80 compatibility level
> IF the DB doesn't use any of the newer 2005 features.
> However, I think it is a mistake to not just upgrade the other server to
> 2005. Upgrading takes so much work, and if the DB is already working in
> 2005, then why go through all the hassle downgrading and upgrading when
> that same fundamental expense can be borne one time to just pay for the
> 2005 license.
>
> "Michael Hotek" <mike@.solidqualitylearning.com> wrote in message
> news:ec7TGrEYGHA.3328@.TK2MSFTNGP02.phx.gbl...
>> You have to script out all of the objects and then transfer the data
>> using either BCP, DTS, or SSIS. A 2005 database can not be loaded into
>> 2000 and it can NOT be downgraded.
>> --
>> Mike
>> http://www.solidqualitylearning.com
>> Disclaimer: This communication is an original work and represents my sole
>> views on the subject. It does not represent the views of any other
>> person or entity either by inference or direct reference.
>>
>> "guoqi zheng" <no@.sorry.com> wrote in message
>> news:2ea036c11bb84a0eba336a26d25d5624@.ureader.com...
>> Dear Sir,
>> Our new test environment running MS SQL 2005. We have finished an
>> application and need to migrate that to a live server which run SQL
>> 2000.
>> I have tried enough but with no luck. How can I convert our new SQL 2005
>> back to 2000 server? The new database contain table schema and quiet
>> some
>> initial data already. How should I do this?
>> regards,
>> Guoqi Zheng
>> http://www.ureader.com
>>
>|||If you're not using any SQL 2005 specific features, you can use
Transactional Replication to keep a warm SQL 2000 fallback option open.
Regards,
Greg Linwood
SQL Server MVP
"guoqi zheng" <no@.sorry.com> wrote in message
news:2ea036c11bb84a0eba336a26d25d5624@.ureader.com...
> Dear Sir,
> Our new test environment running MS SQL 2005. We have finished an
> application and need to migrate that to a live server which run SQL 2000.
> I have tried enough but with no luck. How can I convert our new SQL 2005
> back to 2000 server? The new database contain table schema and quiet some
> initial data already. How should I do this?
> regards,
> Guoqi Zheng
> http://www.ureader.com

Tuesday, February 14, 2012

Convert float to char

Select Cast('100.1234' as float)
give me the result 100.1234
Now when I convert it back to char I want exactly 100.1234
Select Convert(char(100),Cast('100.1234' as float))
Gives me 100.123 (Here I was expecting 100.1234)

When I do
Select STR(Cast('100.1234' as float),25,4)
I get back the result as 100.1234

However here I am not sure how many digits do I have after the decimal
point. If I put some value like
Select STR(Cast('100.1234' as float),25,8)
I get 0's appended to it, which is again not desired.

Thanks in advance,
Jai
jaijai_kumar@.hotmail.com wrote:

> Select Cast('100.1234' as float)
> give me the result 100.1234
> Now when I convert it back to char I want exactly 100.1234
> Select Convert(char(100),Cast('100.1234' as float))
> Gives me 100.123 (Here I was expecting 100.1234)
> When I do
> Select STR(Cast('100.1234' as float),25,4)
> I get back the result as 100.1234
> However here I am not sure how many digits do I have after the decimal
> point. If I put some value like
> Select STR(Cast('100.1234' as float),25,8)
> I get 0's appended to it, which is again not desired.
>
> Thanks in advance,
> Jai

Hi Jai. I want to warn you about going down this path.
You will never get exactly what you want all the time,
because there is a base converson from base 10 to binary,
and there are lots of distressingly simple-seeming
decimal numbers that do not convert exactly to a binary
float. Then converting back will show the loss by giving
a different value. I suggest using a DECIMAL datatype
if you want to retain exactitude...

Joe Weinstein at BEA Systems|||(jaijai_kumar@.hotmail.com) writes:
> Select Cast('100.1234' as float)
> give me the result 100.1234
> Now when I convert it back to char I want exactly 100.1234
> Select Convert(char(100),Cast('100.1234' as float))
> Gives me 100.123 (Here I was expecting 100.1234)
> When I do
> Select STR(Cast('100.1234' as float),25,4)
> I get back the result as 100.1234
> However here I am not sure how many digits do I have after the decimal
> point. If I put some value like
> Select STR(Cast('100.1234' as float),25,8)
> I get 0's appended to it, which is again not desired.

Since a float is an approximate number, this is not any exact science.
Consider:

SELECT cast('100.1235' as float)

this gives in Query Analyzer:

100.12350000000001

So when you convert it to string, which value do you want?

Anyway, here is a horrible expression that achieves what you are looking
for. But note the caveate above, and be aware that you may not always
get what you want.

Select reverse(substring(x, patindex('%[^0]%', x), 25))
from (Select x = reverse(ltrim(str(Cast('100.1235' as float), 25, 8)))) y

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

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Here is another horrible expression, that does the same thing:

select replace(rtrim(replace(ltrim(str(Cast('100.1235' as float),
25, 8)),'0',' ')),' ','0')

Razvan|||Hello all,

Thanks a lot for all your messages.
Erland your work around gave me a good hint.
I have created a small function to do the same.

Jai
jaijai_kumar@.hotmail.com wrote:
> Select Cast('100.1234' as float)
> give me the result 100.1234
> Now when I convert it back to char I want exactly 100.1234
> Select Convert(char(100),Cast('100.1234' as float))
> Gives me 100.123 (Here I was expecting 100.1234)
> When I do
> Select STR(Cast('100.1234' as float),25,4)
> I get back the result as 100.1234
> However here I am not sure how many digits do I have after the decimal
> point. If I put some value like
> Select STR(Cast('100.1234' as float),25,8)
> I get 0's appended to it, which is again not desired.
>
> Thanks in advance,
> Jai