“Cannot find template file” has nothing to do with your database. Management Studio opens every new query window from a tiny template file on your own machine, and it cannot find it. Nobody is going to lose data over this one. It is a local file problem with a two minute fix.

What You See
Cannot find template file for new query
(C:\Program Files\...\SqlWorkbenchProjectItems\Sql\SQLFile.sql)The path in the message is the useful part. Read it, because it tells you exactly which file is missing and where Management Studio expected it.
Why a Blank Query Window Needs a File
When you click New Query, Management Studio does not create an empty buffer from nothing. It copies a template file, which normally contains nothing at all, and opens that.
It seems like a strange design until you remember the template folder holds dozens of other templates: create table, create procedure, and the rest. A blank query is simply the plainest of them.
So when the file is gone, the feature that depends on it stops. Everything else in Management Studio carries on working, which is why the error feels so out of proportion.
The Four Reasons It Goes Missing
Antivirus removed it. A zero byte .sql file under Program Files looks odd to some scanners. This is the most common cause I see.
A partial install or upgrade. Management Studio ships separately from the engine now, and an interrupted update can leave the folder incomplete.
A damaged user profile. There is a per user copy of the templates as well as the shared one, and the per user copy is the one that usually breaks.
Disk cleanup. Somebody tidied a folder they did not recognise.
The Fix That Works Most Often
Recreate the file. It is supposed to be empty, so an empty file is a complete and correct fix.
Take the exact path from the error message, create a text file there with that name, and make sure it ends in .sql rather than .sql.txt, which is the mistake people make with file extensions hidden. Then restart Management Studio.
You will probably need administrator rights to write into Program Files. That is normal for this path.
When That Is Not Enough
If the error names a path under your own user profile rather than Program Files, the per user template folder is the problem. Renaming it makes Management Studio rebuild it from the shared copy the next time it starts.
The folder sits under your AppData directory, inside the Microsoft SQL Server Management Studio folder for your version. Rename it rather than deleting it, so you can put it back if you had custom templates in there.
That last point matters. Anyone who has built up their own templates over the years should copy them out first.
Checking Nothing Else Is Wrong
The error is local, so your connection is fine. Prove it and move on:
SELECT @@SERVERNAME AS server_name,
@@VERSION AS version,
SUSER_SNAME() AS connected_as,
DB_NAME() AS current_database;If that runs, the engine never knew anything had happened.
The Wider Lesson
A surprising number of Management Studio errors are client side and say so if you read them carefully. A path on your own C drive is a strong clue. So is an error with no message number, because engine errors nearly always carry one.
Before assuming a server problem, ask whether anyone else is affected. If it is only you, and only in one application, start at your end. That one question saves a lot of time.
Stopping It Coming Back
If antivirus keeps removing the file, ask for the Management Studio program folder to be excluded from scanning. This is a normal exclusion and most security teams will accept it once they know what the file is.
Keep your own templates somewhere you control as well, in a folder that gets backed up rather than only in the application’s own directory. Those are the ones worth caring about, and they are the ones a reinstall will quietly remove.
This is not a database error, it is a missing empty file with an unusually loud opinion about itself.
Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.





9 Comments. Leave new
When I am trying to acesess Comcash, I get an Application Error:
The application has encountered the following error:
(The application will attempt to recover from this error and continue once you press, ok) But it does not….
SQL utilities has encountered a general error:
Cannor open file C:\Program Files\Comcash8.0\SQLEditImages\Hot_ExportData.bmp
Please help, this is real madening.
hii….. u can also create a new sqlscript file..rename it as “SQLFile.sql” and paste it in that location…..it will work… This file might be deleted by clean up softwares like TuneUp Utilites…as its size is in bytes.
You are absolutely correct. It’s working. I just opened a procedure to modify and cleared the pan and saved it to
C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\sqlworkbenchprojectitems\Sql
with file name SQLFile.sql
It worked thank so much!!
Thank’s brother! So, another question: I’d like convert all my tables, but there is a problem, I need convert a group of caracters, exemple:
dbo.SA1010 to dbo.SA1099, there are 500 tables. You can see, just 3 last caracter.
How can I do this?
Thank you. I’ve been using my virtual machine’s SQL Server Express for this exact reason for several days by now. I did a search just now, found your page, and your solution works like a charm. I wish I search this immediately. Thank you. :)
Now I can solve my problem. Thank you :)
doc. Thanks you !!!
thanks you