Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Run sql server stored procedure from VFP
Message
De
13/09/2017 19:30:04
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Run sql server stored procedure from VFP
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows Server 2012 R2
Database:
MS SQL Server
Divers
Thread ID:
01654272
Message ID:
01654272
Vues:
93
Hello comunity,

I need some help to run from my VFP desktop application my sql server 2016 Stored procedure.
here is my code
		TEXT to msel textmerge noshow pretext 7
			--Sample Execution
			EXECUTE [ExportToExcelData] 'maisritmo21',
			'SELECT
			ft.no[Entidade], ft.nome[Nome Utente],f.telefone [Contacto], ft.etotal [Valor 1], Rtrim(f.refmb1)+SPACE(1)+RTRIM(f.refmb2)+SPACE(1)+RTRIM(f.refmb3) [Ref. MB 1],
			(CASE WHEN SUBSTRING(area,1,1 ) = ''C'' THEN ''C''+ substring(CAST(ft.ftano AS VARCHAR),3,2)
			WHEN SUBSTRING(area,1,1 ) = ''H'' THEN ''H''+ substring(CAST(ft.ftano AS VARCHAR),3,2)
			WHEN SUBSTRING(area,1,1 ) = ''G'' THEN ''G''+ substring(CAST(ft.ftano AS VARCHAR),3,2)
			WHEN SUBSTRING(area,1,1 ) = ''A'' THEN ''A''+ substring(CAST(ft.ftano AS VARCHAR),3,2)
			ELSE '''' END) [Amostra]
			FROM ft (nolock)
			LEFT JOIN (SELECT no , tlmvl FROM cl ) c ON c.no = ft.no
			CROSS JOIN ft2 f
			WHERE  f.ft2stamp = ft.ftstamp
			and ft.ftstamp in (<<lcFtstamp>>) ',
			'C:\lixo\IMP2.xls'
		ENDTEXT

		U_SQLEXEC(msel)
the result inside TEXT TO is:
EXEC maisritmo21..[ExportToExcelData] 'maisritmo21',
'SELECT
ft.no[Entidade], ft.nome[Nome Utente],f.telefone [Contacto], ft.etotal [Valor 1], Rtrim(f.refmb1)+SPACE(1)+RTRIM(f.refmb2)+SPACE(1)+RTRIM(f.refmb3) [Ref. MB 1],
(CASE WHEN SUBSTRING(area,1,1 ) = ''C'' THEN ''C''+ substring(CAST(ft.ftano AS VARCHAR),3,2)
WHEN SUBSTRING(area,1,1 ) = ''H'' THEN ''H''+ substring(CAST(ft.ftano AS VARCHAR),3,2)
WHEN SUBSTRING(area,1,1 ) = ''G'' THEN ''G''+ substring(CAST(ft.ftano AS VARCHAR),3,2)
WHEN SUBSTRING(area,1,1 ) = ''A'' THEN ''A''+ substring(CAST(ft.ftano AS VARCHAR),3,2)
ELSE '''' END) [Amostra]
FROM ft (nolock)
LEFT JOIN (SELECT no , tlmvl FROM cl ) c ON c.no = ft.no
CROSS JOIN ft2 f
WHERE  f.ft2stamp = ft.ftstamp
and ft.ftstamp in (''ADM17091248603,063611992'') ',
'C:\lixo\IMP2.xls'
Curiously if i run the result on SSMS the file was create with data on them, but from VFP the file was created without data.

Someone could help me please.

Many Thanks,
Best regards,
Luis Santos
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform