April 29, 2005 at 10:21 pm
I am new in sql and I would like to declear time in my table but if I declear it as datetime I get erros in entering time like 20:30. My delearation was StartTime dateTime but I get erros. the erro says I am entering data type in place of dateTime. Also how can I generate an auto number like New CustomerID being generated automatically whenever I want to add new customer. Lastly how can I declear a number with a decimal point example 40.50 when I declear it as decimal I am able to enter data alright but when I call the data it only reads 40 instead of 40.50. Pls help Confuse student.
April 30, 2005 at 6:52 pm
1) Try inputing the time in as '20:30:00', sql i sometimes finacky. Or use '08:30 PM'. Sorry no SQL here to verify I am telling you right but I do these all the time with no issue.
2) Auto numbr is an identity field look in sql books online (BOL) fr more details, it i a property in Enterprise Manager or i doin programtically with DDL you do
columnname datatype IDENTITY(start value, increment value) not null
or
Customer_ID int IDENTITY(1,1) not null
3) Decimal data type has two additional parameters you need to ser percision and scale
percision is the maximum entire length a number can be, scale the number of decimal positions.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_da-db_8rc5.asp
More details in BOL.
May 1, 2005 at 11:00 pm
Strange error.
Probably you forgot about quotes.
declare @StartTime dateTime
set @StartTime = '20:30'
works absolutely fine.
_____________
Code for TallyGenerator
May 2, 2005 at 1:32 am
Post the code you use along with the error you get. This will be more descriptive than any narrative.
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply