Solved

TSQL Insert With Just Default Values

Posted on 2011-03-03
3
212 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
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 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