Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 21st, 2004, 11:21 PM
Authorized User
 
Join Date: Nov 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Wht the procedure is wrong??

The procedure below is wrong,
@i couldn't be used after top?Why?
--================================
create procedure proce
(
@i int
)
as
select top @i * from userinfo

 
Old March 21st, 2004, 11:22 PM
Authorized User
 
Join Date: Nov 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am really comfused!!

 
Old March 22nd, 2004, 04:27 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

AFAIK, this is by design. The TOP clause needs to be a constant to work correctly.

You could try using SET ROWCOUNT, like this:

CREATE PROCEDURE proce

@i int

AS

SET ROWCOUNT @i

SELECT * FROM userinfo

Look in the Books Online for SQL Server and read about the TOP Keyword. That topic also discusses the differences between using TOP and using SET ROWCOUNT


Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 22nd, 2004, 06:26 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If you can hang on for the next version of SQL (2005) you can use expressions in the TOP statement :)

--

Joe
 
Old March 22nd, 2004, 11:02 PM
Authorized User
 
Join Date: Nov 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank u!







Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me!Who can tell me where is wrong? kevinchen2004 C# 2 March 7th, 2005 06:22 AM
Stored Procedure hits wrong index ashettleroe SQL Server 2000 6 June 30th, 2004 05:28 PM
does anyone know wht this code does sand133 VB.NET 2002/2003 Basics 3 June 24th, 2004 11:11 AM
Right or wrong? ÕÅÃÍ C++ Programming 6 February 27th, 2004 02:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.