Tuesday, February 14, 2012

constraints on char,varchar

hI,
Is there is a way to find constraints on columns char and
varchar alone..(through query)
Sridhar.Hi
You could try something like:
SELECT object_name(c.id), c.name, t.name, s.*
FROM sysconstraints s JOIN syscolumns c on c.id = s.id and c.colid = s.colid
JOIN systypes t on c.xtype = t.xtype and t.name LIKE '%char%'
John
<anonymous@.discussions.microsoft.com> wrote in message
news:91d001c43330$171e8760$a001280a@.phx.gbl...
> hI,
> Is there is a way to find constraints on columns char and
> varchar alone..(through query)
> Sridhar.|||Thanks John..
Is it possible to find out the indexes on char columns
>--Original Message--
>Hi
>You could try something like:
>SELECT object_name(c.id), c.name, t.name, s.*
>FROM sysconstraints s JOIN syscolumns c on c.id = s.id
and c.colid = s.colid
>JOIN systypes t on c.xtype = t.xtype and t.name LIKE '%
char%'
>John
><anonymous@.discussions.microsoft.com> wrote in message
>news:91d001c43330$171e8760$a001280a@.phx.gbl...
>> hI,
>> Is there is a way to find constraints on columns char
and
>> varchar alone..(through query)
>> Sridhar.
>
>.
>|||> Is it possible to find out the indexes on char columns
I modified John's original script for this requirement:
SELECT object_name(i.id), i.name, c.name, t.name
FROM sysindexes i
JOIN sysindexkeys ik ON ik.id = i.id
JOIN syscolumns c ON c.id = ik.id AND c.colid = ik.colid
JOIN systypes t ON c.xtype = t.xtype AND t.name LIKE '%char%'
ORDER BY object_name(i.id), i.name, c.name
--
Hope this helps.
Dan Guzman
SQL Server MVP
<anonymous@.discussions.microsoft.com> wrote in message
news:8f6401c43345$6601f1e0$a401280a@.phx.gbl...
> Thanks John..
> Is it possible to find out the indexes on char columns
>
> >--Original Message--
> >Hi
> >
> >You could try something like:
> >
> >SELECT object_name(c.id), c.name, t.name, s.*
> >FROM sysconstraints s JOIN syscolumns c on c.id = s.id
> and c.colid = s.colid
> >JOIN systypes t on c.xtype = t.xtype and t.name LIKE '%
> char%'
> >
> >John
> >
> ><anonymous@.discussions.microsoft.com> wrote in message
> >news:91d001c43330$171e8760$a001280a@.phx.gbl...
> >> hI,
> >>
> >> Is there is a way to find constraints on columns char
> and
> >> varchar alone..(through query)
> >>
> >> Sridhar.
> >
> >
> >.
> >

No comments:

Post a Comment