SQL file encoding in Visual Studio - sql

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?

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!

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

For Visual Studio 2010, there is another set of files you need to update:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VSTSDB\Extensions\SqlServer\Items

Related

Using / Saving / Exporting SQL Server 2014 database to be used with VS 2013

I have created a database in SQL Server 2014 but I don't see it in Visual Studio 2013. I've been trying to figure this out for days to no avail. How can I use the database I created in SSMS in VS 2013? or how can I export it to be used in VS 13?
If I try to open the database from SSMS data folder I get an error. "you don't have permission ..."
But if I copy the .mdf file somewhere else and try to open it I get this error:
db cannot be opened because it is version 782. This server supports version 706 and earlier. a downgrade path is not supported
Any help would really be very much appreciated.
Thanks
Do you have the most recent version of SQL Server Data Tools (https://msdn.microsoft.com/en-us/data/tools.aspx)? I believe it's been updated since initial release to support SQL 2014.
Thank you all. I will leave the db alone where it is. I have SSMS 2014 and vs 2013. I thankfully did the following
" Try changing Tools>Options>Data Connections>Database Tools>Data Connections>SQL Server Instance Name. The default for VS2013 is "(LocalDB)\v11.0". Changing to "(LocalDB)\MSSQLLocalDB", for example, seems to work - no more version 782 error."
As from the above link(answer) posted by user1723033 and VikciaR and all is working for now.
Thanks again for your help.

Change the default save location for SQL Management Studio 2008 [duplicate]

This question already has answers here:
Management Studio default file save location
(16 answers)
Closed 8 years ago.
As the title states, how do I do this?
I want to hit save, and have SSMS automatically direct me to a network folder..
This is 3 years old now, but an answer for SSMS 2012 and 2014 would be helpful, so I thought I'd add an update. Step one differs between the versions, and then the rest is the same:
SSMS 2012
Locate C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Extensions\Application
SSMS 2014
Locate C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\Extensions\Application
Both (continued)
Open ssms.application.pkgdef with text editor(e.g. Notepad)
Change the value of DefaultProjectsLocation
"DefaultProjectsLocation"="$MyDocuments$\SQL Server Management Studio"
Save the file
Thanks to this source: http://www.networksteve.com/forum/topic.php/How_to_change_the_default_query_save_location_in_SSMS/?TopicId=41425&Posts=0
The correct location for 2k8 in the registry is HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server\100\Tools\Shell.
It's not editable from within the tool (for some reason), but you can adjust it from the settings file within My Documents > SQL Server Management Studio > Settings.
Look for the node "ProjectsLocation", and adjust accordingly -
<PropertyValue name="ProjectsLocation">\\mynetworkpath</PropertyValue>
Be sure to exit SSMS before editing this file. This should do the trick...
#Kevin's solution doesn't work for SQL 2k8. One needs to change the registry:
key = HKEY_Current_User\Microsoft\Microsoft SQL Server\100\Tools\Shell
Now see where they wrote the default path... change that into any valid UNC.
This seems to work for me after a lot of bungling -
Edit registry settings as outlined in above posts (HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server\100\Tools\Shell) - change all the paths EXCEPT MyDocumentsLocation (this is what seems to cause the settings to get reset).
Locate the .vssettings file from My Documents and copy to your folder + '/Settings' folder (e.g. c:\Dox\SQL Server Management Studio\Settings).
Start SQL studio, quit and restart.
Edit the .vssettings file (should be in your folder now rather than My Documents), and change the ProjectsLocation to the desired folder e.g. C:\Dox\SQL Server Management Studio\Projects
Start SQL studio. Opening files should now work, but save will require clicking the 'My Projects' on the left of the save dialog.

convert rdl to rdlc?

I am using visual studio 2008 and reporting service 2008.
I created a .rdl reports. Now I want to convert .rdl to .rdlc. How can I do it?
Good question. According to spec whey should be more or less the same, but in reality they differ wildly depending on version. For instance if I open an RDLC file I created in Visual Studio 2010 in Report Builder 3.0 it works. But if I make a change in my RDL(C) file and try to open it in VS2010 I first get asked if I want to convert it to RDLC 2008 format (yes) and then I get the error message "The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition' which cannot be upgraded."
There is nothing to convert. All you have to do is to rename the file to .rdlc. This converts it from a server report to a client report. The underlying schema is the same, whether it's an .rdl or .rdlc file.
Take a look at FAQ #8 here: http://www.gotreportviewer.com/
I found working with MS support that converting an RDL to RDLC merely by changing the extensions results in a ReportViewer Control HTTPHandler error which is shown with a style of "dsiplay:none". It accuses the developer of not including the HTTPHandler in the web.config, when it is actually in the web.config. Using an rdlc created by VS in that project, then the reportviewer opens just fine and properly displays. MS support and I are still researching what other changes need to be made, but as of now, I can let people know not to drink the MSDN Kool-Aid.
I also tried changing the schemas namespace in the XML file and I got the same report definition cited above.

SQL Server: How to open .PRC files?

I have old .prc files (SQL Server Stored Procedures) which have exported from SQL Server 2000. Now when I try to open a .prc file using SSMS 2008, I get a bunch of chinese characters and other odd characters. I tried a solution found here, but it did not help.
Can you open the files in a regular text editor, e.g. Notepad or something??
As far as I remember, the SQL Server 2000 tools used to use ANSI / ISO-8869-1 encoding for their files, while newer Mgmt Studio version expect UTF-8 or UTF-16.
So my suggestion would be to open those *.PRC files in an editor and store them as *.SQL files using UTF-8 encoding. After that you should be able to open them in SSMS 2008 without problems.
Once I'd added PRC and UDF suffixes, ssms still ignored the changes if I used "recent files" to re-open the file was I working on.
I had to use File->Open to pick up the new suffixes. Thereafter "recent files" worked.

Editing SQL query with Visual Studio 2008

Would you recommend me the best approach to edit SQL query with Visual Studio 2008 Professional, please?
I know I can open Query window from context menu in Server Explorer and edit text in SQL Pane. But unfortunately I am not allowed to save query to a file and Find and Replace commands are not working there.
Alternatively I can open text file with extension .SQL in Visual Studio editor obtaining syntax highlighting and full editing capabilities but losing possibility to execute the script.
Now I copy query text from one window to another and back but I hope there is better solution.
Many thanks for suggestions!
When I have to connect to Sql Server, I use NetBeans, as it has a number of features that make it much easier to use than Visual Studio. One of these is intellisense, which is very useful when you have an alias for a table name and lots of long field names. The general handling of connections and connection pools is also much cleaner in NetBeans. I could go on, but suggest trying it for yourself. You will almost certainly need the Sql Server jdbc driver, which can be downloaded from http://msdn.microsoft.com/en-us/data/aa937724.aspx
If you create a Database project within your solution in Visual Studio, then you can set up a default database connection for that project. Then any *.sql files that are included in the database project can be executed against that connection. What I usually do is select the text to be exectued and right-click it, then select "Run Selection".
You can set up any number of database connections under the "Database References" node in the solution explorer, and choose the one you want to run your query against.
Wow you are right, this is a real pain. Would it be acceptable for you to use a local copy of the SQL Management Studio (the name might be wrong)? You would be outside of VS but you could still edit your query and run it at the same time. Definitely not optimal but better than nothing.
Good luck.