Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parameter reference (calling Sergey)
Message
De
05/08/2004 07:19:52
Rene Lovino
Bigfoot Global Solutions, Inc
Cebu, Philippines
 
 
À
05/08/2004 06:30:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00930922
Message ID:
00930931
Vues:
23
Derek,

try the code below:

CREATE Procedure ApplicationUserSelect1 @lnParam1 int, @lcTableName varchar(250)
AS
begin
declare @lcsqlstmt varchar(500)

select @lcsqlstmt = "select a.* from " + @lcTableName + " a where a.User_ID = " + ltrim(str(@lnParam1, 10, 0))
execute(@lcsqlstmt)
end

Note I have change the paramter @lcTableName to use varchar(250) instead of char. Note that char only accept 1 character.

Hope this help.




I need to be able to dynamically reference a table name within an SQL stored procedure. For example:

CREATE Procedure ApplicationUserSelect1 @lnParam1 int, @lcTableName char
AS
set @lcTableName = 'V1System.dbo.ApplicationUser'
select a.* from #lcTableName a where a.User_ID = @lnParam1
GO

Firstly, I know this code doesn't work, this is purely for an example.

I'd like to be able to pass the Database.Table name into the procedure, as per the variable lcTableName, so that I can change the database location of the table from VFP (by simply passing it in to the SQL procedure).

Any ideas?

Regards

Derek
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform