Solved

TSQL Insert With Just Default Values

Posted on 2011-03-03
3
208 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
  • 2
3 Comments
 
LVL 10

Expert Comment

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

Accepted Solution

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

Author Closing Comment

by:ComfortablyNumb
Comment Utility
As simple as that! cheers
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now