Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Create table using script in ASP page
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Create table using script in ASP page

 Post Reply Post Reply
Author
808Rider View Drop Down
Senior Member
Senior Member

Vebro Solutions CEO http://www.vebro.net

Joined: 20 April 2003
Status: Offline
Points: 405
Post Options Post Options   Thanks (0) Thanks(0)   Quote 808Rider Quote  Post ReplyReply Direct Link To This Post Topic: Create table using script in ASP page
    Posted: 28 December 2003 at 10:14pm

I know how to create tables using script in an ASP page except I cannot figure out the correct syntax to create a True/False table and set it to either true or false when I create it.

strSQL = "CREATE TABLE test (field yesno(1))"

strSQL = "CREATE TABLE test (field yesno(yes))"

Neither one works. Any ideas how to make the field?

Also here's another question I want to make a field name Date but it won't allow that because Date is a reserved word.

strSQL = "CREATE TABLE test (Date datetime)"

Anyway to be able to get it to create the field named Date?

Back to Top
adnan248999 View Drop Down
Newbie
Newbie
Avatar

Joined: 30 November 2003
Location: United Kingdom
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote adnan248999 Quote  Post ReplyReply Direct Link To This Post Posted: 28 December 2003 at 10:47pm

Hmm not sure about the yes/no field but as for the field name for date try this to see if it works

strSQL = "CREATE TABLE test ([Date] datetime)"

Back to Top
808Rider View Drop Down
Senior Member
Senior Member

Vebro Solutions CEO http://www.vebro.net

Joined: 20 April 2003
Status: Offline
Points: 405
Post Options Post Options   Thanks (0) Thanks(0)   Quote 808Rider Quote  Post ReplyReply Direct Link To This Post Posted: 28 December 2003 at 11:20pm
Originally posted by adnan248999 adnan248999 wrote:

Hmm not sure about the yes/no field but as for the field name for date try this to see if it works

strSQL = "CREATE TABLE test ([Date] datetime)"

I'll give it a go, but I tried this by doing the following before

strSQL = "CREATE TABLE test ('Date' datetime)"

This created a field actually named 'Date' and included the single quote.

I think maybe that your suggestion will create a field named [Date] and include the brackets as part of the field name.

I'll give it a go and report back.

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 29 December 2003 at 8:18am

Originally posted by 808Rider 808Rider wrote:


I'll give it a go, but I tried this by doing the following before

strSQL = "CREATE TABLE test ('Date' datetime)"

This created a field actually named 'Date' and included the single quote.

I think maybe that your suggestion will create a field named [Date] and include the brackets as part of the field name.

no, it won't include the brackets... the brackets are specifically for using (whether creating, selecting against, etc) reserved words as column names, or column names with spaces (for example: SELECT [This Column With Spaces in My Name] FROM ThisTable)

Contribute to the working anarchy we fondly call the Internet
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 29 December 2003 at 8:19am

and btw, its commonly regarded as "bad practice" to use reserved words as column names, why not make it something that makes more sense?

ie/ "StartDate", "SignupDate", "CreationDate", "WhateverDate"

Contribute to the working anarchy we fondly call the Internet
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.