Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL file encoding in Visual Studio

When we create stored procedures in Visual Studio (with the extension .sql) the file encoding is automatically set to 'Unicode (UTF-8 with signature) - Codepage 65001'.

This causes ours DBA's problems as their scripts don't like it.

We have to manually go in and change them to 'Western European (windows) - Codepage 1252'.

This only seems to be happening since we upgraded to VS 2008 from 2005. Can anyone explain whats going on and how to stop it?

like image 587
Simon Keep Avatar asked Sep 05 '08 08:09

Simon Keep


People also ask

How do I change the encoding of a file in Visual Studio?

From the File menu, choose Save File As, and then click the drop-down button next to the Save button. The Advanced Save Options dialog box is displayed. Under Encoding, select the encoding to use for the file.

How do I change the encoding of a SQL file?

Resave using correct encoding: File => Save As. Click the arrow next to the Save button. Choose the relevant encoding: Unicode (UTF-8 with asignature) - Codepage 65001.

How do I run a .SQL file in Visual Studio?

In Visual Studio Code, press Ctrl+Shift+P (or F1) to open the Command Palette. Select MS SQL:Connect and choose Enter.


2 Answers

To summarise the link provided by Codeslayer (in case the page url changes)...

Change the sql file templates to ANSI encoding by opening with notepad and then saving it as an ANSI file. You can do the same for files already created. \Common7\Tools\Templates\Database Project Items

You've just made our DBA's very happy!

like image 141
Simon Keep Avatar answered Oct 07 '22 02:10

Simon Keep


I think somebody faced a similar problem like yours and had the following workaround which is posted at

http://connect.microsoft.com/VisualStudio/feedback/Workaround.aspx?FeedbackID=319830

like image 34
Codeslayer Avatar answered Oct 07 '22 01:10

Codeslayer