Click here to Skip to main content
15,867,568 members
Home / Discussions / Database
   

Database

 
QuestionDatabase Mail Not sending Email Pin
Robymon8-Dec-14 20:56
Robymon8-Dec-14 20:56 
QuestionDo I have to have SQL Server Express installed? Pin
jkirkerx30-Nov-14 11:31
professionaljkirkerx30-Nov-14 11:31 
AnswerRe: Do I have to have SQL Server Express installed? Pin
Richard MacCutchan30-Nov-14 21:30
mveRichard MacCutchan30-Nov-14 21:30 
GeneralRe: Do I have to have SQL Server Express installed? Pin
jkirkerx2-Dec-14 10:21
professionaljkirkerx2-Dec-14 10:21 
AnswerRe: Do I have to have SQL Server Express installed? Pin
Eddy Vluggen2-Dec-14 7:27
professionalEddy Vluggen2-Dec-14 7:27 
GeneralRe: Do I have to have SQL Server Express installed? Pin
jkirkerx2-Dec-14 10:25
professionaljkirkerx2-Dec-14 10:25 
Questionsql server import export wizard stored procedure? Pin
iamvinod3426-Nov-14 18:57
iamvinod3426-Nov-14 18:57 
AnswerRe: sql server import export wizard stored procedure? Pin
Mycroft Holmes26-Nov-14 20:09
professionalMycroft Holmes26-Nov-14 20:09 
AnswerRe: sql server import export wizard stored procedure? Pin
jschell27-Nov-14 6:02
jschell27-Nov-14 6:02 
QuestionNeed to Truncate a table and populate the rest of the tables Pin
Hari-CodeBlogger25-Nov-14 0:30
Hari-CodeBlogger25-Nov-14 0:30 
QuestionRe: Need to Truncate a table and populate the rest of the tables Pin
Shweta N Mishra26-Nov-14 4:35
professionalShweta N Mishra26-Nov-14 4:35 
QuestionJoining three tables in sql server 2012 Pin
umair275624-Nov-14 4:06
professionalumair275624-Nov-14 4:06 
Dear All

we need some help. We have Three Tables in sqlserver2012

Master Table

OrderID PackageID CustomerName
1 1 Abc
2 2 Bcd
3 1 xyz


Child1 Table

OrderID ControlName
1 Row1COlumn1 (It Means Pant in Red Color is selected by user(relation with Child2 Table))
1 Row3Column1 (It Means Gown in Blue Color is selected by user(relation with Child2 Table))
1 Row4Column3 (It Means T Shirt in White Color is selected by user(relation with Child2 Table))
2 Row1Column2 (It Means Tie in Green Color is selected by user(relation with Child2 Table))
2 Row3Column1 (It Means Bow in Red Color is selected by user(relation with Child2 Table))

Child2 Table

PackageID Product Color1 Color2 Color3
1 Pant Red Green Blue
1 Shirt Blue Pink Purple
1 Gown Blue Black Yellow
1 T Shirt Red Green White
2 Tie Red Green White
2 Socks Red Green White
2 Bow Red Green White

We want to have result like

OrderID PackageID CustomerName Pant Gown T Shirt Tie Bow

1 1 ABC Red Blue White x x
Blue
2 2 Bcd x x x Green Red


DB Script
CREATE TABLE [dbo].[Child1](
[Child1ID] [int] NOT NULL,
[OrderID] [int] NULL,
[ControlName] [nvarchar](max) NULL,
CONSTRAINT [PK_Child1] PRIMARY KEY CLUSTERED
(
[Child1ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object: Table [dbo].[Child2] Script Date: 11/11/2014 6:06:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Child2](
[Child2ID] [int] NOT NULL,
[PackageID] [int] NULL,
[Product] [nvarchar](max) NULL,
[Color1] [nchar](10) NULL,
[Color2] [nchar](10) NULL,
[Color3] [nchar](10) NULL,
CONSTRAINT [PK_Child2] PRIMARY KEY CLUSTERED
(
[Child2ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object: Table [dbo].[MasterTable] Script Date: 11/11/2014 6:06:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MasterTable](
[OrderID] [int] NOT NULL,
[PackageID] [int] NULL,
[CustomerName] [nvarchar](max) NOT NULL,
CONSTRAINT [PK_MasterTable] PRIMARY KEY CLUSTERED
(
[OrderID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
INSERT [dbo].[Child1] ([Child1ID], [OrderID], [ControlName]) VALUES (1, 1, N'Row1Column1')
GO
INSERT [dbo].[Child1] ([Child1ID], [OrderID], [ControlName]) VALUES (2, 1, N'Row3Column1')
GO
INSERT [dbo].[Child1] ([Child1ID], [OrderID], [ControlName]) VALUES (3, 1, N'Row4Column3')
GO
INSERT [dbo].[Child1] ([Child1ID], [OrderID], [ControlName]) VALUES (4, 2, N'Row1Column2')
GO
INSERT [dbo].[Child1] ([Child1ID], [OrderID], [ControlName]) VALUES (5, 3, N'Row3Column1')
GO
INSERT [dbo].[Child2] ([Child2ID], [PackageID], [Product], [Color1], [Color2], [Color3]) VALUES (1, 1, N'Pant', N'Red ', N'Green ', N'Blue ')
GO
INSERT [dbo].[Child2] ([Child2ID], [PackageID], [Product], [Color1], [Color2], [Color3]) VALUES (2, 1, N'Shirt', N'Blue ', N'Pink ', N'Purple ')
GO
INSERT [dbo].[Child2] ([Child2ID], [PackageID], [Product], [Color1], [Color2], [Color3]) VALUES (3, 1, N'Gown', N'Blue ', N'Black ', N'Yellow ')
GO
INSERT [dbo].[Child2] ([Child2ID], [PackageID], [Product], [Color1], [Color2], [Color3]) VALUES (4, 1, N'T Shirt', N'Red ', N'Green ', N'White ')
GO
INSERT [dbo].[Child2] ([Child2ID], [PackageID], [Product], [Color1], [Color2], [Color3]) VALUES (5, 2, N'Tie', N'Red ', N'Green ', N'White ')
GO
INSERT [dbo].[Child2] ([Child2ID], [PackageID], [Product], [Color1], [Color2], [Color3]) VALUES (6, 2, N'Socks', N'Red ', N'Green ', N'White ')
GO
INSERT [dbo].[Child2] ([Child2ID], [PackageID], [Product], [Color1], [Color2], [Color3]) VALUES (7, 2, N'Bow', N'Red ', N'Green ', N'White ')
GO
INSERT [dbo].[MasterTable] ([OrderID], [PackageID], [CustomerName]) VALUES (1, 1, N'Abc')
GO
INSERT [dbo].[MasterTable] ([OrderID], [PackageID], [CustomerName]) VALUES (2, 2, N'xyz')
GO
USE [master]
GO
ALTER DATABASE [GarmentsTest] SET READ_WRITE
GO

Thanks and Best Regards Umair
AnswerRe: Joining three tables in sql server 2012 Pin
Simon_Whale24-Nov-14 4:56
Simon_Whale24-Nov-14 4:56 
AnswerRe: Joining three tables in sql server 2012 Pin
Eddy Vluggen24-Nov-14 7:36
professionalEddy Vluggen24-Nov-14 7:36 
AnswerRe: Joining three tables in sql server 2012 Pin
Jörgen Andersson24-Nov-14 21:47
professionalJörgen Andersson24-Nov-14 21:47 
AnswerRe: Joining three tables in sql server 2012 Pin
syed shanu30-Nov-14 22:13
mvasyed shanu30-Nov-14 22:13 
Questionclustering index Pin
Amr Mohammad23-Nov-14 9:04
Amr Mohammad23-Nov-14 9:04 
AnswerRe: clustering index Pin
PIEBALDconsult23-Nov-14 9:12
mvePIEBALDconsult23-Nov-14 9:12 
GeneralRe: clustering index Pin
Amr Mohammad23-Nov-14 9:31
Amr Mohammad23-Nov-14 9:31 
GeneralRe: clustering index Pin
PIEBALDconsult23-Nov-14 9:57
mvePIEBALDconsult23-Nov-14 9:57 
AnswerRe: clustering index Pin
PIEBALDconsult23-Nov-14 10:29
mvePIEBALDconsult23-Nov-14 10:29 
GeneralRe: clustering index Pin
Amr Mohammad23-Nov-14 10:44
Amr Mohammad23-Nov-14 10:44 
QuestionProblem reading null Pin
Jassim Rahma21-Nov-14 0:25
Jassim Rahma21-Nov-14 0:25 
AnswerRe: Problem reading null Pin
Chris Quinn21-Nov-14 0:50
Chris Quinn21-Nov-14 0:50 
AnswerRe: Problem reading null Pin
Jörgen Andersson21-Nov-14 1:33
professionalJörgen Andersson21-Nov-14 1:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.