RE: pl/sql question -- Should be T-SQL question

RE: pl/sql question -- Should be T-SQL question

 

  


Hi ,
I Could't Think That There Is Any Need To Assign
That Min. Seletcted Value To Any Variable. U Can Keep
Ur Query Like This


set @sqlstmt = 'select min( '+@colName + ') from
dbo.' + @TblName






--- "Fang, Elaine" <Elaine.[Email Address Removed] wrote:
> That's what happened when you work on Oracle and sql
> simultanously :-)
>
> -----Original Message-----
> From: Fang, Elaine
> Sent: Monday, September 08, 2003 3:08 PM
> To: LazyDBA.com Discussion
> Subject: pl/sql question
>
>
> Hi list,
>
> I'm trying to write a sproc and part of it will need
> to return the min value of a column to a variable.
> So it's something like
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> create procedure sproc_name (@tbl_name varchar(100),
> @colName varchar(100))
> as
>
> declare
> @MinValue datetime, -- all input columns are
> datetime column
> @sqlstmt varchar(2000)
>
> set @sqlstmt = 'select @minValue = min( '+@colName +
> ') from dbo.' + @TblName
>
> exec (@sqlstmt)
>
> .....
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> However, when I tried to run it, it kept complaining
>
> ' need to declare @minValue '
>
> Which I think is coming from the 'set @sqlstmt'
> statement.
>
> So how do I assign the minimum value of an input
> column to a variable?
>
> Thanks a lot,
>
> Elaine
>
>
>
>
>
>
>
>
---------------------------------------------------------------------
> TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT
> JUST REPLY
> To unsubscribe, e-mail:
> mssqldba-[Email Address Removed] For additional commands, e-mail:
> mssqldba-[Email Address Removed]
>
>
>
>
---------------------------------------------------------------------
> TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT
> JUST REPLY
> To unsubscribe, e-mail:
> mssqldba-[Email Address Removed] For additional commands, e-mail:
> mssqldba-[Email Address Removed]


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
MS Sql Server LazyDBA home page