Re: Custom sort records in a stored proc

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: avnrao (avn_at_newsgroups.com)
Date: 02/24/05


Date: Thu, 24 Feb 2005 18:17:13 +0530

There are different ways you can implement this.

1. like switch statement : based on parameter, you execute the respective
select statement.
2. pass tablename, columnnames as parameters - and execute them using
dynamic sql.
3. create another table that holds information like tablename, columns to be
returned and a key. when the key is passed in dynamicaly prepare the select
statemetn to returns columns of tht table.
there could be other ways too..but you have to consider the flexibility,
maintainability and in somecases performance also..

hth,

-- 
Av.
http://dotnetjunkies.com/WebLog/avnrao
http://www28.brinkster.com/avdotnet
"hals_left" <cc900630@ntu.ac.uk> wrote in message
news:c04136bd.0502240438.305a294@posting.google.com...
> I have several stored procs that return two columns of data -  primary
> key values and another column, eg. Categories, Regions. Used to
> populate select lists in HTML.
>
> Is there a way to pass a parameter to the proc that represents a
> specific primary key value and have the corresponsding record appear
> first in the result set? and also have it igonre the parameter if its
> -1.
>
> Thanks
> hals_left


Relevant Pages

  • Re: Custom sort records in a stored proc
    ... based on parameter, you execute the respective> select statement. ... pass tablename, columnnames as parameters - and execute them using> dynamic sql. ... >> Is there a way to pass a parameter to the proc that represents a>> specific primary key value and have the corresponsding record appear>> first in the result set? ...
    (microsoft.public.sqlserver.programming)
  • Re: Get Number of Rows in Table
    ... will not take much time if you have primary key in table and if table is not ... locked at the moment you execute this query. ... http://www.oledbdirect.com - The fastest way to access MS SQL Server, ... I've also read that you could run select countfrom TableName, ...
    (borland.public.delphi.database.ado)
  • Re: SQL 2000 Windows Authentication - Same User Multiple Groups
    ... App1 contains CRUD functionality using stored procs (EXEC perms on ... UpdateResearch stored procs. ... execute UpdateResearch. ... view-level permissions such that we can permit/deny a database action ...
    (microsoft.public.sqlserver.security)
  • Re: SQL 2000 Windows Authentication - Same User Multiple Groups
    ... App1 contains CRUD functionality using stored procs (EXEC perms on ... Resarch group (of which he is also a member), ... execute UpdateResearch. ... view-level permissions such that we can permit/deny a database ...
    (microsoft.public.sqlserver.security)
  • Re: Question about how to differentiate between user functions and stored procedures when using OLE
    ... > able to tell the differnce between stored procs and user functions through ... > connects to various databases, excel, access, sqlsvr, etc.via OLE DB. ... > trying to add functionality to this application to be able to execute ... > procedures and User functions(for SQL SVR at least). ...
    (microsoft.public.sqlserver.programming)