SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 linked server querry
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nord
Posting Yak Master

122 Posts

Posted - 06/18/2013 :  09:57:17  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3587 Posts

Posted - 06/18/2013 :  10:09:22  Show Profile  Reply with Quote
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

Edited by - James K on 06/18/2013 10:13:18
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 06/18/2013 :  10:11:33  Show Profile  Reply with Quote
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

Edited by - visakh16 on 06/18/2013 10:12:47
Go to Top of Page

nord
Posting Yak Master

122 Posts

Posted - 06/18/2013 :  10:21:49  Show Profile  Reply with Quote
thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 06/18/2013 :  14:16:55  Show Profile  Reply with Quote
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000