Добрый день.
Хочу вытащить данные из этого простенького запроса в эксель. Но выдает ошибку. Подскажите,что я делаю не так.
Код |
---|
declare @Movements table (
Material_id int not NULL,
OwnerDebtor_id int not NULL,
MaterialSeries_id int NULL,
StockType_id int not NULL,
StockCategory_id int not NULL,
DiscountCategory_id int NULL,
BaseQuantity decimal(25,6) not NULL ,
TZ int null--ТЗ
);
declare @Result table (
id int identity(1,1) not NULL primary key,
Material_id int not NULL,
OwnerDebtor_id int not NULL,
MaterialSeries_id int NULL,
StockType_id int not NULL,
StockCategory_id int not NULL,
DiscountCategory_id int NULL,
BaseQuantity decimal(25,6) not NULL
,TZ int NULL
);
insert into @Movements (Material_id, OwnerDebtor_id, MaterialSeries_id, StockType_id, StockCategory_id, DiscountCategory_id, BaseQuantity,TZ)
select
a.Material_id, a.OwnerDebtor_id, d.MaterialSeries_id,
a.StockType_id, /*!*/dbo.DefStockCategory()/*!*/, d.DiscountCategory_id, a.Quantity * e.UnitKoeff
,tz.tid --ТЗ
from OperativeInventory as a (nolock)
join Materials as b (nolock) on a.Material_id = b.tid
join BarcodeObjects as d (nolock) on a.BarcodeObject_id = d.tid
join MaterialUnits as e (nolock) on a.MaterialUnit_id = e.tid
left join locations lo on lo.tid=a.Location_id
left join technozones tz on tz.tid=lo.TechnoZone_id
where --a.TrGUID = @GUID
--and a.Location_id not in (109309) --- ----тест,чтобы не грузилось в ERP
a.StorageObject_id not in (12742221,12850123)
;
--Удалить движения по опр.ТЗ
-- delete @Movements
select *
from @Movements
--where Material_id=68742
|
Ошибка Запрос не выполняется или не удается открыть таблицу БД.
Верно я понимаю,что эксель не умеет работать с табличными переменными?
Настраиваю подключение так.
Данные--Из других источников-С сервера SQL.Укзаываю имя сервера,логин и пароль. Далее вставляю текст запроса и пытаюсь выполнить.