'select @minValue
should be
'select @MinValue
> -----Original Message-----
> From: Fang, Elaine [SMTP:Elaine.[Email Address Removed] Sent: Monday, September 08, 2003 9: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]MS Sql Server LazyDBA home page