Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 24th, 2004, 05:00 AM
mats mats is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: sweden
Posts: 10 mats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question storesprocedure variables

Hi!

I have a storedprocedure question.

Can a use a parameter as a SQL-Command.
I tried something like this with out success.

Code:
@sortorder = 'DESC'
 SELECT * FROM tblUsers ORDER BY usrName @sortorder 


thank you in advance
regards
/mats

Reply With Quote
  #2  
Old March 24th, 2004, 06:27 AM
Kris_Vanherck's Avatar
Kris_Vanherck Kris_Vanherck is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Belgium, Antwerp
Posts: 177 Kris_Vanherck User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 sec
Reputation Power: 5
Post

it my be better to use if statements instead
i'll give you a small example from my current db

PHP Code:
 CREATE PROCEDURE dbo.sp_Children
 
@Type_ID bigint
AS
DECLARE @
Niveau bigint
SET 
@Niveau = (SELECT niveau FROM Type WHERE Type_ID = @Type_ID)
IF @
Niveau 1
 
(SELECT FROM Type WHERE Niveau 2)
ELSE IF @
Niveau 
 
(SELECT FROM Type WHERE (Niveau 3) OR (Niveau 4))
ELSE IF @
Niveau 3
 
(SELECT FROM Type WHERE (Type_ID = @Type_ID) OR (Niveau 4))
ELSE IF @
Niveau 4
 
(SELECT FROM Type WHERE (Type_ID = @Type_ID) OR (Niveau AND Parent_ID = @Type_ID)) 


Reply With Quote
  #3  
Old March 24th, 2004, 07:13 AM
mats mats is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: sweden
Posts: 10 mats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
OK! IŽll try that.

thanks
/mats

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > storesprocedure variables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT