SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 27th, 2004, 10:15 AM
ccstarr ccstarr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 22 ccstarr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy RENAME TABLE, Change Field type varchar(50) to varchar(100)

Thank you in advance, I am having trouble with renaming tables. I've tried every syntax I can get my hands on. Here is the code, is the statement wrong?

if form_in_new_name <> 0 then
sSQL = "ALTER TABLE " & form_in_name & "_table RENAME TO " & form_in_new_name & "_table ;"
Set rs2 = cn.Execute(sSQL)
Set rs2 = Nothing
end if

My second question is, is there a way through an SQL statement to change a field type, either from one type to another, or simply the size such as, varchar(50) to varchar(100). If so what would the statement(s) be?

Muchas Gracias!!!!!!!!

Reply With Quote
  #2  
Old February 27th, 2004, 10:22 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
To rename that table try this
Code:
sql = "ALERT TABLE '" & form_in_name & "'_table RENAME TO '" & form_in_new_name & "'_table"

To change the datatype try this
Code:
sql = "ALTER TABLE <tableName> ALTER COLUMN <columnName> SET DATA TYPE VARCHAR(100)"

Reply With Quote
  #3  
Old February 27th, 2004, 10:31 AM
ccstarr ccstarr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 22 ccstarr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Microsoft OLE DB Provider for SQL Server error '80040e14'

Incorrect syntax near the keyword 'TO'.

/edit_category.asp, line 38

When I don't tell it to run the line, I can output the statement. This is exactly what statement is giving the error:

ALTER TABLE Computer_Displays_table RENAME TO Computer_Display_table ;

Reply With Quote
  #4  
Old February 27th, 2004, 10:33 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
try modifying it to this
Code:
sql = "ALERT TABLE ['" & form_in_name & "'_table] RENAME TO ['" & form_in_new_name & "'_table]"

Reply With Quote
  #5  
Old February 27th, 2004, 10:37 AM
ccstarr ccstarr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 22 ccstarr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ALTER TABLE [Computer_Displays_table] RENAME TO [Computer_Display_table] ;


Microsoft OLE DB Provider for SQL Server error '80040e14'

Incorrect syntax near the keyword 'TO'.

/edit_category.asp, line 38

Reply With Quote
  #6  
Old February 27th, 2004, 11:41 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
okay, try this
Code:
sql = "ALERT TABLE [" & form_in_name & "_table] RENAME TO [" & form_in_new_name & "_table]"


Reply With Quote
  #7  
Old March 1st, 2004, 09:26 AM
ccstarr ccstarr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 22 ccstarr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have actually been trying without the single quotes.. the single quotes throws an error beyond the one i was already getting. I knew the single quotes was wrong to begin with and thus have been ignoring them... hence this last suggestion I have already tried and get the same error.

-Jason

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > RENAME TABLE, Change Field type varchar(50) to varchar(100)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT