2010-03-25 7 views
0

INSERT INTO [태스크] 가 ([에서 LoginName] [종류] [필터] [사전] [설명])문제점

Select N'Anonymous',4,'SomeTable.targetcode in (select Code from cities where countrycode in ('TN')) and SomeTable.SomeValue in ('13','15')',3,N'Cities from tunis' 
Union All 
... 

[사전] 인 내 서버에서 작동해야하는 쿼리의 일부.

내가 얻을 :

Incorrect syntax near ')) and SomeTable.SomeValue in (13,15)'. 

어떻게 이런 실수를 복구하려면?

답변

4

값 내에 어포 스트로피가 있기 때문입니다. 특히, 필터 문자열은 그들을 배로 탈출 할 필요가 거기에 아포스트로피, 포함

INSERT INTO [Tasks] 
     ([LoginName] 
     ,[Type] 
     ,[Filter] 
     ,[Dictionary] 
     ,[Description]) 

Select N'Anonymous',4,'SomeTable.targetcode in (select Code from cities where countrycode in (''TN'')) and SomeTable.SomeValue in (''13'',''15'')',3,N'Cities from tunis' 
Union All 
1

그것은 당신이하려고하는 정확하게 조금 불분명를 액면가에 당신의 일부를 삽입하려고 where 절을 테이블에 추가하십시오.

당신을 끄는 것은 ('TN')에 있습니다. 그 부분 내의 따옴표가 바깥 쪽 따옴표를 끝내기 때문입니다. 시도해보십시오 (''TN'')