[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

syntax to determine if constraint exists

John Grandy

3/23/2007 7:52:00 PM

What's the syntax to determine if a constraint exists ?

( I need to write sql to drop a constraint if exists before creating it. )


4 Answers

Tibor Karaszi

3/23/2007 7:55:00 PM

0

What type of constraint and what version of SQL Server?

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/d...
http://sqlblog.com/blogs/tib...


"John Grandy" <johnagrandy-at-gmail-dot-com> wrote in message
news:eHOhpSYbHHA.4808@TK2MSFTNGP04.phx.gbl...
> What's the syntax to determine if a constraint exists ?
>
> ( I need to write sql to drop a constraint if exists before creating it. )
>

John Grandy

3/23/2007 8:12:00 PM

0

Check constraint on Sql Svr 2005.

"Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in
message news:OuYC0UYbHHA.4544@TK2MSFTNGP03.phx.gbl...
> What type of constraint and what version of SQL Server?
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/d...
> http://sqlblog.com/blogs/tib...
>
>
> "John Grandy" <johnagrandy-at-gmail-dot-com> wrote in message
> news:eHOhpSYbHHA.4808@TK2MSFTNGP04.phx.gbl...
>> What's the syntax to determine if a constraint exists ?
>>
>> ( I need to write sql to drop a constraint if exists before creating
>> it. )
>>
>


Alejandro Mesa

3/23/2007 8:46:00 PM

0

John Grandy,

See "sys.check_constraints" catalog view in BOL.


AMB


"John Grandy" wrote:

> Check constraint on Sql Svr 2005.
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in
> message news:OuYC0UYbHHA.4544@TK2MSFTNGP03.phx.gbl...
> > What type of constraint and what version of SQL Server?
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > http://www.karaszi.com/sqlserver/d...
> > http://sqlblog.com/blogs/tib...
> >
> >
> > "John Grandy" <johnagrandy-at-gmail-dot-com> wrote in message
> > news:eHOhpSYbHHA.4808@TK2MSFTNGP04.phx.gbl...
> >> What's the syntax to determine if a constraint exists ?
> >>
> >> ( I need to write sql to drop a constraint if exists before creating
> >> it. )
> >>
> >
>
>
>

Hari

3/24/2007 12:56:00 AM

0

If exists(select 1 from sys.check_constraints where name='constrait_name')

alter table table_name drop constraint constraint_name



Thanks

Hari

"Alejandro Mesa" <AlejandroMesa@discussions.microsoft.com> wrote in message
news:A04BF8B5-335A-4DA2-96CB-2B97F97C873D@microsoft.com...
> John Grandy,
>
> See "sys.check_constraints" catalog view in BOL.
>
>
> AMB
>
>
> "John Grandy" wrote:
>
>> Check constraint on Sql Svr 2005.
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote
>> in
>> message news:OuYC0UYbHHA.4544@TK2MSFTNGP03.phx.gbl...
>> > What type of constraint and what version of SQL Server?
>> >
>> > --
>> > Tibor Karaszi, SQL Server MVP
>> > http://www.karaszi.com/sqlserver/d...
>> > http://sqlblog.com/blogs/tib...
>> >
>> >
>> > "John Grandy" <johnagrandy-at-gmail-dot-com> wrote in message
>> > news:eHOhpSYbHHA.4808@TK2MSFTNGP04.phx.gbl...
>> >> What's the syntax to determine if a constraint exists ?
>> >>
>> >> ( I need to write sql to drop a constraint if exists before creating
>> >> it. )
>> >>
>> >
>>
>>
>>