I have a stored-procedure which will save a file into a filetable
table:
DECLARE @table1 TABLE (id NVARCHAR(50))
INSERT INTO FileTable1(file_stream,name,path_locator) OUTPUT inserted.stream_id INTO @table1 VALUES(@File,@FName,@SubDirectoryPath)
The problem is, SOME TIMES stored procedure raises insert duplicate key
error and i don't know why.
ERROR MESSAGE:
Violation of UNIQUE KEY constraint ''UQ__FileTabl__A236CBB318510CF4''. Cannot insert duplicate key in object ''dbo.FileTable1''. The duplicate key value is...
-----------------EDIT---------------------
I know what Duplicate key
means, But i'm wondering that: should stream-id
automatically inserted by sql server
according to the following table structure?
CREATE TABLE [dbo].[FileTable1] AS FILETABLE ON [PRIMARY] FILESTREAM_ON [FSDataGroup]
WITH
(
FILETABLE_DIRECTORY = N'FileTable1', FILETABLE_COLLATE_FILENAME = Arabic_CI_AS
)