update qw_ticket set qw_agentid = 0, qw_ownerid = 0
go
ALTER TABLE [dbo].[QW_TICKET] DROP CONSTRAINT [fk_qw_ticket_agent]
GO
ALTER TABLE [dbo].[QW_TICKET] ADD CONSTRAINT [fk_qw_ticket_agent] FOREIGN KEY([qw_agentid])
REFERENCES [dbo].[QX_USERS] ([pkey])
GO

ALTER TABLE [dbo].[QW_TICKET] DROP CONSTRAINT [fk_qw_ticket_owner]
GO
ALTER TABLE [dbo].[QW_TICKET] ADD CONSTRAINT [fk_qw_ticket_owner] FOREIGN KEY([qw_ownerid])
REFERENCES [dbo].[QX_USERS] ([pkey])
GO

update qw_interaction set qw_agentid = 0
go

ALTER TABLE [dbo].[QW_INTERACTION] DROP CONSTRAINT [fk_qw_inter_agent]
GO
ALTER TABLE [dbo].[QW_INTERACTION]  WITH CHECK ADD  CONSTRAINT [fk_qw_inter_agent] FOREIGN KEY([qw_agentid])
REFERENCES [dbo].[QX_USERS] ([pkey])
GO

-- all new update scripts must include a line like this:
UPDATE QX_SYS_PROP SET PROP_VAL = '049' WHERE (PROP_ID = 'DB_APP_VERSION');
