0
而不是鍵入'NXT_US.dbo。'一遍又一遍,我還能怎麼做?SQL將數據庫添加到所有表引用
SELECT DISTINCT
NXT_US.dbo.icsp.prod, NXT_US.dbo.icsp.descrip##1, NXT_US.dbo.icsp.descrip##2, NXT_US.dbo.icsw.whse, NXT_US.dbo.sastn.descrip AS branch, NXT_US.dbo.icsw.qtyonhand, NXT_US.dbo.icsp.unitstock AS UOM, NXT_US.dbo.apsv.vendno AS VendorNumber,
NXT_US.dbo.apsv.name AS VendorName, NXT_US.dbo.icsp.prodcat, NXT_US.dbo.sasta.descrip, NXT_US.dbo.icsw.prodline, NXT_US.dbo.icsw.statustype, NXT_US.dbo.icsw.lastinvdt, NXT_US.dbo.oeel.invoicedt, NXT_US.dbo.icsw.avgcost, NXT_US.dbo.oeel.vendno,
NXT_US.dbo.icsw.avgcost * NXT_US.dbo.icsw.qtyonhand AS ExtCost, NXT_US.dbo.oeel.prodcost, NXT_US.dbo.oeel.orderno
INTO InventoryView
FROM NXT_US.dbo.sasta INNER JOIN
NXT_US.dbo.icsp ON NXT_US.dbo.sasta.codeval = NXT_US.dbo.icsp.prodcat LEFT OUTER JOIN
NXT_US.dbo.icswu ON NXT_US.dbo.icsp.prod = NXT_US.dbo.icswu.prod LEFT OUTER JOIN
NXT_US.dbo.icsw LEFT OUTER JOIN
NXT_US.dbo.oeel ON NXT_US.dbo.icsw.lastinvdt = NXT_US.dbo.oeel.invoicedt AND NXT_US.dbo.icsw.whse = NXT_US.dbo.oeel.whse AND NXT_US.dbo.icsw.prod = NXT_US.dbo.oeel.shipprod RIGHT OUTER JOIN
NXT_US.dbo.sastn RIGHT OUTER JOIN
NXT_US.dbo.icsd ON NXT_US.dbo.sastn.cono = NXT_US.dbo.icsd.cono AND NXT_US.dbo.sastn.codeval = NXT_US.dbo.icsd.divno ON NXT_US.dbo.icsw.whse = NXT_US.dbo.icsd.whse ON NXT_US.dbo.icsp.prod = NXT_US.dbo.icsw.prod LEFT OUTER JOIN
NXT_US.dbo.apsv ON NXT_US.dbo.icsw.arpvendno = NXT_US.dbo.apsv.vendno
WHERE (NXT_US.dbo.sasta.cono = '1') AND (NXT_US.dbo.sasta.codeiden = 'c') AND (NXT_US.dbo.icsw.statustype = 's') AND (NXT_US.dbo.icsp.cono = '1') AND (NXT_US.dbo.sastn.codeiden = 'V') and NXT_US.dbo.icsw.whse = 'G010'
一旦表被引用,那麼你可以通過表名引用它。此外,您可能需要閱讀[別名](http://technet.microsoft.com/en-us/library/ms187455(v = SQL.105).aspx)。 –
所以NXT_US是數據庫,dbo是模式。如果所有表都在相同的數據庫和相同的模式中,那麼您希望將此DB和模式作爲前綴添加到所有表名的原因是什麼?使用完全合格的對象名稱是一種很好的做法,但如果只是您公司的開發實踐,則必須這樣做。 –