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

Table Structure Expand / Collapse
Author
Message
Posted Thursday, April 25, 2013 11:40 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Sunday, December 14, 2014 11:09 PM
Points: 1,962, Visits: 2,406
Hi,
Below are the 2 table structure from which I have to select TransactionID from table GV_Voucher which are not present in GV_ReceivedOffice. But as TransactionID column not present in Gv_ReceivedOffice so I am confused is it good to add to a TransactionId in GV_Received table or should I exctract TransactionID on basis of vouchers?

CREATE TABLE [dbo].[GV_Voucher](
[VoucherId] [int] IDENTITY(1,1) NOT NULL,
[VoucherTypeId] [int] NOT NULL,
[VoucherNo] [varchar](20) NOT NULL,
[Denomination] [int] NOT NULL,
[ExpiryDate] [datetime] NULL,
[CreatedDate] [datetime] NULL,
[ModifyDate] [datetime] NULL,
[VoucherStatusId] [int] NOT NULL,
[TransactionID] [varchar](20) NOT NULL,
[Quantity] [int] NOT NULL,
[AmountValue] [int] NULL,
[CreatedBy] [nvarchar](50) NULL,
[ModifiedBy] [nvarchar](50) NULL,
[Validatedays] [int] NULL,
[IsDeleted] [bit] NULL,
CONSTRAINT [PK_GV_Voucher] PRIMARY KEY CLUSTERED
(
[VoucherId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [UN_GVVoucher_VoucherNo] UNIQUE NONCLUSTERED
(
[VoucherNo] 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].[GV_Voucher] WITH NOCHECK ADD CONSTRAINT [FK_GV_Voucher_GV_VoucherStatus] FOREIGN KEY([VoucherStatusId])
REFERENCES [dbo].[GV_VoucherStatus] ([VoucherStatusId])
GO

ALTER TABLE [dbo].[GV_Voucher] NOCHECK CONSTRAINT [FK_GV_Voucher_GV_VoucherStatus]
GO

ALTER TABLE [dbo].[GV_Voucher] WITH NOCHECK ADD CONSTRAINT [FK_GV_Voucher_GV_VoucherType] FOREIGN KEY([VoucherTypeId])
REFERENCES [dbo].[GV_VoucherType] ([VoucherTypeID])
GO

ALTER TABLE [dbo].[GV_Voucher] NOCHECK CONSTRAINT [FK_GV_Voucher_GV_VoucherType]
GO
-----------------------------------------------------------------------------------------
CREATE TABLE [dbo].[GV_ReceivedOffice](
[ReceivedOfficeID] [int] IDENTITY(1,1) NOT NULL,
[VoucherNo] [varchar](20) NULL,
[ReceivedDate] [datetime] NULL,
[ReceivedBy] [int] NULL,
PRIMARY KEY CLUSTERED
(
[ReceivedOfficeID] 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



_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1446803
Posted Friday, April 26, 2013 2:30 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, December 11, 2014 1:51 AM
Points: 2,693, Visits: 4,755
Is it possible for TransactionID to be duplicated in the table GV_Voucher?
If the answer is No, then you can fetch it based on VoucherNo's else you will need TransactionID in both the tables.



Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1446848
Posted Friday, April 26, 2013 2:38 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 2:51 PM
Points: 3,115, Visits: 3,237
It depends on TransactionID as Kingston said.
How big are the tables? Do they have many indexes?

Regards
IgorMi




Igor Micev,
SQL Server developer at Seavus
www.seavus.com
Post #1446853
Posted Friday, April 26, 2013 3:07 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Sunday, December 14, 2014 11:09 PM
Points: 1,962, Visits: 2,406
Kingston Dhasian (4/26/2013)
Is it possible for TransactionID to be duplicated in the table GV_Voucher?
If the answer is No, then you can fetch it based on VoucherNo's else you will need TransactionID in both the tables.

ye sTransactionID is duplicate in table Gv_voucher and voucherno is unique



_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1446859
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse