Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7748307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:45:03+00:00 2026-06-01T10:45:03+00:00

I have a table that we just enabled FileStreams on. We created a new

  • 0

I have a table that we just enabled FileStreams on. We created a new varbinary column and set it to store to a filestream. Then we copied everything from the existing column to the new one in order to get the file data pushed to the file system.

So far so good.

However, we weren’t able to take the DB offline while doing this (uptime SLA) and there were 2 records out of 7400 that came in after the update statement ran but before we renamed the columns. We currently have 2 columns: FileData and FileDataOld. Where FileData is the one tied to the filestream.

The average file size is a little over 2MB. So, I decided to run a very simple select statement to find the records that didn’t go:

select DocumentId, FileName
from docslist
where FileData is null

When I ran this query, the CPU spiked to 80% and sat there for quite a while. Ultimately I killed the select after 2 minutes because that was just insane.

If I run something like:

select DocumentId, FileName from docslist

It returns almost instantly.

However, as soon as I try to query where FileData or FileDataOld is null it spins off into forever land.

When using Resource Monitor, and I query for ‘FileData is null’, I can see it pulling every byte from every single document off the file system. Which is pretty odd; you’d think that info would be stored within the table itself.

If I query for FileDataOld is null, it looks like it’s trying to load the entire table (16GB) in memory.

How can I improve this?? I just need to get the 2 records that happened after the update statement and force those documents to move over.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:45:04+00:00Added an answer on June 1, 2026 at 10:45 am

    Can’t you do:

    select DocumentId, FileName from docslist WHERE DATALENGTH(FileData)>0
    

    On mdsn it says:

    DATALENGTH is especially useful with varchar, varbinary, text, image,
    nvarchar, and ntext data types because these data types can store
    variable-length data.

    The DATALENGTH of NULL is NULL.

    Reference here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just noticed that if I have an identity column in a table, when
We have a 10 thousand row table that has just 2 columns, a primary
I have to models that are practically the same, just diferent table in db
I have several database tables that just contain a single column and very few
Just a SQL Server 2008 generic question, I have a table that has around
I have some tables that represent various types. They usually just consist of an
I have a relatively large database tables (just under a million rows) that has
I have table that I insert data with following query (from c# code): INSERT
I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45
I have a table that got into the db_owner schema, and I need it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.