![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Help with SQL statement I am trying to check for the existance of a server record in our SQL db. My sql statement returns an error of: Microsoft VBScript compilation error: Expected end of statement. My statement is: strSqlQuery = "SELECT item.item_sc, item.item_n,item.item_keya FROM assyst.dbo.item WHERE item.item_sc = ' " & strComputer " ' " There are several more fields I want to return in addition to what's in the current statement, but getting this to work will do for now. I'm assuming it will return a NULL recordset if the server was not entered. TIA, Seymour |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Help with SQL statement > My statement is: Quote: > strSqlQuery = "SELECT item.item_sc, item.item_n,item.item_keya FROM > assyst.dbo.item WHERE item.item_sc = ' " *& strComputer " ' " "SELECT item.item_sc, item.item_n,item.item_keya FROM assyst.dbo.item WHERE item.item_sc = ' " & strComputer & " ' " |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Help with SQL statement "krazymike" <krazymike@xxxxxx> wrote in message news:4dbee183-b17f-48db-89c5-63e82def063d@xxxxxx Quote: > My statement is: > strSqlQuery = "SELECT item.item_sc, item.item_n,item.item_keya FROM > assyst.dbo.item WHERE item.item_sc = ' " & strComputer " ' " "SELECT item.item_sc, item.item_n,item.item_keya FROM assyst.dbo.item WHERE item.item_sc = ' " & strComputer & " ' " ------ Also, I believe the extra spaces around the value of strComputer are a problem. I would use: ====== strSqlQuery = "SELECT item.item_sc, item.item_n, item.item_keya " _ & "FROM assyst.dbo.item " _ & "WHERE item.item_sc = '" & strComputer & "'" ==== Otherwise you have concatenated space characters to the computer name. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Help with SQL statement Thanks to you both. I figured out the concatenation and was coming back here to post that I solved it. You guys are QUICK! Now it appears that I need to do a JOIN as some of the fields I'm looknig for might be in another table. I may be back for more help <g> Seymour On Sep 8, 3:39*pm, "Richard Mueller [MVP]" <rlmueller- nos...@xxxxxx> wrote: Quote: > "krazymike" <krazym...@xxxxxx> wrote in message > > news:4dbee183-b17f-48db-89c5-63e82def063d@xxxxxx > Quote: > > My statement is: > > strSqlQuery = "SELECT item.item_sc, item.item_n,item.item_keya FROM > > assyst.dbo.item WHERE item.item_sc = ' " & strComputer " ' " > You didn't concatenate the last string segment. > "SELECT item.item_sc, item.item_n,item.item_keya FROM > assyst.dbo.item WHERE item.item_sc = ' " *& strComputer & *" ' " > ------ > Also, I believe the extra spaces around the value of strComputer are a > problem. I would use: > ====== > strSqlQuery = "SELECT item.item_sc, item.item_n, item.item_keya " _ > * * & "FROM assyst.dbo.item " _ > * * & "WHERE item.item_sc = '" *& strComputer & "'" > ==== > Otherwise you have concatenated space characters to the computer name. > > -- > Richard Mueller > MVP Directory Services > Hilltop Lab -http://www.rlmueller.net > -- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Is this statement real? I can't buy but maybe U can | General Discussion | |||
| First 400 Records in SQL Statement | VB Script | |||
| More than one condition with the if-Statement | PowerShell | |||
| just a statement | Vista General | |||