문제

I'm using Visual Studio 2005 to script out a database so that I can put it in subversion. Now one complaint that I have is that it puts my stored procedure code in a single literal string, like in the example. below.

/****** Object:  StoredProcedure [dbo].[MyStoredProc]    Script Date: 08/19/2010 16:40:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[MyStoredProc]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE   PROCEDURE [dbo].[MyStoredProc]

-- My T-SQL code here

END' 
END
GO

I don't like this because then the syntax highlighting is useless. Is there anyway that I can turn this behaviour off, i.e. so that it removes the

EXEC dbo.sp_executesql @statement = N'

part?

What is the motivation for doing it this way in the first place? String quoting has always been a topic that's somewhat of a blindspot of mine so I'm sure I'm not aware of all the implications. I might be more accepting of this behaviour if I understood what it is for.

Thanks

도움이 되었습니까?

해결책

SQL Server Management studio scripts out as Execute SQL if you select the option

Include If Not Exists

If you uncheck that the script is generated as you are looking for.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top