Web Wiz - Solar Powered Eco Web Hosting

  New Posts New Posts RSS Feed - Delete default
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Delete default

 Post Reply Post Reply
Author
Roberto Randall View Drop Down
Senior Member
Senior Member
Avatar

Joined: 21 August 2009
Location: San Pedro Alc.
Status: Offline
Points: 260
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roberto Randall Quote  Post ReplyReply Direct Link To This Post Topic: Delete default
    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
Back to Top
IanSmithISA View Drop Down
Groupie
Groupie


Joined: 21 October 2010
Location: Worcester
Status: Offline
Points: 127
Post Options Post Options   Thanks (0) Thanks(0)   Quote IanSmithISA Quote  Post ReplyReply Direct Link To This Post 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


Edited by IanSmithISA - 07 February 2013 at 6:16am
Why does anyone need more than an 80x25 character only VDU?
Back to Top
Roberto Randall View Drop Down
Senior Member
Senior Member
Avatar

Joined: 21 August 2009
Location: San Pedro Alc.
Status: Offline
Points: 260
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roberto Randall Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
IanSmithISA View Drop Down
Groupie
Groupie


Joined: 21 October 2010
Location: Worcester
Status: Offline
Points: 127
Post Options Post Options   Thanks (0) Thanks(0)   Quote IanSmithISA Quote  Post ReplyReply Direct Link To This Post 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



Edited by IanSmithISA - 30 January 2013 at 10:22am
Why does anyone need more than an 80x25 character only VDU?
Back to Top
Roberto Randall View Drop Down
Senior Member
Senior Member
Avatar

Joined: 21 August 2009
Location: San Pedro Alc.
Status: Offline
Points: 260
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roberto Randall Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
IanSmithISA View Drop Down
Groupie
Groupie


Joined: 21 October 2010
Location: Worcester
Status: Offline
Points: 127
Post Options Post Options   Thanks (0) Thanks(0)   Quote IanSmithISA Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
IanSmithISA View Drop Down
Groupie
Groupie


Joined: 21 October 2010
Location: Worcester
Status: Offline
Points: 127
Post Options Post Options   Thanks (0) Thanks(0)   Quote IanSmithISA Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
Roberto Randall View Drop Down
Senior Member
Senior Member
Avatar

Joined: 21 August 2009
Location: San Pedro Alc.
Status: Offline
Points: 260
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roberto Randall Quote  Post ReplyReply Direct Link To This Post 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")


Edited by Roberto Randall - 27 January 2013 at 9:44pm
https://www.lanocion.es - https://www.lanocion.games - https://www.lanocion.chat
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.07
Copyright ©2001-2024 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 Policy

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 unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

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