Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 26th, 2003, 04:20 AM
Authorized User
 
Join Date: Jun 2003
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default Alter Default on a Column

Does anyone know if it is possible, via the ordinary ALTER TABLE, to change an existing DEFAULT on a varchar column? I know that it is possible through EM, but I need to do it in a script. I've tried the syntax from BOL, but keeps getting SYNTAX ERROR.

Could someone please help me with an example?

Thank you in advance.

Gert
 
Old November 26th, 2003, 09:40 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Can you post your syntax ?

 
Old November 26th, 2003, 10:39 AM
Authorized User
 
Join Date: Jun 2003
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply, but I found it out my self.

Code:
ALTER TABLE Anlegg DROP CONSTRAINT DF_Anlegg_Landkode 

ALTER TABLE Anlegg ADD CONSTRAINT DF_Anlegg_Landkode DEFAULT 'FR' FOR landkode
 
Old November 28th, 2003, 03:56 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

your sentax is right and i executed it..
Try this code as another way to do default

CREATE DEFAULT DF_Anlegg_Landkode AS 'FR'

sp_bindefault DF_Anlegg_Landkode , 'tablename.landkode'

plz inform me with the result

Ahmed Ali
Software Developer
 
Old November 28th, 2003, 08:58 AM
Authorized User
 
Join Date: Jun 2003
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I know the syntax is right. It works fine now with me (I wrote that I found it out my selv.. :-)

Thanks anyway for answering.

Gert





Similar Threads
Thread Thread Starter Forum Replies Last Post
alter add puzzle: Invalid column name JL1024 SQL Server 2000 11 June 11th, 2013 04:59 PM
Alter Column SQLScott SQL Server 2005 5 January 5th, 2007 11:53 AM
Alter a column as identity for table kasanar SQL Server 2000 5 July 6th, 2005 08:44 AM
Alter Column - Default Value sasidhar79 SQL Server 2000 2 January 18th, 2005 07:30 AM
Alter Table - Add Column liz@trinityholdings.co.za Access 2 July 29th, 2003 03:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.