>
سلام
ممنون، ما و تیممون در حا بررسی هستیم، به زودی بهتون اطلاع میدیم
سلام وققپتتون بخیر
چندین ماه درگیر این ماجرا بودیم و فقط راه حل شما جواب داد
بسیار ممنون از کمکتون
وحدت حمیدی wrote:
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'FK_PictureBinary_Picture_PictureId') AND parent_object_id = OBJECT_ID(N'PictureBinary'))
ALTER TABLE [PictureBinary] DROP CONSTRAINT [FK_PictureBinary_Picture_PictureId]
GO
select count(*) from PictureBinary
--copy existing data
INSERT INTO [dbo].[PictureBinary](PictureId, BinaryData)
SELECT [Id], [PictureBinary] FROM [dbo].[Picture]
INSERT INTO [dbo].[PictureBinary](PictureId, BinaryData)
SELECT top 1 [Id], [PictureBinary] FROM [dbo].[Picture] where Id NOT IN (select PictureId from [PictureBinary])
CREATE TABLE [dbo].[PictureBinary]
(
[Id] int IDENTITY(1,1) NOT NULL,
[PictureId] int NOT NULL,
[BinaryData] [varbinary](max) NULL,
PRIMARY KEY CLUSTERED
(
[Id] ASC
) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
ALTER TABLE dbo.Picture DROP COLUMN [PictureBinary]')
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'FK_PictureBinary_Picture_PictureId') AND parent_object_id = OBJECT_ID(N'PictureBinary'))
ALTER TABLE [PictureBinary] DROP CONSTRAINT [FK_PictureBinary_Picture_PictureId]
GO
ALTER TABLE [dbo].[PictureBinary] WITH CHECK ADD CONSTRAINT [FK_PictureBinary_Picture_PictureId] FOREIGN KEY(PictureId)
REFERENCES [dbo].[Picture] ([Id])
ON DELETE CASCADE
GO