Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

SQL Server INSERT (easy question)

date posted 10th July 2001 10:38

Hi all

I know this is a really simple question but I just can't find the answer to
it anywhere, possibly a case of wood and trees. I'm trying to insert data
into a SQL Server table. However I'm having real trouble with the syntax
for inserting dates and times. I've tried using #07/07/01# which works fine
in Access, but that doesn't work in SQL Server. Putting the date in single
quotes seems to work, although I think that there's some converting going
on, but it doesn't appear to work for times. Could anyone point out what
I'm doing wrong, or (and possibly better) point me to some information on
this? I've included the table information and the SQL statement at the
bottom of this email

Thanks in advance

Norman

The table loooks like this:

motiveID int 4 10 0 0 1 1 1 0
motiveTitle varchar 50 0 0 0 0 0
motiveForename varchar 50 0 0 0 0 0
motiveSurname varchar 50 0 0 0 0 0
motiveOrganisation varchar 50 0 0 0 ('Private Individual') 0 0
motiveAddress varchar 250 0 0 0 0 0
motivePostCode varchar 10 0 0 0 0 0
motiveTelephone varchar 50 0 0 0 0 0
motiveEmail varchar 50 0 0 0 0 0
motiveContactMethod char 4 0 0 0 0 0
motiveDate smalldatetime 4 0 0 0 0 0
motiveStart smalldatetime 4 0 0 0 0 0
motiveFinish smalldatetime 4 0 0 0 0 0
motiveVenue varchar 50 0 0 0 0 0
motiveGuests int 4 10 0 0 0 0
motivePackageID smallint 2 5 0 0 0 0
motiveDateBooked smalldatetime 4 0 0 0 0 0

The SQL statement looks like this:

INSERT INTO motivaction ( motiveTitle, motiveForename, motiveSurname,
motiveOrganisation, motiveAddress, motivePostcode, motiveTelephone,
motiveEmail, motiveContactMethod, motiveDate, motiveStart, motiveFinish,
motiveVenue, motiveGuests, motivePackageID, motiveDateBooked)
VALUES ('Miss', 'Anne', 'Cooper', 'Private Individual', '157 Houblon
RoadRichmondSurrey', 'TW10 6DB', '020 2222 2222,
[EMAIL REMOVED] 'Email', #22/November/2001#, #18.00#, #23.30#,
'My house', 45, 9, #7/10/01#);



Messages by Day
July 31st 2001
July 30th 2001
July 29th 2001
July 28th 2001
July 27th 2001
July 26th 2001
July 25th 2001
July 24th 2001
July 23rd 2001
July 22nd 2001
July 21st 2001
July 20th 2001
July 19th 2001
July 18th 2001
July 17th 2001
July 16th 2001
July 15th 2001
July 14th 2001
July 13th 2001
July 12th 2001
July 11th 2001
July 10th 2001
July 9th 2001
July 8th 2001
July 7th 2001
July 6th 2001
July 5th 2001
July 4th 2001
July 3rd 2001
July 2nd 2001
July 1st 2001


Messages by Month
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
January 2001


Messages by Year
2009
2008
2007
2006
2005
2004
2003
2002
2001
2000