Saturday, February 25, 2012
Capturing SQL Data via Triggers
The code below only captures previous recorded profile information but not the profile information currently being saved.
How can I correct this issue?
TRIGGER INFORMATION:
USE heat601
IF EXISTS (SELECT name FROM sysobjects
WHERE name = 'trk_profile' AND type = 'TR')
DROP TRIGGER trk_profile
GO
CREATE TRIGGER trk_profile
ON profile
FOR INSERT
AS
DECLARE @.vTracker varchar(10), @.vTrackername varchar (25), @.vAuditDate varchar(10), @.vCustId varchar(10)
SELECT @.vTracker = profile.Tracker, @.vTrackername = calllog.RbyFullName, @.vAuditDate = profile.DTLMod, @.vCustId = profile.CustId
From profile JOIN calllog On profile.custid = calllog.custid
Insert Into AuditTrail Values(@.vTracker,@.vTrackername,@.vAuditDate,@.vCusti d)
EXEC master..xp_sendmail 'tward@.caremark.com',
'HEAT CMS customer profile is currently being manipulated.'
GODo U use the Temporary Inserted & Deleted Tables ?
Friday, February 24, 2012
Capture time alone in SQL Server database
Is there any data type in SQL Server 2005 which captures only the TIME in default DATETIME type?
For example, if the datatime field has a value2007-12-11 12:31:00.000, i need a datatype which can capture12:31:00.000 alone. The data type should be in a fashion so that i can find differences in time also...
Any ideas??
Hi,
SQL Server does not have any type which can store only time. One way is to store it as datetime, and when fetching these times, you can convert them to only show time.
|||
venkatesh_ur:
Is there any data type in SQL Server 2005 which captures only the TIME in default DATETIME type?
I'm afraid there is no Datatype to fetch the time only. But of course there are some functions that can be used to get the time part out of any datatime value. Below query will get you the time (converted as varchar):
select getdate() , convert ( varchar , getdate() , 8 )
venkatesh_ur:
he data type should be in a fashion so that i can find differences in time also...
To compare date and time values theDatepartandDateNamefunctions can be useful. They both are quite similar to each other. Read Books Online for more help on these functions.