July 7, 2014 at 9:59 am
I want to generate a list of all the unique pairs from these two tables. Such as:
MatCostType : Loc
1 : A
1 : B
1 : C
2 : A
2 : B
2 : C
...
3 : C
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TableA](
[MatCostType] [char](1) NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TableB](
[Loc] [char](3) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
insert into TableA(MatCostType)
Select '1'
union all
Select '2'
union all
Select '3'
Go
insert into TableB(Loc)
Select 'A'
union all
Select 'B'
union all
Select 'C'
Go
How do I go about this?
Thanks,
pat
July 7, 2014 at 10:10 am
Looks like you want a CROSS JOIN.
I'd provide the code, but I think you'll get more by reading the link above and coding it yourself.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply