Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sippon77
Starting Member
13 Posts |
Posted - 2005-03-14 : 08:23:43
|
| hi,i am having problems with the following query,Declare @vchStates as nvarchar(100)set @vchstates = 'TX,CA,CO'set @vchstates = REPLACE(@vchstates,',',''',''') set @vchstates = '''' + @vchstates + ''''print @vchstatesselect iw.iworknoteid,iw.iincidentid,c.vchCompanyname,i.vchDesc1 'Incident Desc', iw.vchWorknote1 + isNull(iw.vchworknote2,'') + isNull(iw.vchworknote3,'') + isNull(iw.vchworknote4,'') 'Incident WorkNotes', iw.vchenteredBy, i.dtInsertdatefrom incidentworknote iwjoin incident ion iw.iIncidentid = i.iIncidentidand i.iIncidentCategory in (2,3)and iw.vchWorknote1 <> ''join company con i.iownerid = c.iCompanyid andc.ICOMPANYTYPECODE = 101445 andc.chregioncode in (@vchstates)When i execute the above query i get no records as output(there are no error messages!!). The problem is with the @vchstates variable that i am using in the IN clause. If i replace the @vchstates variable with ('TX','CA','CO') then i get output records. It would be helpful if somebody could tell me whats wrong or how to use a string in the IN clause |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-03-14 : 08:31:00
|
http://www.sqlteam.com/item.asp?ItemID=11499Go with the flow & have fun! Else fight the flow |
 |
|
|
|
|
|
|
|