Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Insert Into

Author  Topic 

sinjin67
Yak Posting Veteran

53 Posts

Posted - 2008-03-21 : 18:02:07
Greetings

Again I am trying to adapt from Foxpro to SQL but have
gotten a little stuck on structure.

My goal is grab value from field audit1 and append and/or
insert into audit2, when the user hits save buttton

I am not sure which is better to use append/insert into

I have started building this with the following, but could
use some expert advice.

INSERT INTO Active (audit2)
VALUES (Audit1)

Thank You

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-03-21 : 18:43:39
There is no append in SQL. Could you show us a data example of what you are trying to do as your post isn't very clear?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-03-21 : 18:44:32
There is no "append" in SQL Server. You can also UPDATE, which will overwrite an existing field.
Give us more detail about what it is you want to do (table structures, logic, etc.)

Jim
Go to Top of Page

sinjin67
Yak Posting Veteran

53 Posts

Posted - 2008-03-21 : 19:33:19
After thinking this thru some, I am basically trying to create a trigger that will write the Username, Date and Record Number to
a Audit Table When the user Updates the record. If you have a better approach on this, Any insight would be great..

I built this out so far.

CREATE TRIGGER Audit
ON dbo.Active
FOR UPDATE

BEGIN

INSERT Audit
(Audit1,Username, Anumber)
SELECT Audit1,Username, Anumber()
FROM Active

END
GO
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-03-21 : 19:35:17
You should be using the inserted or deleted trigger tables instead of Active.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-23 : 12:27:20
The DELETED & INSERTED tables are internal tables which holds the old and new values of your table during the update operation.The results of these are available inside the trigger.
Go to Top of Page
   

- Advertisement -