Unix Technical Forum

Re: triggers with non existence table reference

This is a discussion on Re: triggers with non existence table reference within the SQL Server forums, part of the Microsoft SQL Server category; --> You could try using the meta-data tables (1) if exists (select 1 from information_schema.tables where table_name = 'OutputHeaderStatusHistory' and ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 05:59 PM
Mystery Man
 
Posts: n/a
Default Re: triggers with non existence table reference

You could try using the meta-data tables

(1) if exists (select 1 from information_schema.tables where
table_name = 'OutputHeaderStatusHistory' and table_type = 'BASE
TABLE')

(2) if exists (select 1 from sysobjects where name =
'OutputHeaderStatusHistory' and xtype = 'U')

INSERT INTO OutputHeaderStatusHistory
(OutputHdrRef, WorkflowStatusRef, UserRef, ChangeDate)
SELECT OutputHdrRef, WorkflowStatusRef, LastUpdateUserRef,
LastUpdateDate
FROM INSERTED
WHERE WorkflowStatusRef in(3,5,7) -- Awaiting Export, exporting,
awaiting settlement
GO
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 05:59 PM
John Pan
 
Posts: n/a
Default Re: triggers with non existence table reference

thanks Mystery Man

What I needed to know was if there is a flag in the administration of
SQL Server that turns off messages about non existence tables when the
trigger is run into the database for the first time?

thanks


PromisedOyster@hotmail.com (Mystery Man) wrote in message news:<87c81238.0306300443.1de481d5@posting.google. com>...
> You could try using the meta-data tables
>
> (1) if exists (select 1 from information_schema.tables where
> table_name = 'OutputHeaderStatusHistory' and table_type = 'BASE
> TABLE')
>
> (2) if exists (select 1 from sysobjects where name =
> 'OutputHeaderStatusHistory' and xtype = 'U')
>
> INSERT INTO OutputHeaderStatusHistory
> (OutputHdrRef, WorkflowStatusRef, UserRef, ChangeDate)
> SELECT OutputHdrRef, WorkflowStatusRef, LastUpdateUserRef,
> LastUpdateDate
> FROM INSERTED
> WHERE WorkflowStatusRef in(3,5,7) -- Awaiting Export, exporting,
> awaiting settlement
> GO

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:45 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com