SQL Configuration

Hello Experts

    Can SQL Server 2005  be configured to populate a Time_Stamp field with the current date / time when the record is created?  How would you go about doing this?

Thank you for your time

algotubeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee SavidgeCommented:
Éric MoreauSenior .Net ConsultantCommented:
You can't. A timestamp field is a number field!
Éric MoreauSenior .Net ConsultantCommented:
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Lee SavidgeCommented:
That depends on your table. I have a database that has a time stamp field in all the tables that is a datetime field.

Lee
Éric MoreauSenior .Net ConsultantCommented:
>>That depends on your table. I have a database that has a time stamp field in all the tables that is a datetime field.

in Microsoft SQL Server with a field declared with a TimeStamp datatype?
Lee SavidgeCommented:
Nope, it is a field called timestamp declared with a datetime data type.
algotubeAuthor Commented:
Thanks everyone for your reply here is the structure of my table:


USE [ShearLine]
GO
/****** Object:  Table [dbo].[Master_Plate]    Script Date: 04/07/2011 10:15:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Master_Plate](
      [Plate_No] [char](12) NOT NULL,
      [Section_ID] [char](1) NOT NULL,
      [Cust_Name] [char](14) NULL,
      [Ord_Wid_Imp] [real] NULL,
      [Ord_Wid_Met] [real] NULL,
      [Ord_Gauge_Imp] [real] NULL,
      [Ord_Gauge_Met] [real] NULL,
      [Gauge_Tol_Pos_Imp] [real] NULL,
      [Gauge_Tol_Pos_Met] [real] NULL,
      [Gauge_Tol_Neg_Imp] [real] NULL,
      [Gauge_Tol_Neg_Met] [real] NULL,
      [Next_Process_Code] [char](3) NULL,
      [Prev_Process_Code] [char](3) NULL,
      [Width_Tol_Pos_Imp] [real] NULL,
      [Width_Tol_Pos_Met] [real] NULL,
      [Width_Tol_Neg_Imp] [real] NULL,
      [Width_Tol_Neg_Met] [real] NULL,
      [Rot_Horiz_Gap] [real] NULL,
      [Rot_Vert_Gap] [real] NULL,
      [Slit_Horiz_Gap] [real] NULL,
      [Slit_Vert_Gap] [real] NULL,
      [Test_Code] [char](2) NULL,
      [Special_Cut_Instr] [char](40) NULL,
      [Ruck_No] [int] NULL,
      [Plate_Status] [char](10) NULL,
      [Time_Stamp] [datetime] NULL,
 CONSTRAINT [PK_Master_Plate] PRIMARY KEY CLUSTERED
(
      [Plate_No] ASC,
      [Section_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
Lee SavidgeCommented:

USE [ShearLine]
GO
/****** Object:  Table [dbo].[Master_Plate]    Script Date: 04/07/2011 10:15:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Master_Plate](
      [Plate_No] [char](12) NOT NULL,
      [Section_ID] [char](1) NOT NULL,
      [Cust_Name] [char](14) NULL,
      [Ord_Wid_Imp] [real] NULL,
      [Ord_Wid_Met] [real] NULL,
      [Ord_Gauge_Imp] [real] NULL,
      [Ord_Gauge_Met] [real] NULL,
      [Gauge_Tol_Pos_Imp] [real] NULL,
      [Gauge_Tol_Pos_Met] [real] NULL,
      [Gauge_Tol_Neg_Imp] [real] NULL,
      [Gauge_Tol_Neg_Met] [real] NULL,
      [Next_Process_Code] [char](3) NULL,
      [Prev_Process_Code] [char](3) NULL,
      [Width_Tol_Pos_Imp] [real] NULL,
      [Width_Tol_Pos_Met] [real] NULL,
      [Width_Tol_Neg_Imp] [real] NULL,
      [Width_Tol_Neg_Met] [real] NULL,
      [Rot_Horiz_Gap] [real] NULL,
      [Rot_Vert_Gap] [real] NULL,
      [Slit_Horiz_Gap] [real] NULL,
      [Slit_Vert_Gap] [real] NULL,
      [Test_Code] [char](2) NULL,
      [Special_Cut_Instr] [char](40) NULL,
      [Ruck_No] [int] NULL,
      [Plate_Status] [char](10) NULL,
      [Time_Stamp] [datetime] default getdate()
 CONSTRAINT [PK_Master_Plate] PRIMARY KEY CLUSTERED
(
      [Plate_No] ASC,
      [Section_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lee SavidgeCommented:
See above code.

Lee
Éric MoreauSenior .Net ConsultantCommented:
since the beginning I was thinking that you were using a field of a TimeStamp datatype!
algotubeAuthor Commented:
Thank you
Lee SavidgeCommented:
You're welcome.

Lee
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.