Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

SQL Logical errors Expand / Collapse
Author
Message
Posted Thursday, March 28, 2013 9:43 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 9:10 AM
Points: 13,230, Visits: 12,709
sundayose (3/28/2013)
I think what I need is a tutorial which will teach me on how to join multiple table.

Most of the tutorials I am getting on the internet do not show how to deal with multiple tables like 5 or more thanks.


If you want help with this you will have to post ddl, sample data and desired results. See the first link in my signature for best practices when posting questions.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1436566
Posted Thursday, March 28, 2013 10:04 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, August 9, 2013 11:04 AM
Points: 7, Visits: 16
How do I generate the DDL for entire my Database?

Thanks for the responses.
Post #1436582
Posted Thursday, March 28, 2013 10:07 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 9:10 AM
Points: 13,230, Visits: 12,709
sundayose (3/28/2013)
How do I generate the DDL for entire my Database?

Thanks for the responses.


You don't need the entire database, just the few tables in your query.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1436586
Posted Thursday, March 28, 2013 10:26 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, August 9, 2013 11:04 AM
Points: 7, Visits: 16
Below is the DDL for my tables.


USE [MSIU]
GO
/****** Object: Table [dbo].[tbl_DISTRIBUTOR_MASTER] Script Date: 3/28/2013 7:23:14 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tbl_DISTRIBUTOR_MASTER](
[int_DISTRIBUTOR_ID] [bigint] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[str_DISTRIBUTOR_CODE] [varchar](50) NULL,
[str_DISTRIBUTOR_NAME] [varchar](100) NULL,
[int_ORAGANISATION_TYPE_ID] [int] NULL,
[str_PROPRIETOR_NAME] [varchar](50) NULL,
[str_OCCUPATION] [varchar](50) NULL,
[str_DESIGNATION] [varchar](50) NULL,
[str_CONTACT_NUMBER] [varchar](50) NULL,
[str_EMAIL] [varchar](100) NULL,
[str_ACCEPTABLE_CREDIT_LIMIT] [varchar](50) NULL,
[dec_ACCEPTED_DISCOUNT] [decimal](18, 2) NULL,
[str_POSTAL_ADDRESS] [varchar](200) NULL,
[int_VILLAGE_ID] [bigint] NOT NULL,
[int_PARISH_ID] [bigint] NOT NULL,
[int_SUB_COUNTY_ID] [bigint] NOT NULL,
[int_COUNTY_ID] [bigint] NOT NULL,
[int_SUB_DISTRICT_ID] [bigint] NOT NULL,
[int_DISTRICT_ID] [bigint] NOT NULL,
[int_COUNTRY_ID] [bigint] NOT NULL,
[bln_ACTIVE] [bit] NULL,
[bln_ISDELETED] [bit] NOT NULL,
[str_CREATED_BY] [varchar](50) NULL,
[dt_CREATED_DATE] [datetime] NULL,
[str_UPDATED_BY] [varchar](50) NULL,
[dt_UPDATED_DATE] [datetime] NULL,
CONSTRAINT [PK_tbl_DISTRIBUTOR_MASTER] PRIMARY KEY CLUSTERED
(
[int_DISTRIBUTOR_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[tbl_SALES_EXECUTIVE_MASTER] Script Date: 3/28/2013 7:23:14 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tbl_SALES_EXECUTIVE_MASTER](
[int_SALES_EXECUTIVE_ID] [bigint] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[str_SALES_EXECUTIVE_CODE] [varchar](50) NULL,
[str_SALES_EXECUTIVE_NAME] [varchar](100) NULL,
[str_EMAIL] [varchar](100) NULL,
[str_GENDER] [varchar](50) NULL,
[str_CONTACT_NUMBER] [varchar](50) NULL,
[int_ACCEPTABLE_CREDIT_LIMIT] [int] NULL,
[str_AREA_OF_OPERATION] [varchar](50) NULL,
[int_SALES_TEAM_ID] [bigint] NULL,
[str_PHYSICAL_ADDRESS] [varchar](200) NULL,
[bln_ISACTIVE] [bit] NULL,
[bln_ISDELETED] [bit] NOT NULL,
[str_CREATED_BY] [varchar](50) NULL,
[dt_CREATED_DATE] [datetime] NULL,
[str_UPDATED_BY] [varchar](50) NULL,
[dt_UPDATED_DATE] [datetime] NULL,
[dt_BIRTH_DATE] [datetime] NULL,
CONSTRAINT [PK_tbl_SALSE_EXECUTIVE_MASTER] PRIMARY KEY CLUSTERED
(
[int_SALES_EXECUTIVE_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[tbl_SALES_TEAM_MASTER] Script Date: 3/28/2013 7:23:14 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tbl_SALES_TEAM_MASTER](
[int_SALES_TEAM_ID] [bigint] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[str_SALES_TEAM_CODE] [varchar](50) NULL,
[str_SALES_TEAM_NAME] [varchar](100) NULL,
[str_DRIVER_NAME] [varchar](100) NULL,
[str_DESCRIPTION] [varchar](1000) NULL,
[bln_ISACTIVE] [bit] NOT NULL,
[bln_ISDELETED] [bit] NOT NULL,
[str_CREATED_BY] [varchar](50) NULL,
[dt_CREATED_DATE] [datetime] NULL,
[str_UPDATED_BY] [varchar](50) NULL,
[dt_UPDATED_DATE] [datetime] NULL,
CONSTRAINT [PK_tbl_SALES_TEAM_MASTER] PRIMARY KEY CLUSTERED
(
[int_SALES_TEAM_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[tbl_VOUCHER_CAPTURE] Script Date: 3/28/2013 7:23:14 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tbl_VOUCHER_CAPTURE](
[int_VOUCHER_CAPTURE_ID] [bigint] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[int_SALES_TEAM_ID] [bigint] NULL,
[int_SALES_EXECUTIVE_ID] [bigint] NULL,
[int_DISTRIBUTOR_ID] [bigint] NULL,
[dt_VOUCHER_ISSUE_DATE] [datetime] NULL,
[str_CREATED_BY] [varchar](50) NULL,
[dt_CREATED_DATE] [datetime] NULL,
[str_UPDATED_BY] [varchar](50) NULL,
[dt_UPDATED_DATE] [datetime] NULL,
[int_SALES_AMOUNT] [decimal](18, 2) NULL,
CONSTRAINT [PK_tbl_VOUCHER_CAPTURE] PRIMARY KEY CLUSTERED
(
[int_VOUCHER_CAPTURE_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[tbl_VOUCHER_CAPTURE_DETAIL] Script Date: 3/28/2013 7:23:14 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tbl_VOUCHER_CAPTURE_DETAIL](
[int_VOUCHER_CAPTURE_DETAIL_ID] [bigint] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[int_VOUCHER_CAPTURE_ID] [bigint] NOT NULL,
[int_SEQ_NO] [bigint] NULL,
[int_BARCODE_DETAIL_ID] [bigint] NOT NULL,
[int_BARCODE_ID] [bigint] NOT NULL,
[int_VOUCHER_ISSUE_ID] [bigint] NOT NULL,
[int_VOUCHER_ISSUE_DETAIL_ID] [bigint] NOT NULL,
[dt_APPLICABLE_FROM] [datetime] NULL,
[int_VOUCHER_NUMBER] [int] NULL,
[str_BARCODE] [varchar](15) NULL,
[int_STATUS] [int] NULL,
[str_CREATED_BY] [varchar](50) NULL,
[dt_CREATED_DATE] [datetime] NULL,
[str_UPDATED_BY] [varchar](50) NULL,
[dt_UPDATED_DATE] [datetime] NULL,
[bln_ISDELETE] [bit] NULL,
[int_PROJECT_TYPE] [int] NULL,
CONSTRAINT [PK_tbl_VOUCHER_CAPTURE_DETAIL] PRIMARY KEY CLUSTERED
(
[int_VOUCHER_CAPTURE_DETAIL_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[tbl_VOUCHER_ISSUE] Script Date: 3/28/2013 7:23:14 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tbl_VOUCHER_ISSUE](
[int_VOUCHER_ISSUE_ID] [bigint] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[int_SALES_TEAM_ID] [bigint] NULL,
[dt_VOUCHER_ISSUE_DATE] [datetime] NULL,
[str_CREATED_BY] [varchar](50) NULL,
[dt_CREATED_DATE] [datetime] NULL,
[str_UPDATED_BY] [varchar](50) NULL,
[dt_UPDATED_DATE] [datetime] NULL,
CONSTRAINT [PK_tbl_VOUCHER_ISSUE] PRIMARY KEY CLUSTERED
(
[int_VOUCHER_ISSUE_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[tbl_VOUCHER_ISSUE_DETAIL] Script Date: 3/28/2013 7:23:14 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tbl_VOUCHER_ISSUE_DETAIL](
[int_VOUCHER_ISSUE_DETAIL_ID] [bigint] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[int_VOUCHER_ISSUE_ID] [bigint] NOT NULL,
[int_SEQ_NO] [bigint] NULL,
[int_BARCODE_DETAIL_ID] [bigint] NOT NULL,
[int_BARCODE_ID] [bigint] NOT NULL,
[dt_APPLICABLE_FROM] [datetime] NULL,
[int_VOUCHER_NUMBER] [int] NULL,
[str_BARCODE] [varchar](15) NULL,
[int_STATUS] [int] NULL,
[int_DISTRIBUTOR_ID] [bigint] NOT NULL,
[str_CREATED_BY] [varchar](50) NULL,
[dt_CREATED_DATE] [datetime] NULL,
[str_UPDATED_BY] [varchar](50) NULL,
[dt_UPDATED_DATE] [datetime] NULL,
[bln_ISDELETE] [bit] NULL,
[int_PROJECT_TYPE] [int] NULL,
CONSTRAINT [PK_tbl_VOUCHER_ISSUE_DETAIL] PRIMARY KEY CLUSTERED
(
[int_VOUCHER_ISSUE_DETAIL_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[tbl_DISTRIBUTOR_MASTER] ADD CONSTRAINT [DF_tbl_DISTRIBUTOR_MASTER_int_VILLAGE_ID] DEFAULT ((0)) FOR [int_VILLAGE_ID]
GO
ALTER TABLE [dbo].[tbl_DISTRIBUTOR_MASTER] ADD CONSTRAINT [DF_tbl_DISTRIBUTOR_MASTER_int_PARISH_ID] DEFAULT ((0)) FOR [int_PARISH_ID]
GO
ALTER TABLE [dbo].[tbl_DISTRIBUTOR_MASTER] ADD CONSTRAINT [DF_tbl_DISTRIBUTOR_MASTER_int_SUB_COUNTY_ID] DEFAULT ((0)) FOR [int_SUB_COUNTY_ID]
GO
ALTER TABLE [dbo].[tbl_DISTRIBUTOR_MASTER] ADD CONSTRAINT [DF_tbl_DISTRIBUTOR_MASTER_int_COUNTY_ID] DEFAULT ((0)) FOR [int_COUNTY_ID]
GO
ALTER TABLE [dbo].[tbl_DISTRIBUTOR_MASTER] ADD CONSTRAINT [DF_tbl_DISTRIBUTOR_MASTER_int_SUB_DISTRICT_ID] DEFAULT ((0)) FOR [int_SUB_DISTRICT_ID]
GO
ALTER TABLE [dbo].[tbl_DISTRIBUTOR_MASTER] ADD CONSTRAINT [DF_tbl_DISTRIBUTOR_MASTER_int_DISTRICT_ID] DEFAULT ((0)) FOR [int_DISTRICT_ID]
GO
ALTER TABLE [dbo].[tbl_DISTRIBUTOR_MASTER] ADD CONSTRAINT [DF_tbl_DISTRIBUTOR_MASTER_int_COUNTRY_ID] DEFAULT ((0)) FOR [int_COUNTRY_ID]
GO
ALTER TABLE [dbo].[tbl_DISTRIBUTOR_MASTER] ADD CONSTRAINT [DF_tbl_DISTRIBUTOR_MASTER_bln_ACTIVE] DEFAULT ((1)) FOR [bln_ACTIVE]
GO
ALTER TABLE [dbo].[tbl_DISTRIBUTOR_MASTER] ADD CONSTRAINT [DF_tbl_DISTRIBUTOR_MASTER_bln_ISDELETED] DEFAULT ((0)) FOR [bln_ISDELETED]
GO
ALTER TABLE [dbo].[tbl_SALES_EXECUTIVE_MASTER] ADD CONSTRAINT [DF_tbl_SALSE_EXECUTIVE_MASTER_bln_ISACTIVE] DEFAULT ((1)) FOR [bln_ISACTIVE]
GO
ALTER TABLE [dbo].[tbl_SALES_EXECUTIVE_MASTER] ADD CONSTRAINT [DF_tbl_SALSE_EXECUTIVE_MASTER_bln_ISDELETED] DEFAULT ((0)) FOR [bln_ISDELETED]
GO
ALTER TABLE [dbo].[tbl_SALES_TEAM_MASTER] ADD CONSTRAINT [DF_tbl_SALES_TEAM_MASTER_bln_ISDELETED1] DEFAULT ((1)) FOR [bln_ISACTIVE]
GO
ALTER TABLE [dbo].[tbl_SALES_TEAM_MASTER] ADD CONSTRAINT [DF_tbl_SALES_TEAM_MASTER_bln_ISDELETED] DEFAULT ((0)) FOR [bln_ISDELETED]
GO
ALTER TABLE [dbo].[tbl_VOUCHER_CAPTURE_DETAIL] ADD CONSTRAINT [DF_tbl_VOUCHER_CAPTURE_DETAIL_bln_ISDELETE] DEFAULT ((0)) FOR [bln_ISDELETE]
GO
ALTER TABLE [dbo].[tbl_VOUCHER_ISSUE_DETAIL] ADD CONSTRAINT [DF_Table_1_int_CLIENT_ID] DEFAULT ((0)) FOR [int_DISTRIBUTOR_ID]
GO
ALTER TABLE [dbo].[tbl_VOUCHER_ISSUE_DETAIL] ADD CONSTRAINT [DF_tbl_VOUCHER_ISSUE_DETAIL_bln_ISDELETE] DEFAULT ((0)) FOR [bln_ISDELETE]
GO
ALTER TABLE [dbo].[tbl_DISTRIBUTOR_MASTER] WITH CHECK ADD CONSTRAINT [FK_tbl_DISTRIBUTOR_MASTER_tbl_VILLAGE_MASTER] FOREIGN KEY([int_VILLAGE_ID])
REFERENCES [dbo].[tbl_VILLAGE_MASTER] ([int_VILLAGE_ID])
GO
ALTER TABLE [dbo].[tbl_DISTRIBUTOR_MASTER] CHECK CONSTRAINT [FK_tbl_DISTRIBUTOR_MASTER_tbl_VILLAGE_MASTER]
GO
ALTER TABLE [dbo].[tbl_SALES_EXECUTIVE_MASTER] WITH CHECK ADD CONSTRAINT [FK_tbl_SALES_EXECUTIVE_MASTER_tbl_SALES_TEAM_MASTER] FOREIGN KEY([int_SALES_TEAM_ID])
REFERENCES [dbo].[tbl_SALES_TEAM_MASTER] ([int_SALES_TEAM_ID])
GO
ALTER TABLE [dbo].[tbl_SALES_EXECUTIVE_MASTER] CHECK CONSTRAINT [FK_tbl_SALES_EXECUTIVE_MASTER_tbl_SALES_TEAM_MASTER]
GO
ALTER TABLE [dbo].[tbl_VOUCHER_CAPTURE] WITH CHECK ADD CONSTRAINT [FK_tbl_VOUCHER_CAPTURE_tbl_DISTRIBUTOR_MASTER] FOREIGN KEY([int_DISTRIBUTOR_ID])
REFERENCES [dbo].[tbl_DISTRIBUTOR_MASTER] ([int_DISTRIBUTOR_ID])
GO
ALTER TABLE [dbo].[tbl_VOUCHER_CAPTURE] CHECK CONSTRAINT [FK_tbl_VOUCHER_CAPTURE_tbl_DISTRIBUTOR_MASTER]
GO
ALTER TABLE [dbo].[tbl_VOUCHER_CAPTURE] WITH CHECK ADD CONSTRAINT [FK_tbl_VOUCHER_CAPTURE_tbl_SALES_EXECUTIVE_MASTER] FOREIGN KEY([int_SALES_EXECUTIVE_ID])
REFERENCES [dbo].[tbl_SALES_EXECUTIVE_MASTER] ([int_SALES_EXECUTIVE_ID])
GO
ALTER TABLE [dbo].[tbl_VOUCHER_CAPTURE] CHECK CONSTRAINT [FK_tbl_VOUCHER_CAPTURE_tbl_SALES_EXECUTIVE_MASTER]
GO
ALTER TABLE [dbo].[tbl_VOUCHER_CAPTURE] WITH CHECK ADD CONSTRAINT [FK_tbl_VOUCHER_CAPTURE_tbl_SALES_TEAM_MASTER] FOREIGN KEY([int_SALES_TEAM_ID])
REFERENCES [dbo].[tbl_SALES_TEAM_MASTER] ([int_SALES_TEAM_ID])
GO
ALTER TABLE [dbo].[tbl_VOUCHER_CAPTURE] CHECK CONSTRAINT [FK_tbl_VOUCHER_CAPTURE_tbl_SALES_TEAM_MASTER]
GO
ALTER TABLE [dbo].[tbl_VOUCHER_ISSUE] WITH CHECK ADD CONSTRAINT [FK_tbl_VOUCHER_ISSUE_tbl_SALES_TEAM_MASTER] FOREIGN KEY([int_SALES_TEAM_ID])
REFERENCES [dbo].[tbl_SALES_TEAM_MASTER] ([int_SALES_TEAM_ID])
GO
ALTER TABLE [dbo].[tbl_VOUCHER_ISSUE] CHECK CONSTRAINT [FK_tbl_VOUCHER_ISSUE_tbl_SALES_TEAM_MASTER]
GO
ALTER TABLE [dbo].[tbl_VOUCHER_ISSUE_DETAIL] WITH CHECK ADD CONSTRAINT [FK_tbl_VOUCHER_ISSUE_DETAIL_tbl_BARCODE_DETAIL] FOREIGN KEY([int_BARCODE_DETAIL_ID])
REFERENCES [dbo].[tbl_BARCODE_DETAIL] ([int_BARCODE_DETAIL_ID])
GO
ALTER TABLE [dbo].[tbl_VOUCHER_ISSUE_DETAIL] CHECK CONSTRAINT [FK_tbl_VOUCHER_ISSUE_DETAIL_tbl_BARCODE_DETAIL]
GO
Post #1436603
Posted Thursday, March 28, 2013 10:43 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 9:10 AM
Points: 13,230, Visits: 12,709
That was pretty close. There are a few foreign keys to tables we don't have but that is workable. We are still missing tbl_DISTRICT_MASTER. And more importantly we still don't have any data to work with.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1436612
Posted Tuesday, April 2, 2013 6:18 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, October 31, 2013 3:44 AM
Points: 314, Visits: 4,128
Just something else you can also do if joining that many tables is all new to you.
You can join say the first two tables then check the output and then another and then check again until you
spot the join that is introducing the duplicates/rows you want excluded.
This would also give you some understanding of the data you are querying which is also what appears to be lacking here.
If you are, however, able to provide data which would be representative of the problem you are actually having then, of course, as has already been suggested go ahead and do so.
Post #1437857
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse