Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1957
  • Last Modified:

SQL Server 2005 rowid - invalid coulmn name

SQL Server 2005 ROWID -  invalid column name  I keep getting an invalid column name message from the attached code...  The trigger works if I comment out the where clause...  I even tried using the row number function  -  SELECT ROW_NUMBER () OVER (ORDER BY id) AS ROWID FROM dbo.
able1; no luck.  Your help is appreciated!  Am I  missing a declaration or what?
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
CREATE TRIGGER trg_New_Trigger
   ON  dbo.Table1
   FOR INSERT,  UPDATE
 AS
 
BEGIN
                 SET NOCOUNT ON;
UPDATE dbo.Table1
SET dbo.Table1.Target_Column = (Select substring(cast(getdate() AS CHAR(11)),10,2) + cast(inserted.ID AS CHAR(10))
                                     From inserted)
WHERE dbo.Table1.ROWID IN (SELECT ROWID FROM inserted)
END
GO

Open in new window

0
stang1
Asked:
stang1
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
is ROWID an existing column in your table?
in other words, what is the primary key column of your table?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
say, the PK column was named PK indeed:
CREATE TRIGGER trg_New_Trigger
   ON  dbo.Table1
   FOR INSERT,  UPDATE
 AS
 
BEGIN
                 SET NOCOUNT ON;
UPDATE t1 
SET Target_Column = substring(cast(getdate() AS CHAR(11)),10,2) + cast(i.ID AS CHAR(10) )
  FROM dbo.Table1 t1
  JOIN inserted i
    on i.PK = t1.PK
END

Open in new window

0
 
stang1Author Commented:
It worked, thanks!  Your rank describes you well....
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now