Print Page | Close Window

Delete default

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=30652
Printed Date: 28 March 2026 at 6:54am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Delete default
Posted By: Roberto Randall
Subject: Delete default
Date Posted: 27 January 2013 at 8:01pm
I created a column in my database and I have given a default value.

How I can delete the default value of the column with asp?

Thanks,
 
 
I have another problem:
I have two tables together and both have a column that have the same name (Name), I can show how each?
 
rsCommon.Fields("Name")


-------------
https://www.lanocion.es - https://www.lanocion.games - https://www.lanocion.chat



Replies:
Posted By: IanSmithISA
Date Posted: 28 January 2013 at 6:14am
Good morning

....... have another problem:
I have two tables together and both have a column that have the same name (Name), I can show how each?
 
rsCommon.Fields("Name")

The best way is to change your query to something like

SELECT Table1.Name AS  Table1_Name,  Table2.Name AS  Table2_Name
 FROM .........
 and then use

rsCommon.Fields("Table1_Name") or 
rsCommon.Fields("Table2_Name")

You can fudge it by trying to guess/ experiment with what ADO/DAO etc is doing and you will find that it is expecting 

 rsCommon.Fields("Name") and rsCommon.Fields("table2.Name")
or 
 rsCommon.Fields("table1.Name") and rsCommon.Fields("Name")
or  
rsCommon.Fields("table1.Name") and rsCommon.Fields("table2.Name")

But doing this is just storing up trouble for the future, although the last option appears to be correct as it fully qualifies the column, it won't work!

Bye

Ian


-------------
Why does anyone need more than an 80x25 character only VDU?


Posted By: IanSmithISA
Date Posted: 28 January 2013 at 6:21am
Good morning

How I can delete the default value of the column with asp?

I don't understand what you are trying to do.Smile

You can override the DEFAULT value by specifying a value for the column when you INSERT the row. 

If you don't know the value that you want at that time, then you will need to issue an UPDATE statement specifying the value.

Bye

Ian


-------------
Why does anyone need more than an 80x25 character only VDU?


Posted By: Roberto Randall
Date Posted: 29 January 2013 at 4:30pm

Thank you very much. It has been a great help.

About the other problem I have I can not explain in English. I use a translator "English-Spanish" to read and write.

Try to explain again:

I created a column in a table with asp.
In the column I wrote as default "(3)".
I want to remove the default value with asp.

I have to do it through my server asp because I work with has not enabled to work with programs such as "SQL Server Management Studio". They are looking for ways to enable it.



-------------
https://www.lanocion.es - https://www.lanocion.games - https://www.lanocion.chat


Posted By: IanSmithISA
Date Posted: 30 January 2013 at 8:11am
Good morning,

If I understand you correctly and you have an SQL Server database then this may help

 

You already have your table so this is just an example

CREATE TABLE tf1 (Fred_int32 int DEFAULT 3);

 

You need the name of the constraint for the DEFAULT value, so you will need to run this and display the result. Note the table name in object id

SELECT name,type_desc FROM sys.default_constraints WHERE parent_object_id = object_id('tf1')

 The above may return more than one row depending upon your table design.

Then run this , DF__tf1__fred__7C48823F is the name of the constraint returned from the above command, note that it is not in quotes. 

ALTER TABLE TF1 DROP CONSTRAINT DF__tf1__fred__7C48823F


 If you have an Access or MySQL database it is different.

 Bye

 

Ian



-------------
Why does anyone need more than an 80x25 character only VDU?


Posted By: Roberto Randall
Date Posted: 06 February 2013 at 12:25pm

If. is that what you want to do. I tried, but I think there are fields and not deleted the default. How I can change "(3)" to "(2)"?

Thanks,



-------------
https://www.lanocion.es - https://www.lanocion.games - https://www.lanocion.chat


Posted By: IanSmithISA
Date Posted: 06 February 2013 at 1:44pm
Good afternoon,

I don't think that there is a simple command to alter the default value.

You have to drop the default value as shown earlier and then create a new one.

ALTER TABLE TF1 ADD CONSTRAINT DF_tf1_fred_int32_1 DEFAULT 2 FOR Fred_int32

You can use pretty any name you like for the constraint ( DF_tf1_fred_int32_1)

Note that someone could add a row in the time between the DEFAULT being dropped and recreated.

I get that you had a problem but I don't understand what you mean by ", but I think there are fields and ". Dropping a constraint doesn't drop the field or alter its contents.

Bye

Ian


-------------
Why does anyone need more than an 80x25 character only VDU?


Posted By: Roberto Randall
Date Posted: 09 February 2013 at 6:11pm
Hi,

Now the problem I have is how to change the name of a column in a table created in Web Wiz Newspad or Web Wiz forum


-------------
https://www.lanocion.es - https://www.lanocion.games - https://www.lanocion.chat



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