surajit khamrai
surajit khamrai

Reputation:

SQL Server database script

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_NULLS 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)

Upvotes: 1

Views: 268

Answers (2)

Adriaan Stander
Adriaan Stander

Reputation: 166396

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).

Upvotes: 0

Jonas Lincoln
Jonas Lincoln

Reputation: 9767

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.

Upvotes: 2

Related Questions