Advertisement

02.12.2008 at 11:55AM PST, ID: 23157470
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Query to change the default column value in a table
Tags: Microsoft, Access, 2003, Alter Table Query
I have an Access 2003 Database in which I would like to run a query to change the default values for several columns within a table to NULL. Is it possible to write a query without VBA to do so?

I created a new query went to the SQL view and entered in the following:

ALTER TABLE My_Table ALTER COLUMN My_Column LONG DEFAULT NULL

Access lets me save the query; however, it appears to do nothing when run.

FYI: I already removed the relationships regarding this column.
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: solaris01
Solution Provided By: etsherman
Participating Experts: 3
Solution Grade: A
Views: 250
Translate:
Loading Advertisement...
02.12.2008 at 11:59AM PST, ID: 20878208

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.12.2008 at 12:26PM PST, ID: 20878506

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.12.2008 at 12:35PM PST, ID: 20878635

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.12.2008 at 12:44PM PST, ID: 20878738

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.12.2008 at 01:01PM PST, ID: 20878939

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.12.2008 at 01:18PM PST, ID: 20879129

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.12.2008 at 01:39PM PST, ID: 20879373

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.12.2008 at 01:42PM PST, ID: 20879412

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.12.2008 at 01:54PM PST, ID: 20879546

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
02.12.2008 at 11:59AM PST, ID: 20878208

Rank: Genius

Try running that from the VBA Immediate Window ...

mx
 
02.12.2008 at 12:26PM PST, ID: 20878506

Rank: Master

>> however, it appears to do nothing when run

I guess that statement sets the default value as NULL for all INSERTs performed after running it, not before it.
Do not expect any of the existing values in that column to change to NULL, that won't happen I believe.
After running this query, if u do an INSERT, it will set the default value for this column to NULL and not the one that was defined at table-creation time.
 
02.12.2008 at 12:35PM PST, ID: 20878635
I apologize it did not let me save the query:

ALTER TABLE My_Table ALTER COLUMN My_Column LONG DEFAULT NULL

It did let me save and execute the following query and I saw the expected result:
ALTER TABLE My_Table ALTER COLUMN My_Column LONG

I guess Access does not like the DEFAULT keyword. So I guess I'm looking for the correct SQL syntax to use with Access to set the default value in the ALTER COLUMN statement .
 
02.12.2008 at 12:44PM PST, ID: 20878738

Rank: Master

ALTER TABLE My_Table ALTER COLUMN My_Column LONG would itself take care of the DEFAULT value since none is specified, i guess. Doesn't it?
 
02.12.2008 at 01:01PM PST, ID: 20878939
jinesh_kamdar:

I had previous set it up with a default value of 0 now I need to change it to NULL so I can enforce referential integrity on the column.
 
02.12.2008 at 01:18PM PST, ID: 20879129

Rank: Master

Try this.

ALTER TABLE My_Table ALTER COLUMN My_Column LONG DROP DEFAULT
 
02.12.2008 at 01:39PM PST, ID: 20879373
jinesh_kamdar:

I tried your suggestion in the last post and it didn't work. Your somewhat right though. If I could just drop my current default value of 0 it would default to null; however, the SQL you have provided does not do that.

From the query paine within Access if you were to click "New Query", go into the SQL view, then enter that SQL it will tell you there is a syntax error. This error prevents the query from being saved or executed.

Thanks for your suggestion anyhow and I would be pleased to try anymore you may have.

 
02.12.2008 at 01:42PM PST, ID: 20879412

Rank: Genius

solaris - did you try my post.  That can only be executed in VBA
 
02.12.2008 at 01:54PM PST, ID: 20879546

Rank: Wizard

solaris ....

I ran into this many many moons ago and spent a lot of time trying to accomplish what you are trying to do with the ALTER TABLE statement all in SQL and setting the DEFAULT value of the field ....  "To No Avail on an Access Table".  I should say Access 2k table as that what I was working with at the time.

Here is an easy way to handle that.  Below I am setting the TRACK_POOL field to Bit in the POOL_DATA table and then setting the default to True (-1).  I alter the table first then modify the default value in a separate line of code using the CurrentDb.TableDefs.

    Dim strSQL As String
    strSQL = "ALTER TABLE  POOL_DATA ALTER COLUMN TRACK_POOL YESNO;"
    CurrentDb.Execute strSQL
    CurrentDb.TableDefs("POOL_DATA").Fields("TRACK_POOL").DefaultValue = -1


With all the reasearch I did I never found a way "That Works" to do that in one Alter Table statement on a Access table.  If you do I would like to know.

ET
Accepted Solution
 
 
02.12.2008 at 02:57PM PST, ID: 20880119
Like I said ... you have to run that SQL in code :-)

mx
 
 
02.12.2008 at 02:58PM PST, ID: 20880129
DatabaseMX:

I did try your solution and thank you for your post. It just appears that Access will not accept the following SQL nomatter where it is comming from (Access API or VBA). It complains of a syntax error on the 'DEFAULT' keyword despite the fact that Microsoft's MSDN page show the usage of the exact syntax.

ALTER TABLE table1 ALTER COLUMN column1 INT DEFAULT NULL

Anyhow,
Thanks you and everyone else for your responses.
 
 
02.12.2008 at 03:02PM PST, ID: 20880166
np

MSDN .... not ...... always reliable :-(

mx
 
 
02.12.2008 at 03:20PM PST, ID: 20880312
As I posted ....

Been there & done that!!!!!  I must have wasted a week off and on trying to get that to work ...  To No Avail!!!

ET

What's up today MX????

Quite a Profile you have there.  I noticed you are a very talented musician .....  but ...  you are missing something from the list!!!!

No Zydeco on your list!!!  What's with that???  :-)

I grew up on that in So. Louisiana (Let the good times roll!!!)

ET
 
 
02.12.2008 at 03:29PM PST, ID: 20880362
Zydeco is cool.  In fact, some of my musician colleagues in San Diego have a Zydeco band ... and I sit in occasionally, although I'm not in SD any longer, but I still do treasurer and webmaster for www.blusd.org

mx
 
 
02.12.2008 at 03:37PM PST, ID: 20880402
Thanks and a nice site.  I didn't know San Diego had a presence on the Blues Scene.  I always think of everything on the West Coast as surf boards and the Beach Boys.

I will check it out!!!

ET
 
 
02.12.2008 at 03:41PM PST, ID: 20880423
"San Diego had a presence on the Blues Scene"
Yes ... a common misconception, lol.

International Blues Challenge (IBC)
2006 2nd place in Band category
2007 1st place in Single/Duo category
... as in the World.
Sadly this year, our 2006 2nd place finisher went again this year, but did not make the finals.

mx
 
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628