Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matching values but do not get expected result

Status
Not open for further replies.

ton12

Programmer
Mar 9, 2005
58
GB
The code below is an extract of ActivexScript within DTS where the values match but does not return the expected result.

------------------------------------------------------------
SqlCommand3 = "Select 'countRec'= count(*) from Tab1 where SysKey = "&" ' " & SystemKeyVal &" ' "

set Flds3 = myRecordset3.Fields
myRecordset3.Open SqlCommand3, myConn3
SET iCountREC = Flds3("countRec")

------------------------------------------------------------

It is translated as follows :
Select 'countRec' = count (*) from Tab1 where Syskey = 'NNAA'

iCountREC returns 0 records.

However, when I run the same code with Query Analyzer, I do get the expected result which is 1.

Anyhelp would be greatly appreciated.
Thanks
Ton.
 
My best guess is that the where clause may not be formed correctly.
 
Try removing the spaces after the ' values:

EX:
Code:
SqlCommand3 = "Select 'countRec'= count(*) from Tab1 where SysKey = "&" '" & SystemKeyVal & "' "
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top