DataTable dataTable = DbHelperSQL.RunProcedure("proc_Data_GetUploadInfo", new IDataParameter[] { new SqlParameter("@BillCodes", $"'{string.Join("','", result.Select(x => x.prepare_num.ToString()).ToArray())}'"), }, "get").Tables[0];
解决
经过各种尝试,我使用 exec sp_executesql @sql 这种方式解决的:
1 2 3 4
declare@sql nvarchar(max) set@sql='select * from (select BillCode,BillType,NetWeight,Tare,TareWeightTime,GrossWeight,GrossWeightTime from OrderInfo union select BillCode,BillType,NetWeight,Tare,TareWeightTime,GrossWeight,GrossWeightTime from EndInfo) as u where u.BillCode in('+@BillCodes+')' exec sp_executesql @sql