Help

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: :\) (anonymous_at_discussions.microsoft.com)
Date: 03/29/04


Date: Mon, 29 Mar 2004 04:00:25 -0800

I changed it a bit.. can anyone tell me how i can get rid
of the "number 25" but keep what i am trying to do(cause
some tables have more columns and some have less than 25):

declare @i varchar(10)
set @i = '1'
        
        while @i < 25
        begin
        select distinct o.name from syscomments c join
sysobjects o on o.id = c.id
        where o.type IN ('TR','TF','P','X','V','FN')
        and
        c.text like '%order by ' + @i + '%'
        
        set @i = @i+1
        end
        

>-----Original Message-----
>Can anyone help me,
>I am writting a script where i get to find out all the
>store procedure, triggers,... that has the
command "..from
>table_name order by 2,1.." for example...
>
>Here is what i got as a base idea... hope you understand
>what i am trying to get at:
>declare @i int
>declare @tbnames varchar (150)
>set @i = 1
>
>declare test cursor for
> select [name] from sysobjects where xtype = 'U'
>
>open test
>fetch next from test into @tbnames
>
>if @@fetch_status = 1
>
>Begin
>
> if @i < 9
>
> begin
> select o.name from syscomments c join sysobjects o
>on o.id = c.id
> where o.type IN ('TR','TF','P','X','V','FN')
> and
> c.text like '%from ' + @tbnames + 'order by' + @i
>+ '%'
>
> set @i = @i + 1
> end
>
>
>fetch next from test into @tbnames
>
>End
>
>close test
>deallocate test
>
>Can anyone give me a hand with this please
>.
>