Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Variable Scope
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Titre:
Divers
Thread ID:
00663609
Message ID:
00663643
Vues:
21
Try
SET @sql_string = REPLACE(@sql_string, '@@idoc', CAST(@idoc AS varchar(10)))
EXEC (@sql_string)
BTW, why it's @@idoc in the @sql_string?


>>You can run select like this w/o EXEC
select * from tablename where ckeyfieldname = @cwhere
>
>I need the variable - this is not exactly what I am trying to do, just an example. Is there no way have the variable scoped?
>
>
>Here is exactly what I am doing...
>Stored Procedure
>
>CREATE procedure dbo.getdata_wayne
>@doc as ntext, @sql_string as ntext
>
>AS
>
>declare @idoc int
>	-- Parse XML String	
>	EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
>	-- Get Data
>	EXEC (@sql_string)
>	-- Select data
>	-- Remove XML document		
>	EXEC sp_xml_removedocument @idoc
>GO
>
>
>Call to the sp
>
>
>exec getdata_wayne '<A><B>99WCAL138462</B></A>',
>'SELECT PREMIUMHEADER.CPOLICYNUM FROM OPENXML (@@idoc, "/A/B",2)
> WITH (I varchar(16)) AS JT  ,
>PREMIUMHEADER WHERE PREMIUMHEADER.CPOLICYNUM = JT.I'
>
>
>The sql_string is created dynamically in VFP. I do not have the @idoc for the OPENXML call.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform