Friday, March 9, 2012

drop constraint?

Hi all,
How does one drop a constraint using an sql statement?
Thanke,
IvanALTER TABLE <TABLENAME>
DROP CONSTRAINT <ConstrintName>
Roji. P. Thomas
Net Asset Management
http://toponewithties.blogspot.com
"Ivan Debono" <ivanmdeb@.hotmail.com> wrote in message
news:u2SHNxHrFHA.3060@.TK2MSFTNGP09.phx.gbl...
> Hi all,
> How does one drop a constraint using an sql statement?
> Thanke,
> Ivan
>|||Ivan
use tempdb
CREATE TABLE #t
(
col DATETIME DEFAULT GETDATE()
)
GO
--sp_helpconstraint '#t'
ALTER TABLE #t DROP constraint DF__#t__col__6FDB4B23
"Ivan Debono" <ivanmdeb@.hotmail.com> wrote in message
news:u2SHNxHrFHA.3060@.TK2MSFTNGP09.phx.gbl...
> Hi all,
> How does one drop a constraint using an sql statement?
> Thanke,
> Ivan
>|||Thanks!
Ivan
"Uri Dimant" <urid@.iscar.co.il> schrieb im Newsbeitrag
news:u1t834HrFHA.2604@.TK2MSFTNGP14.phx.gbl...
> Ivan
> use tempdb
> CREATE TABLE #t
> (
> col DATETIME DEFAULT GETDATE()
> )
> GO
> --sp_helpconstraint '#t'
> ALTER TABLE #t DROP constraint DF__#t__col__6FDB4B23
>
> "Ivan Debono" <ivanmdeb@.hotmail.com> wrote in message
> news:u2SHNxHrFHA.3060@.TK2MSFTNGP09.phx.gbl...
>|||Best to name the constraint (though you probably knew that, just wanted to
make sure Ivan did)
use tempdb
CREATE TABLE #t
(
col DATETIME CONSTRAINT dftl_t_col DEFAULT GETDATE()
)
GO
ALTER TABLE #t DROP constraint dftl_t_col
--
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:u1t834HrFHA.2604@.TK2MSFTNGP14.phx.gbl...
> Ivan
> use tempdb
> CREATE TABLE #t
> (
> col DATETIME DEFAULT GETDATE()
> )
> GO
> --sp_helpconstraint '#t'
> ALTER TABLE #t DROP constraint DF__#t__col__6FDB4B23
>
> "Ivan Debono" <ivanmdeb@.hotmail.com> wrote in message
> news:u2SHNxHrFHA.3060@.TK2MSFTNGP09.phx.gbl...
>

No comments:

Post a Comment