synchronization script

Compares and synchronizes SQL Server databases, backups and scripts.

Moderators: JonathanWatts, Chris Auckland, David Atkinson, eddie davis, Anu Deshpande, Michelle Taylor, alice.easey, james.billings, chengvoon.tong

synchronization script

Postby rgfriend » Fri Jun 08, 2012 12:24 am

I use SQL compare to compare my dev database with production.

Since I only modify a column 's length to a table, it shows the table schema is different, and all is fine until I get to the generate script screen, I see the script also includes alter trigger of the table.
Nothing actaully changed in the trigger.
And in the review dependency screen, nothing shows there.

So I don't understand why the script include alter trigger statement.

I think the script should only shows the alter column statement.

Thanks
rgfriend
 
Posts: 11
Joined: Sun Jun 12, 2011 4:46 pm

Postby Brian Donahue » Mon Jun 11, 2012 2:44 pm

I would understand why the trigger would not show up as a dependency, because triggers are considered part of the table definition rather than a free-standing object.

The only reason for modifying the trigger that I can think of is if the modified column is somehow involved in the trigger definition.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby rgfriend » Mon Jun 11, 2012 4:20 pm

But I only change the length of the column.

I didn't see why there is a need to refresh the trigger.

So is this a bug of SQL compare?
rgfriend
 
Posts: 11
Joined: Sun Jun 12, 2011 4:46 pm

Postby ktrainer » Mon Jun 11, 2012 7:40 pm

Hi rgfriend,

I would say no it is not a bug if the trigger is indeed dependent upon the modified column. It seems reasonable to me that SQL compare would include the trigger as it does not know what the trigger actually does and what effect modifying the column has on the trigger. In your case probably nothing, since you are increasing the length of the column, but what if you decrerased the size? Then there may be an issue.

Just my two cents...
ktrainer
 
Posts: 4
Joined: Thu Jun 07, 2012 7:35 pm

Postby rgfriend » Mon Jun 11, 2012 9:11 pm

Thanks, but even if I decrease the size, I don't think the trigger is affected.

It is just a trigger for update , delete.

Something like below:
I only increase the size of one column for example AccidentType

CREATE trigger [dbo].[Investigation_Trigger] on [dbo].[Investigation] for update, delete
as
set nocount on

insert Investigation (
LogDate,
LogNbr,
WorkgroupId,
CarrierId,
ControlNbr,
SchoolId,
SchoolYear,
StudentId,
InvestigationStatusId,
AccidentType,
CreateDate,
CreatedBy,
ChangeDate,
ChangedBy)
select LogDate,
LogNbr,
WorkgroupId,
CarrierId,
ControlNbr,
SchoolId,
SchoolYear,
StudentId,
InvestigationStatusId,
AccidentType
CreateDate,
CreatedBy,
ChangeDate,
ChangedBy
from deleted

GO
rgfriend
 
Posts: 11
Joined: Sun Jun 12, 2011 4:46 pm

Postby Brian Donahue » Tue Jun 12, 2012 9:30 am

If I try the same thing manually in SQL Server, it will not allow me to modify the column and displays a message saying the table must be created.
Code: Select all
/****** Object:  Table [dbo].[Table_1]    Script Date: 06/12/2012 09:21:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Table_1](
   [id] [int] NOT NULL,
   [data] [nvarchar](50) NULL,
 CONSTRAINT [PK_Table_1] PRIMARY KEY CLUSTERED
(
   [id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
CREATE TRIGGER dbo.tbtrg1
   ON  dbo.table_1
   for INSERT
AS
BEGIN
   -- SET NOCOUNT ON added to prevent extra result sets from
   -- interfering with SELECT statements.
   SET NOCOUNT ON;

    -- Insert statements for trigger here
    INSERT INTO table_1 (data) SELECT data+'uhhuh' FROM inserted
END
GO

Change the data column to a length of 150 in the query designer and it says the table needs to be rebuilt. If you script it by hand, though, it works.
Code: Select all
ALTER TABLE dbo.Table_1 ALTER COLUMN data NVARCHAR(150) NOT NULL
There must be some circumstances where it's not allowed to change the column. If you have a script from both sides I would be happy to try and reproduce the issue.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am


Return to SQL Compare 10

Who is online

Users browsing this forum: No registered users and 0 guests

cron