내가 여기에 약간의 문제가 있습니다 모두 내가 원하는 샘플 코드SQL 매개 변수 숯불 []
create table Sections (ID int, name char(1), Description nvarchar(50))
insert into Sections values (1,'A','A Section')
insert into Sections values (2,'B','B Section')
insert into Sections values (3,'C','C Section')
insert into Sections values (4,'D','D Section')
insert into Sections values (5,'E','E Section')
insert into Sections values (6,'F','F Section')
select * from Sections
declare @Names nvarchar(10) ='A,B,C';
select *from Sections where name in (@Names)
같이 내가 그 문자열을 각 문자에 splited 할 것이다 문자열과 그 문자의 배열을 전달하는 것입니다 where 절에 전달됩니다. 잘 작동하는 숫자로 시도했지만 제대로 작동하지 않는 char. 은 내가 무슨 짓을하는 것은 'A'등이
declare @Categories nvarchar(50)='ABC';
declare @array nvarchar(50);
declare @lenth int =len(@Categories);
Declare @c int =1;
declare @param nvarchar(50)='' ;
while @c <[email protected]
begin
set @param = @param + ''''+ SUBSTRING(@Categories ,@c,1) +''''+','
set @c [email protected]+1
end
print @param
declare @Cats nvarchar(50);
set @Cats= substring(@param, 0,len(@param)-0)
출력, 'B', 'C'와 같다. 하지만이 @ 고양이를 sp에 전달할 때 레코드가 반환되지 않습니다.
또 다른 한가지는이 쿼리를 동적 쿼리로 실행한다는 것이 아닙니다.
[당신은 어느 비트를 쓰셨습니까?] (http://stackoverflow.com/questions/314824/t-sql-opposite-to-string-concatenation-how-to-split-string-into-multiple- recor/2837662 # 2837662) –
귀하의 권리. 주목 해 주셔서 감사합니다. 나의 영어는 나쁘다. 그리고이 본문은 나의 불에 의해 훼손된다. 보통 나는 ** 텍스트를 쓰지 않는다. 왜냐하면 내가 찾은 해결책이 인터넷에 있기 때문이다. – ABI