开发者

SQL Server database script

开发者 https://www.devze.com 2022-12-14 02:52 出处:网络
i need a script to script all the database object (like tables,sp,view).....like IFEXISTS (SELECT * FROM sys.objects

i need a script to script all the database object (like tables,sp,view).....like

 IF  EXISTS (SELECT * FROM sys.objects 
 WHERE object_id = OBJECT_ID(N'[dbo].[fnSplit]') 
 AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
 DROP FUNCTION [dbo].[fnSplit]
 GO

/****** Object:  UserDefinedFunction [dbo].[fnSplit]    Script Date: 12/14/2009  
15:14:23 ******/
SET ANSI_NU开发者_JAVA百科LLS ON
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[fnSplit].......

it will also drop all constraint .....i need a complete package i am aware of tools like scriptio,SQL Management studio(where only one can be selected either create or drop)


You can use Sql Management Studio, if you right click the database, select 'Tasks' and then 'Generate scripts'. In that wizard, you can select all objects (including triggers) and also if you want the script to contain drop commands.


Have a look at this

How to: Generate a Script (SQL Server Management Studio)

This also includes the option for Script Drop and Include If NOT EXISTS under Choose Script Options (which is set to False by default).

0

精彩评论

暂无评论...
验证码 换一张
取 消