freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Brian Bruns <camber AT ais.org>
- To: TDS Development Group <freetds AT franklin.oit.unc.edu>
- Subject: Re: Implementation of select Limit
- Date: Fri, 9 Nov 2001 07:32:06 -0500 (EST)
Doesn't SQL Server have a limit-type statement? Sybase doesn't but I'm
pretty sure MS added one....back, back, back into the recesses of my mind,
I think its like:
select top 100 * from table
or something like that.
I'll take a look at this this weekend anyway.
Brian
On Fri, 9 Nov 2001, Vitor Pinho wrote:
>
> Hello all,
>
> We are trying to implement a stored procedure which mimics the LIMIT
> clause of the MySql select implementation in SqlServer.
>
>
> When we use only one stored procedure our problems is related with column
> names returned for each row. We cannot get all the results, PHP
> mssql_query dont return any information and mssql_fetch_row also.
>
> Our procedure is this:
>
> ========================================================================
>
> CREATE PROCEDURE sp_limit @sql nvarchar(1000), @min int, @num int AS
>
> SET NOCOUNT ON
>
> DECLARE @sqlcur nvarchar(100)
> DECLARE @i int
>
> SET @sqlcur = 'DECLARE limit_cursor INSENSITIVE SCROLL CURSOR FOR ' +
> @sql
>
> exec(@sqlcur)
> OPEN limit_cursor
>
> -- Fetch the nth row in the cursor.
> FETCH ABSOLUTE @min FROM limit_cursor
>
> SET @i = 1
> WHILE (@i < @num AND @@FETCH_STATUS = 0)
> BEGIN
> -- Fetch the row immediately after the current row in the cursor.
> FETCH NEXT FROM limit_cursor
> SET @i = @i +1
> END
>
> CLOSE limit_cursor
> DEALLOCATE limit_cursor
>
> SET NOCOUNT OFF
> GO
>
> ========================================================================
>
>
> Question 2:
>
> If we try to implement the above stored procedure in different steps in
> PHP, we are able to declare and open cursor. However the FETCH NEXT
> doesnt return any results (we using PHP with mysql_query again).
>
>
> Has anyone done this implementation of LIMIT? Does anyone sees other
> solutions for this problem?
>
> Were using PHP accessing MSSQL server using freetds 0.52.
>
> Best Regards,
> Vpp
>
>
> ---
> You are currently subscribed to freetds as: [camber AT ais.org]
> To unsubscribe, forward this message to $subst('Email.Unsub')
>
-
Implementation of select Limit,
Vitor Pinho, 11/09/2001
- <Possible follow-up(s)>
- Re: Implementation of select Limit, Brian Bruns, 11/09/2001
- Re: Implementation of select Limit, Jez Humble, 11/09/2001
- Re: Implementation of select Limit, Vitor Pinho, 11/09/2001
- Re: Implementation of select Limit, Winkless, Geoff, 11/09/2001
- Re: Implementation of select Limit, Vitor Pinho, 11/09/2001
- Re: Implementation of select Limit, Steve Langasek, 11/09/2001
- Re: Implementation of select Limit, Michael Peppler, 11/09/2001
- Re: Implementation of select Limit, Michael Peppler, 11/09/2001
- Re: Implementation of select Limit, Brian Bruns, 11/09/2001
- Re: Implementation of select Limit, Rui Ribeiro, 11/10/2001
- Re: Implementation of select Limit, Eric Deutsch, 11/13/2001
Archive powered by MHonArc 2.6.24.