| Author |
Topic |
|
kashyapsid
Yak Posting Veteran
78 Posts |
Posted - 2010-05-31 : 07:46:22
|
i want to create a table in which a column is the date and time the column must be automatically updated when data is added in the table as the identity column can u give a suggestion CREATE TABLE firms (ItemNo int IDENTITY NOT NULL,CustomerName varchar(30) NOT NULL,Address1 varchar(30) NOT NULL,date& time Contact varchar(25) NOT NULL,Phone char(15) NOT NULL)beside the date & time wt can i add to auto update the column KaShYaP |
|
|
kashyapsid
Yak Posting Veteran
78 Posts |
Posted - 2010-05-31 : 08:08:42
|
| please considerKaShYaP |
 |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-05-31 : 08:11:34
|
| Use getdate() function at the time of insertion or updation...Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-31 : 08:14:32
|
| CREATE TABLE firms (ItemNo int IDENTITY NOT NULL,CustomerName varchar(30) NOT NULL,Address1 varchar(30) NOT NULL,date_time datetime default getdate(),Contact varchar(25) NOT NULL,Phone char(15) NOT NULL)MadhivananFailing to plan is Planning to fail |
 |
|
|
kashyapsid
Yak Posting Veteran
78 Posts |
Posted - 2010-05-31 : 08:20:23
|
quote: Originally posted by madhivanan CREATE TABLE firms (ItemNo int IDENTITY NOT NULL,CustomerName varchar(30) NOT NULL,Address1 varchar(30) NOT NULL,date_time datetime default getdate(),Contact varchar(25) NOT NULL,Phone char(15) NOT NULL)MadhivananFailing to plan is Planning to fail
this works but i can't insert the data into the table wt's the reason i can't understandKaShYaP |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-31 : 08:22:09
|
quote: Originally posted by kashyapsid
quote: Originally posted by madhivanan CREATE TABLE firms (ItemNo int IDENTITY NOT NULL,CustomerName varchar(30) NOT NULL,Address1 varchar(30) NOT NULL,date_time datetime default getdate(),Contact varchar(25) NOT NULL,Phone char(15) NOT NULL)MadhivananFailing to plan is Planning to fail
this works but i can't insert the data into the table wt's the reason i can't understandKaShYaP
You need to omit that column in the INSERT statementMadhivananFailing to plan is Planning to fail |
 |
|
|
kashyapsid
Yak Posting Veteran
78 Posts |
Posted - 2010-05-31 : 08:24:09
|
| @madivan|ItemNo|CustomerName|Address1|date_time|this is the table & i have removed the last two columns that are contact & phone Plz considerKaShYaP |
 |
|
|
kashyapsid
Yak Posting Veteran
78 Posts |
Posted - 2010-05-31 : 08:25:49
|
| insert into firms ('Jow', 'plipians')i am using this commandKaShYaP |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-31 : 08:27:44
|
| insert into firms (CustomerName,Address1)select 'Jow', 'plipians'MadhivananFailing to plan is Planning to fail |
 |
|
|
kashyapsid
Yak Posting Veteran
78 Posts |
Posted - 2010-05-31 : 08:29:08
|
| thanks alot this works really thanks for consideringKaShYaP |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-31 : 08:30:00
|
quote: Originally posted by kashyapsid thanks alot this works really thanks for consideringKaShYaP
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|