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
>.
>if you are looking for anything that has "order by " and a digit why not
take it out of the loop and try
c.text like '%order by [0-9]%'
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"" <anonymous@.discussions.microsoft.com> wrote in message
news:14fc301c41585$6bb3b6b0$a401280a@.phx
.gbl...
> 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
>
>
> command "..from
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment