Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 create table with datetime

Author  Topic 

boomboom
Starting Member

6 Posts

Posted - 2003-11-18 : 09:42:39
I'm not very familar with SQL Server so I'm throwing this out here for some help.

I have the following:
CREATE TABLE TRANS (ID int IDENTITY (100,1) PRIMARY KEY,
USER_ID nvarchar(10),
CUST_NO nvarchar(20),
TRANS_ID nvarchar(10),
LP nvarchar(10),
LOC nvarchar(10),
ITEM nvarchar(30),
ORDER_NO nvarchar(20),
DOOR nvarchar(10),
PALLET_QTY integer,
QTY integer,
LOOSE integer,
DT_TM_STAMP as datetime )

And get the following error:
Server: Msg 1759, Level 16, State 1, Line 1
Invalid column 'datetime' is specified in a constraint or computed-column definition.

Any suggestions? TIA

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2003-11-18 : 09:46:58
[code]
TransDate datetime DEFAULT getdate()
[/code]
Go to Top of Page

boomboom
Starting Member

6 Posts

Posted - 2003-11-18 : 09:58:04
Sorry, but that didn't work. My create statement now ends like:

QTY integer,
LOOSE integer,
TRANSDATE as datetime DEFAULT GETDATE() )

Query Analyzer complains again:

Server: Msg 8183, Level 16, State 1, Line 13
Only UNIQUE or PRIMARY KEY constraints are allowed on computed columns.
Go to Top of Page

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2003-11-18 : 10:01:57
Remove "as" before your TRANSDATE datatype declaration.
Go to Top of Page

boomboom
Starting Member

6 Posts

Posted - 2003-11-18 : 10:09:09
Oh wow, always something so little that you overlook sometimes!

Thanks alot ehorn!!
Go to Top of Page
   

- Advertisement -