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.
| Author |
Topic |
|
sinjin67
Yak Posting Veteran
53 Posts |
Posted - 2008-03-21 : 18:02:07
|
| GreetingsAgain 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/orinsert into audit2, when the user hits save butttonI am not sure which is better to use append/insert intoI have started building this with the following, but coulduse 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 KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
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 |
 |
|
|
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 |
 |
|
|
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 KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
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. |
 |
|
|
|
|
|
|
|