Hi all,
Is there a 3rd party tool that anyone is aware of that'll script out selected objects from a database into individual .sql files for each object in the same/similar format as doing a 'right click|Script table as|Drop and Create|...'?
This is for development, source control and repeatable, error-free, powershell driven deployment.
The Tasks|Generate Scripts... is not suitable because it does the 'if not exists' and wraps the code in a dynamic sql statement for stored procedures which just doesn't work for development
The way it defines defaults on tables also differs from the right click|script|drop and create| output
It doesn't have to be identical to the output from script|drop and create, i just find that format easiest on the eye, it retains the ability to use intellisense when modifying the .sql and it'll deploy error free whether a previous version of the object exists or not.
so to reiterate, something like this for tables/sprocs/views/udfs saved into a separate file for each object:
/****** Object: StoredProcedure [ETL].[Update_Sales_Sales] Script Date: 04/10/2014 12:53:26 ******/ IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ETL].[Update_Sales_Sales]') AND type in (N'P', N'PC')) DROP PROCEDURE [ETL].[Update_Sales_Sales] GO /****** Object: StoredProcedure [ETL].[Update_Sales_Sales] Script Date: 04/10/2014 12:53:26 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create procedure [ETL].[Update_Sales_Sales] AS etc.. GO
Jakub @ Adelaide, Australia