2012年3月11日星期日

Any suggestions?

I have a database which contains more than 20000 stored procedures
which were created with
ansi nulls off. This i found out using the query
SELECT name,AnsiNullsOn FROM
(
SELECT name, OBJECTPROPERTY(id, 'ExecIsAnsiNullsOn') AS AnsiNullsOn
FROM sysobjects WHERE type = 'P' ) A WHERE AnsiNullsOn=0

Is there any way that i can set this property to 1 for all the stored
procedures i have??

I know the alternate method is to drop the procedure and execute the
scripts again with AnsiNullsOn = 1.

Is there any other simple ways?? It will be very helpful for me..I believe this will do the job, though I suggest some small-scale
tests first.

1) Script out all the procs as CREATEs, but do not include the DROP
option.

2) Edit the script.

- Change CREATE PROC to ALTER PROC for all procedures.

- Change all the SET ANSI_NULLS ( and possibly the SET
QUOTED_IDENTIFIER) commands as you want them.

3) Run the script.

Roy Harvey
Beacon Falls, CT

On 21 Nov 2006 14:17:38 -0800, "balaji" <mailbalajijagan@.gmail.com>
wrote:

Quote:

Originally Posted by

>I have a database which contains more than 20000 stored procedures
>which were created with
>ansi nulls off. This i found out using the query
>SELECT name,AnsiNullsOn FROM
>(
>SELECT name, OBJECTPROPERTY(id, 'ExecIsAnsiNullsOn') AS AnsiNullsOn
>FROM sysobjects WHERE type = 'P' ) A WHERE AnsiNullsOn=0
>
>Is there any way that i can set this property to 1 for all the stored
>procedures i have??
>
>I know the alternate method is to drop the procedure and execute the
>scripts again with AnsiNullsOn = 1.
>
>Is there any other simple ways?? It will be very helpful for me..

|||balaji wrote:

Quote:

Originally Posted by

I have a database which contains more than 20000 stored procedures
which were created with
ansi nulls off. This i found out using the query
SELECT name,AnsiNullsOn FROM
(
SELECT name, OBJECTPROPERTY(id, 'ExecIsAnsiNullsOn') AS AnsiNullsOn
FROM sysobjects WHERE type = 'P' ) A WHERE AnsiNullsOn=0
>
Is there any way that i can set this property to 1 for all the stored
procedures i have??
>
I know the alternate method is to drop the procedure and execute the
scripts again with AnsiNullsOn = 1.
>
Is there any other simple ways?? It will be very helpful for me..


Just to state the obvious. Since there are potential behaviour changes
associated with changing the setting it seems like the bigger task
could be testing the procs rather than making the change.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/...US,SQL.90).aspx
--

没有评论:

发表评论