# Drupal 7 on Windows - File Module Problems

Installed Drupal 7 using the Web Platform installer on Windows 2008

For some reason, the file module, when you upload a file, uses the first few letters of the filename as the unique key to store in the database, which of course causes problems very fast.

I'm wondering does anybody have a workaround for this?

An AJAX HTTP request terminated abnormally. Debugging information follows.

StatusText: n/a

ResponseText:  Error message PDOException: SQLSTATE[23000]: [Microsoft][SQL Server Native Client10.0][SQL Server]Cannot insert duplicate key row in object 'dbo.file_managed' with unique index 'uri_unique'. in drupal_write_record() (line 6776 of  ..........\includes\common.inc). Error The website encountered an unexpected error. Please try again later.


-

I experienced exactly the same problem today. It happened when I was trying to load a new theme.

I have installed another instance of Drupal with a MySQL database to compare the tables and check if there were a calculated field there.

There was none. In MySQL the index is built on the field 'uri'

So, in my SQL server database, I moved the 'uri_unique' index from the field '__unique_uri' to the field 'uri' (like in MySQL). And it worked just fine !

I assume it's less efficient as the field is nvarchar(255) where the calculated field was a varbinary(16)... and I hope i won't be in trouble later...But at least, it solved the problem.

-
Similar to the solution I found where I changed the calculated field, but I think your solution might even work better. Thnx! –  TimothyP Feb 16 '11 at 12:27

I just found the bug report for that problem: http://drupal.org/node/10508004 (There is a patch)

-
This issues seems to be missing now? –  David Barratt May 15 '14 at 19:39

Apparently some genious inserted this in the database:

the __unique_uri in the file_managed table is a calculated field:

(CONVERT([varbinary](16),hashbytes('MD4',coalesce(CONVERT([varbinary],[uri],0),CONVERT([varbinary],[__pk],0))),0))

-