Try another name: ##temptable.
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