Hola
Tengo 2 tablas casi iguales SalesB y SalesC.La tabla SalesC no tiene el
campo InvN (numero de factura). Desde la tabla SalesC pretendo hacer un
insert masivo a la tabla SalesB, pero me encuertro con el problema de como
le asigno el numero de Factura correlativo a la Tabla SalesB?
Espero ser claro, transcribo las tablas, desde ya muchas gracias.
CREATE TABLE [SalesC] (
[InvId] [int] IDENTITY (1, 1) NOT NULL ,
[InvDate] [datetime] NULL ,
[PaymentTerms] [int] NULL ,
[DueDate] AS ([invdate] + [paymentTerms]) ,
[CustomerId] [nvarchar] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[TotalInv] [smallmoney] NULL ,
[CustomerPO] [char] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[ShippingMethod] [char] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[ShipDate] [datetime] NULL ,
[DateEntry] [datetime] NULL ,
[UserBelstone] [char] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Notes] [char] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[SalesPersonId] [int] NULL ,
[PO] [char] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PL] [numeric](18, 0) NULL ,
[Shipping] [int] NULL ,
CONSTRAINT [PK_SalesC] PRIMARY KEY CLUSTERED
(
[InvN]
) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE TABLE [SalesB] (
[InvId] [int] IDENTITY (1, 1) NOT NULL ,
[InvN] [int] NOT NULL ,
[InvDate] [datetime] NULL CONSTRAINT [DF_SalesB_InvDate] DEFAULT
(getdate()),
[PaymentTerms] [int] NULL ,
[DueDate] AS ([invdate] + [paymentTerms]) ,
[CustomerId] [nvarchar] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[TotalInv] [money] NULL ,
[CustomerPO] [char] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[ShippingMethod] [char] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
CONSTRAINT [DF_SalesB_ShippingMethod] DEFAULT ('Cust. Pickup'),
[ShipDate] [datetime] NULL CONSTRAINT [DF_SalesB_ShipDate] DEFAULT
(getdate()),
[DateEntry] [datetime] NULL CONSTRAINT [DF_SalesB_DateEntry] DEFAULT
(getdate()),
[UserBelstone] [char] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
CONSTRAINT [DF_SalesB_UserBelstone] DEFAULT (suser_sname()),
[Notes] [char] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[SalesPersonId] [int] NULL ,
[PO] [char] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PL] [numeric](18, 0) NULL ,
[Shipping] [int] NULL ,
[NoPrint] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
CONSTRAINT [PK_SalesB] PRIMARY KEY CLUSTERED
(
[InvN]
) ON [PRIMARY]
) ON [PRIMARY]
GO
Leer las respuestas