How do I find the name of a check constraint given a Table Name and a Column
Name?
I need this to work on SQL 7 and 2000.
Thanks!
Jim
I need this to work on SQL 7 and 2000.
Thanks!
Jim
use info views...
select *
from information_schema.table_constraints
where table_name='tb'
--
-oj
Rac v2.0 is coming...
http://rac4sql.home.attbi.com
> I need this to work on SQL 7 and 2000.
> Thanks!
> Jim
Thanks for the quick response. The constraint I am looking for is a
column constraint
not a table constraint.
It is not listed in information_schema.table_constraints.
I considered information_schema.check_constraints but
unfortunately the Table Name and Column Name is not also
listed in information_schema.check_constraints.
Do you have any other suggestion?
Thanks!
Jim
> use info views...
> select *
> from information_schema.table_constraints
> where table_name='tb'
> --
> -oj
> Rac v2.0 is coming...
> http://rac4sql.home.attbi.com
> > How do I find the name of a check constraint given a Table Name and a
> Column
> > Name?
> > I need this to work on SQL 7 and 2000.
> > Thanks!
> > Jim
table_constraints contains all constraints in the db...
select *
from information_schema.table_constraints
where constraint_type='check'
will give you the same list as check_constraints.
--
-oj
Rac v2.0 is coming...
http://rac4sql.home.attbi.com
> Thanks for the quick response. The constraint I am looking for is a
> column constraint
> not a table constraint.
> It is not listed in information_schema.table_constraints.
> I considered information_schema.check_constraints but
> unfortunately the Table Name and Column Name is not also
> listed in information_schema.check_constraints.
> Do you have any other suggestion?
> Thanks!
> Jim
> > jim,
> > use info views...
> > select *
> > from information_schema.table_constraints
> > where table_name='tb'
> > --
> > -oj
> > Rac v2.0 is coming...
> > http://rac4sql.home.attbi.com
> > > How do I find the name of a check constraint given a Table Name and a
> > Column
> > > Name?
> > > I need this to work on SQL 7 and 2000.
> > > Thanks!
> > > Jim
Sorry, my mistake.Quote:> table_constraints contains all constraints in the db...
All I need now to solve this is to get the constraint, table,
and column in one view... It's just the column name that's
missing.
Thanks so much,
Jim
The solution is not so pretty but it works for me
CREATE PROCEDURE sp_KillCheckConstraint
AS
BEGIN
(SELECT C.CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS C
LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS T
ON C.CONSTRAINT_NAME = T.CONSTRAINT_NAME
WHERE T.CONSTRAINT_TYPE='CHECK'
END
-Jim
CREATE PROCEDURE sp_KillCheckConstraint
AS
BEGIN
(SELECT C.CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS C
LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS T
ON C.CONSTRAINT_NAME = T.CONSTRAINT_NAME
WHERE T.CONSTRAINT_TYPE='CHECK'
END
1. Change table check constraint to column check constraint?
After our SQL 6.5 database was wiz'd into SQL 7.0 format, I noticed that many
(but not all) of the column check constraints were converted to table check
constraints. These really are simple data-entry checks, and logically belong
with the column.
Is there a way to convert them back to column check constraints without
having to recreate the table? I can't find any syntax in ALTER TABLE to add
a column check constraint.
Why do I care? It's either change the ERWin schema or fix the database, and
frankly, I think ERWin is right this time.
TIA
--
Bobb Head
Sent via Deja.com http://www.deja.com/
Before you buy.
2. FREE PAGERS! LOOK HERE! NO STRINGS!
3. Column check constraint vs table check constraint
4. New Bug! Access 95/VB5/DAO3.5 Date Incrementing bad rounding
5. Table level column reference problem in Check constraint
6. What's causing query to fire?
7. Problem with Alter Table Constraint NO CHECK/CHECK?
8. NY -Colton-ORACLE MANIA- TB
9. Table constraints vs column constraints
10. Table constraints and Column constraints
11. Changing a table-level constraint to a column-specific constraint
12. Could not find CHECK constraint??
13. NOT NULL restriction and CHECK constraint on same column in 7.3.4