Here's the trigger, wtih actual variables I'm trying to set. My problem is the @commonDB, where I'm trying to get a database name that will be unique to this server. When I try to execute, it tells me I must declare the variable. If I just set it to a string variable, it is fine.
Thnaks
CREATE TRIGGER tgInsPubCat
ON dbo.PPPCat
FOR INSERT
AS
BEGIN
DECLARE @acronym char (3)
DECLARE @Acctno char (8)
DECLARE @dtcat smalldatetime
DECLARE @cdcat varchar (3)
DECLARE @tramount as smallmoney
DECLARE @ccNum varchar (16)
DECLARE @ccexp varchar (6)
DECLARE @batch varchar (4)
DECLARE @checkno varchar (34)
DECLARE @pass varchar (6)
DECLARE @commondb varchar (35)
SELECT @ccexp = cc_exp,
@acronym = acronym,
@Acctno = acctno,
@dtcat = dtcat,
@cdcat = cc_exp,
@tramount = tramount,
@ccNum = checkno,
@ccexp = cc_Exp,
@batch= batch,
@pass = 'PASS'
FROM INSERTED
If Len(@ccexp) > 0
BEGIN
---Get common database, get server path for write
SET @commondb =(SELECT name FROM master..sysdatabases where name like
'[a-z]%Common')
INSERT INTO @commondb VALUES (@acronym, @Acctno, @dtcat, @cdcat,@tramount, @checkno, @ccexp,@batch)
END
END