Solved

TSQL Insert With Just Default Values

Posted on 2011-03-03
3
214 Views
Last Modified: 2012-05-11
Hi Experts,

Don't know if this is possible. Have a table with just an ID and datetime so both are set with defaults.

CREATE TABLE [dbo].[tb_ErrorLog](
	[errorLogID] [int] IDENTITY(1,1) NOT NULL,
	[errorLogDate] [datetime] NOT NULL,
 CONSTRAINT [PK_tb_ErrorLog] PRIMARY KEY CLUSTERED 
(
	[errorLogID] 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

ALTER TABLE [dbo].[tb_ErrorLog] ADD  CONSTRAINT [DF_tb_ErrorLog_errorLogDate]  DEFAULT (getdate()) FOR [errorLogDate]
GO

Open in new window


All I want to do is to increment the table with a record every time a particular web page is reached.

So how do you write the INSERT statement without any passed values?

Regs,
Numb
0
Comment
Question by:ComfortablyNumb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Expert Comment

by:Asim Nazir
ID: 35026483
INSERT INTO [SS].[dbo].[tb_ErrorLog]
           ([errorLogDate])
     VALUES
           (default)
0
 
LVL 10

Accepted Solution

by:
Asim Nazir earned 500 total points
ID: 35026516
Also you can use following:
INSERT INTO [SS].[dbo].[tb_ErrorLog]
           DEFAULT VALUES
0
 

Author Closing Comment

by:ComfortablyNumb
ID: 35026589
As simple as that! cheers
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question