Single Profile Script vs Multiple Profile Scripts?


Author
Message
William Fields
William Fields
StrataFrame User (326 reputation)StrataFrame User (326 reputation)StrataFrame User (326 reputation)StrataFrame User (326 reputation)StrataFrame User (326 reputation)StrataFrame User (326 reputation)StrataFrame User (326 reputation)StrataFrame User (326 reputation)StrataFrame User (326 reputation)
Group: StrataFrame Users
Posts: 80, Visits: 239
Hello,

I know, probably a simple question with an obvious answer... "it depends..."

But, I have a large number of check constraints that I need to add to a DDT profile as deployment scripts and I was wondering what the benefit would be to create separate scripts for each table, or even each constraint, vs a single script for the entire database.

I can see there is a priority level that can be assigned, which would give me flexibility in the order the scripts are applied, but can anyone else chime in on other (not obvious) benefits of the separate vs combined approach?

Thanks.

Bill
Replies
William Fields
William Fields
StrataFrame User (326 reputation)StrataFrame User (326 reputation)StrataFrame User (326 reputation)StrataFrame User (326 reputation)StrataFrame User (326 reputation)StrataFrame User (326 reputation)StrataFrame User (326 reputation)StrataFrame User (326 reputation)StrataFrame User (326 reputation)
Group: StrataFrame Users
Posts: 80, Visits: 239
OK, that's easy enough (and thanks for the info).

Here's the result:



-- Add the parameters for the stored procedure here

@p_cTableName VARCHAR(100) = '',

@p_cConstraintName VARCHAR(4000) = '',

@p_cConstraintExp VARCHAR(4000) = ''

AS

BEGIN

-- SET NOCOUNT ON added to prevent extra result sets from

-- interfering with SELECT statements.

SET NOCOUNT ON;

IF EXISTS (SELECT * FROM sys.check_constraints WHERE object_id = OBJECT_ID(@p_cConstraintName) AND parent_object_id = OBJECT_ID(@p_cTableName))

BEGIN

EXEC ('ALTER TABLE ' + @p_cTableName + ' DROP CONSTRAINT ' + @p_cConstraintName)

END

IF NOT EXISTS (SELECT * FROM sys.check_constraints WHERE object_id = OBJECT_ID(@p_cConstraintName) AND parent_object_id = OBJECT_ID(@p_cTableName))

BEGIN

EXEC ('ALTER TABLE ' + @p_cTableName + ' WITH NOCHECK ADD CONSTRAINT ' + @p_cConstraintName + ' CHECK (' + @p_cConstraintExp + ')')

END

IF EXISTS (SELECT * FROM sys.check_constraints WHERE object_id = OBJECT_ID(@p_cConstraintName) AND parent_object_id = OBJECT_ID(@p_cTableName))

BEGIN

EXEC ('ALTER TABLE ' + @p_cTableName + ' CHECK CONSTRAINT ' + @p_cConstraintName)

END

END

GO


Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Looks good!  That will serve you much better in the long run.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search