question

PavanMidde-2742 avatar image
0 Votes"
PavanMidde-2742 asked Viorel-1 answered

Usage of SQL Temp Table query in VBScript

Hi All,

I want to create a SQL Temp table and make use of it(Temp Table) in another SQL Query.
Below is the sample script that I have created.

Note: There are many columns in Temptable(#temptable) where i wnat to return only few. Therefore I havent mentioned all the column names here.

So help me to complete the script without any issues


Dim v1,v2,v3,v4,resp,fullres
SET shell = createObject("WScript.Shell")

SET v1= shell.Exec("sqlcmd -E -S server-name -d DBName -Q""Select * into #temptable from ABC where companyid = 100""")

SET v2 = shell.Exec("sqlcmd -E -S server-name -d DBName -Q""Select * from #temptable""")

SET v3 = v2.StdOut

fullres = v2.ReadAll

WScript.Echo""& fullres

office-vba-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered

Try another name: ##temptable.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.