Print Page | Close Window

Create table using script in ASP page

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=8390
Printed Date: 29 March 2026 at 2:47am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Create table using script in ASP page
Posted By: 808Rider
Subject: Create table using script in ASP page
Date 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?



-------------
PodcastPUP: http://podcastpup.com - http://podcastpup.com
808Talk: http://808Talk.com - http://808Talk.com
808TTV: http://808Talk.tv - http://808Talk.tv



Replies:
Posted By: adnan248999
Date 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)"



-------------
They call me Bruce Lee


Posted By: 808Rider
Date 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.



-------------
PodcastPUP: http://podcastpup.com - http://podcastpup.com
808Talk: http://808Talk.com - http://808Talk.com
808TTV: http://808Talk.tv - http://808Talk.tv


Posted By: MorningZ
Date 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


Posted By: MorningZ
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net