Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 linked server querry

Author  Topic 

nord
Posting Yak Master

126 Posts

Posted - 2013-06-18 : 09:57:17
Hi,
I need write querry(view) with 3 table one server and one table with another table,what I do not right?
Thanks
SELECT
dbo.TS_ITEM.ITEM_CATEGORY1
,dbo.TS_ITEM.ITEM_CATEGORY2
,dbo.TS_ITEM.ITEM_CATEGORY4
,dbo.TS_ITEM.ITEM_CATEGORY3
,dbo.TS_ITEM.ITEM_CATEGORY5
,dbo.TS_ITEM.ITEM_CATEGORY6
,dbo.TS_ITEM.ITEM_CATEGORY8
,dbo.FS_RECEIPT_DETAIL.COMPANY
,dbo.FS_RECEIPT_DETAIL.ITEM
,dbo.FS_RECEIPT_DETAIL.ITEM_DESC
,dbo.FS_RECEIPT_DETAIL.TOTAL_QTY
,dbo.TS_ITEM.ITEM_CATEGORY9
,dbo.TS_ITEM.ITEM_CATEGORY7
,dbo.TS_ITEM.USER_DEF1
,dbo.TS_ITEM.USER_DEF2
,dbo.TS_ITEM.USER_DEF3
,dbo.TS_ITEM.USER_DEF4
,dbo.TS_ITEM.USER_DEF5
,dbo.TS_ITEM.USER_DEF6
,dbo.TS_ITEM.USER_DEF7
,dbo.TS_ITEM.USER_DEF8
,dbo.FS_RECEIPT_DETAIL.ITEM_LIST_PRICE
,dbo.FS_RECEIPT_DETAIL.ITEM_NET_PRICE
,dbo.FS_RECEIPT_HEADER._ID
,dbo.TS_ITEM._ID AS Expr1
,dbo.shipment_detail.USER_DEF2FROM
dbo.FS_RECEIPT_DETAIL
INNER JOIN dbo.TS_ITEM ON dbo.FS_RECEIPT_DETAIL.COMPANY = dbo.TS_ITEM.COMPANY
INNER JOIN dbo.FS_RECEIPT_HEADER ON dbo.FS_RECEIPT_DETAIL.COMPANY = dbo.FS_RECEIPT_HEADER.COMPANY
INNER JOIN [WMSDB01].[ILS].dbo.[shipment_detail] on FS_RECEIPT_DETAIL.company=shipment_detail.company

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-06-18 : 10:09:22
quote:
Originally posted by nord

Hi,
I need write querry(view) with 3 table one server and one table with another table,what I do not right?
Thanks
SELECT
dbo.TS_ITEM.ITEM_CATEGORY1
,dbo.TS_ITEM.ITEM_CATEGORY2
,dbo.TS_ITEM.ITEM_CATEGORY4
,dbo.TS_ITEM.ITEM_CATEGORY3
,dbo.TS_ITEM.ITEM_CATEGORY5
,dbo.TS_ITEM.ITEM_CATEGORY6
,dbo.TS_ITEM.ITEM_CATEGORY8
,dbo.FS_RECEIPT_DETAIL.COMPANY
,dbo.FS_RECEIPT_DETAIL.ITEM
,dbo.FS_RECEIPT_DETAIL.ITEM_DESC
,dbo.FS_RECEIPT_DETAIL.TOTAL_QTY
,dbo.TS_ITEM.ITEM_CATEGORY9
,dbo.TS_ITEM.ITEM_CATEGORY7
,dbo.TS_ITEM.USER_DEF1
,dbo.TS_ITEM.USER_DEF2
,dbo.TS_ITEM.USER_DEF3
,dbo.TS_ITEM.USER_DEF4
,dbo.TS_ITEM.USER_DEF5
,dbo.TS_ITEM.USER_DEF6
,dbo.TS_ITEM.USER_DEF7
,dbo.TS_ITEM.USER_DEF8
,dbo.FS_RECEIPT_DETAIL.ITEM_LIST_PRICE
,dbo.FS_RECEIPT_DETAIL.ITEM_NET_PRICE
,dbo.FS_RECEIPT_HEADER._ID
,dbo.TS_ITEM._ID AS Expr1
,dbo.shipment_detail.USER_DEF2FROM
dbo.FS_RECEIPT_DETAIL
INNER JOIN dbo.TS_ITEM ON dbo.FS_RECEIPT_DETAIL.COMPANY = dbo.TS_ITEM.COMPANY
INNER JOIN dbo.FS_RECEIPT_HEADER ON dbo.FS_RECEIPT_DETAIL.COMPANY = dbo.FS_RECEIPT_HEADER.COMPANY
INNER JOIN [WMSDB01].[ILS].dbo.[shipment_detail] on FS_RECEIPT_DETAIL.company=shipment_detail.company

Seems like a missing space; also either alias, or use fully qualified name
SELECT 
ti.ITEM_CATEGORY1
,ti.ITEM_CATEGORY2
,ti.ITEM_CATEGORY4
,ti.ITEM_CATEGORY3
,ti.ITEM_CATEGORY5
,ti.ITEM_CATEGORY6
,ti.ITEM_CATEGORY8
,fd.COMPANY
,fd.ITEM
,fd.ITEM_DESC
,fd.TOTAL_QTY
,ti.ITEM_CATEGORY9
,ti.ITEM_CATEGORY7
,ti.USER_DEF1
,ti.USER_DEF2
,ti.USER_DEF3
,ti.USER_DEF4
,ti.USER_DEF5
,ti.USER_DEF6
,ti.USER_DEF7
,ti.USER_DEF8
,fd.ITEM_LIST_PRICE
,fd.ITEM_NET_PRICE
,fh._ID
,ti._ID AS Expr1
,sd.USER_DEF2
FROM
dbo.FS_RECEIPT_DETAIL fd
INNER JOIN dbo.TS_ITEM ti ON fd.COMPANY = ti.COMPANY
INNER JOIN dbo.FS_RECEIPT_HEADER fh ON fd.COMPANY = fh.COMPANY
INNER JOIN [WMSDB01].[ILS].dbo.[shipment_detail] sd on fd.company=sd.company
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-18 : 10:11:33
learn to use short aliases


SELECT
ti.ITEM_CATEGORY1
,ti.ITEM_CATEGORY2
,ti.ITEM_CATEGORY4
,ti.ITEM_CATEGORY3
,ti.ITEM_CATEGORY5
,ti.ITEM_CATEGORY6
,ti.ITEM_CATEGORY8
,frd.COMPANY
,frd.ITEM
,frd.ITEM_DESC
,frd.TOTAL_QTY
,ti.ITEM_CATEGORY9
,ti.ITEM_CATEGORY7
,ti.USER_DEF1
,ti.USER_DEF2
,ti.USER_DEF3
,ti.USER_DEF4
,ti.USER_DEF5
,ti.USER_DEF6
,ti.USER_DEF7
,ti.USER_DEF8
,frd.ITEM_LIST_PRICE
,frd.ITEM_NET_PRICE
,frh._ID
,ti._ID AS Expr1
,sd.USER_DEF2
FROM
dbo.FS_RECEIPT_DETAIL frd
INNER JOIN dbo.TS_ITEM ti ON frd.COMPANY = ti.COMPANY
INNER JOIN dbo.FS_RECEIPT_HEADER frh ON frd.COMPANY = frh.COMPANY
INNER JOIN [WMSDB01].[ILS].dbo.[shipment_detail] sd on frd.company=sd.company


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

nord
Posting Yak Master

126 Posts

Posted - 2013-06-18 : 10:21:49
thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-18 : 14:16:55
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -