Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-01-23 : 10:18:51
|
A DBA I know named Lance sent me a view and a write-up on it and asked if I'd like to publish it. He posts in the forum under JohnDeere. Lance was fighting with server named default constraints and was using the view to help manage and rename the constraints. Article Link. |
|
JamieKitson
Starting Member
1 Post |
Posted - 2004-01-30 : 08:30:05
|
There's a script for dropping default constraints of unknown names at the bottom of [url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsqlpro2k/html/sql00a11.asp]this[/url] page. |
|
|
Tsabi
Starting Member
1 Post |
Posted - 2005-05-09 : 14:24:23
|
Hi!My problem was that I need to alter some columns, but the alter statement throw an error: Cannot alter column ... its being replicated.I was wondering about that error message bacause there are no replications on my database. I run sp_help on that table then realized that my column has a default value wich creates a default constraint. Because the alter runs in an install kit, i had to have a script what drops the default constraint from that column.I think the MSDN link is very useful, but the script doesn't work, so I made one based on that. Here it is:-- this script drops the default constraint from the given column in the given tableDECLARE @tablename VARCHAR(100),@columnname VARCHAR(100),@tab VARCHAR(100)SET @tablename='TABLE'SET @columnname='COLUMN'declare @defname varchar(100)declare @cmd varchar(100)select @defname = name FROM sysobjects so JOIN sysconstraints scON so.id = sc.constid WHERE object_name(so.parent_obj) = @tablenameAND so.xtype = 'D'AND sc.colid = (SELECT colid FROM syscolumns WHERE id = object_id(@tablename) AND name = @columnname)select @cmd='alter table '+@tablename+ ' drop constraint '+@defnameif @cmd is null print 'No default constraint to drop'exec (@cmd)Jason, thanks for your link, it helped me to write my own code.Go on SQL Team! Regards,Tsabi |
|
|
|
|
|