Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To Do This Query
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01172321
Message ID:
01172324
Vues:
15
>I want to create a proc that pulls either a single record based in the RecId or all
>records if no Id was passed in.
>
>What am I doing wrong here?
>
>
>CREATE PROCEDURE syGetUser
>	@RecId integer = NULL
>
>AS
>
>	SELECT RecId,
>	       GroupId,
>	       FullName
>	       UserName,
>	       Password
>	  FROM appUsers
>	  WHERE (RecId = @RecId) OR ISNULL(@RecId)
>
>
>



Change the place of the conditions:
(Also ISNULL() function is not the same as in VFP. it is like NVL() VFP function)
CREATE PROCEDURE syGetUser
	@RecId integer = NULL

AS
  SELECT RecId,
	GroupId,
	FullName
	UserName,
	Password
  FROM appUsers
  WHERE (@RecId IS NULL OR RecId = @RecId)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform