I have this litte SQL string for a MS SQL DB.
"SELECT"
" [Navision4].[dbo].[3S Company A_S$Item].[No_],[Navision4].[dbo].[3S Company A_S$Item].[Description] AS Description,[Navision4].[dbo].[3S Company A_S$Item].[Description 2], [Navision4].[dbo].[3S Company A_S$Item].[Item Status], [Navision4].[dbo].[3S Company A_S$Item].[New Sales Price DK], [Navision4].[dbo].[3S Company A_S$Item].[New List Price DK],[Navision4].[dbo].[3S Company A_S$Item].[New Sales Price No], [Navision4].[dbo].[3S Company A_S$Item].[New List Price No], [Navision4].[dbo].[3S Company A_S$Item].[New Sales Price S], [Navision4].[dbo].[3S Company A_S$Item].[New List Price S],[Navision4].[dbo].[3S Company A_S$Item Cross Reference].[Cross-Reference No_], [Navision4].[dbo].[3S disponibelt for export].[Disponibelt], [Navision4].[dbo].[3S Lagersaldo].[Quantity] AS Lagerantal, [Navision4].[dbo].[3S i_bestilling].[Expected Receipt Date] AS ToDispDate "
"FROM [Navision4].[dbo].[3S Company A_S$Item] "
"LEFT OUTER JOIN [Navision4].[dbo].[3S Company A_S$Item Cross Reference] ON [Navision4].[dbo].[3S Company A_S$Item].[No_] = [Navision4].[dbo].[3S Company A_S$Item Cross Reference].[Item No_] AND [Navision4].[dbo].[3S Company A_S$Item Cross Reference].[Cross-Reference Type No_] = 'EAN' "
"LEFT OUTER JOIN [Navision4].[dbo].[3S disponibelt for export] ON [Navision4].[dbo].[3S disponibelt for export].[Item No_] = [Navision4].[dbo].[3S Company A_S$Item].[No_] "
"LEFT OUTER JOIN [Navision4].[dbo].[3S Lagersaldo] ON [Navision4].[dbo].[3S Company A_S$Item].[No_] = [Navision4].[dbo].[3S Lagersaldo].[Item no_] "
"LEFT OUTER JOIN [Navision4].[dbo].[3S i_bestilling] ON [Navision4].[dbo].[3S Company A_S$Item].[No_] = [Navision4].[dbo].[3S i_bestilling].[No_] "
"WHERE [Navision4].[dbo].[3S Company A_S$Item].[No_] <> '' " & strWhereItemCategory & " " & strWhereItemVendor & " " & strWhereItemStatus & " " & strWhereItemC & " " & strWhereItemE & " " & strWhereQty & " " & strWhereMisc & " "
"ORDER BY [Navision4].[dbo].[3S Company A_S$Item].[" & strOrderSort & "] " & strSort & ""
But I want to only SELECT TOP 1 from this OUTER LEFT JOIN "LEFT OUTER JOIN [Navision4].[dbo].[3S Company A_S$Item Cross Reference] ON [Navision4].[dbo].[3S Company A_S$Item].[No_] = [Navision4].[dbo].[3S Company A_S$Item Cross Reference].[Item No_] AND [Navision4].[dbo].[3S Company A_S$Item Cross Reference].[Cross-Reference Type No_] = 'EAN' "
How can I do that?
" &_
for us since they have nothing to do with the sql query. Show the sql query without the VB.NET variables. – Tim Schmelter