SQL Server 2005脚本生成 [英] SQL Server 2005 Script Generation

查看:74
本文介绍了SQL Server 2005脚本生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用SQL Server 2005为一个配置为SQL Server 2000的本地

数据库生成了一个脚本。然而,

脚本使用了新的结构和语法(即sys.objects vs.

sysobjects)。有没有办法可以强制SQL Server 2005使用旧的2000语法?
?我注意到当我在远程

SQL Server 2000机器上编写对象时,它确实使用了旧语法。


Bill E.

解决方案

(bi ******** @ netscape.net)写道:


我最近使用SQL Server 2005为一个配置为SQL Server 2000的本地

数据库生成了一个脚本。然而,

脚本使用了新的结构和语法(即sys.objects vs.

sysobjects)。有没有办法可以强制SQL Server 2005使用旧的2000语法?
?我注意到当我在远程

SQL Server 2000机器上编写对象时,它确实使用了旧语法。



如果您使用任务 - >生成脚本,您将到达选项对话框

,您可以在其中选择SQL 2000语法。如果您直接从对象资源管理器编写单个对象

,则无法设置选项。

-

Erland Sommarskog,SQL Server MVP , es****@sommarskog.se


SQL Server 2005联机丛书在
http:// www .microsoft.com / technet / pro ... ads / books.mspx

SQL Server 2000联机丛书
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Erland,


我选择了SQL Server 2000选项,但我还在编写脚本
$看起来像是为SQL Server 2005制作的b $ b。你有能力做这个工作吗?


Bill

(BI ******** @净scape.net)写道:


我选择了SQL Server 2000选项,但我仍然得到脚本

看起来像它是为SQL Server 2005而制作的。你能否使这个工作成为




是的。我实际上并没有尝试在SQL 2000上运行脚本,因此可能还会出现故障。但我确实得到了类似的东西:


如果不是EXISTS(SELECT * FROM dbo.sysobjects WHERE id =

OBJECT_ID(N''[dbo]。[ language_rule]'')AND OBJECTPROPERTY(id,N''IsRule'')= 1)

EXEC dbo.sp_executesql N''

CREATE RULE [dbo]。[ language_rule] AS @x IN(''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''$ $ $ $ $ $ $



,它不会在SQL 2005上说。


-

Erland Sommarskog,SQL Server MVP , es****@sommarskog.se


SQL Server 2005联机丛书在
http:// www .microsoft.com / technet / pro ... ads / books.mspx

SQL Server 2000联机丛书
http://www.microsof t.com/sql/prodinf...ons/books.mspx


I recently generated a script using SQL Server 2005 for a local
database that is configured as SQL Server 2000. Nevertheless, the
script used the new structures and syntax (i.e., sys.objects vs.
sysobjects). Is there a way that I can force SQL Server 2005 to use
the old 2000 syntax? I notice that when I script objects on a remote
SQL Server 2000 machine, it does use the old syntax.

Bill E.

解决方案

(bi********@netscape.net) writes:

I recently generated a script using SQL Server 2005 for a local
database that is configured as SQL Server 2000. Nevertheless, the
script used the new structures and syntax (i.e., sys.objects vs.
sysobjects). Is there a way that I can force SQL Server 2005 to use
the old 2000 syntax? I notice that when I script objects on a remote
SQL Server 2000 machine, it does use the old syntax.

If you use Tasks->Generate Scripts you will arrive at an options dialog
where you can select SQL 2000 syntax. If you script individual objects
directly from Object Explorer, there is no way to set options.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Erland,

I selected the SQL Server 2000 option, but I''m still getting script
that looks like it was made for SQL Server 2005. Are you able to make
this work?

Bill


(bi********@netscape.net) writes:

I selected the SQL Server 2000 option, but I''m still getting script
that looks like it was made for SQL Server 2005. Are you able to make
this work?

Yes. I did not actually try to run the script on SQL 2000, so there may
still be glitches. But I did get things like:

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id =
OBJECT_ID(N''[dbo].[language_rule]'') AND OBJECTPROPERTY(id, N''IsRule'') = 1)
EXEC dbo.sp_executesql N''
CREATE RULE [dbo].[language_rule] AS @x IN (''''E'''', ''''S'''') OR @x IS NULL
''
GO

which it would not say on SQL 2005.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


这篇关于SQL Server 2005脚本生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆