Where is my all procedures, etc. from SQL Server? - sql-server

I guess this or similar question was asked, but can not find one such.
Where are stored on my computer (automatically if you do not specify otherwise) all procedures and scripts that I wrote?
And if I am doing a new installation on the computer what the simplest and safest recover for everything?
Thanks

If you saved any files in SQL Server Management Studio and used default path then your saved scripts are in "C:\Users\**YourWindowsLoginName**\Documents\SQL Server Management Studio\"
If you created your stored procedures in a database you have to remember in which database you've created these them and on which server.
If you did it on another server, they might be still there, you just have to ask somebody, who knows more about SQL Server on how to connect to that server and how to get access to the database you've used.
If you used SQL Server on your local PC, then Database files might also be still there. Search your Drive C:\ for files with extension ".mdf" and ".ldf".
Most probably they are stored in the default location: "C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\" - That location for SQL 2014, but it might give you an idea where to search for.
PLEASE keep us posted if you find these Stored procedures, everybody have to know where to search it next time if anybody lost them. Help everybody else as I help you.
Thanks.

By default, SQL Server Management Studio will save queries to "C:\Users(windows log in username)\Documents\SQL Server Management Studio" and they should be saved as .sql
This is by default even with a new installation. So if you upgrade, or uninstall and/or reinstall a new version the folder and the scripts should still be there. I did this when I uninstalled SSMS and reinstalled to another drive on my machine.

Related

Sql management Studio 2014 crashed + backup databases before reinstall

I have installed sql server 2014 standard edition on windows server 2012R2, it was working fine. but after few days i try to open management studio but it says cannot find one or more components try reinstalling the application. i have seen many solution for recovery and reinstalling but my first concern is data backup. as its a live system i dont want to lose any data. can any one tell so surely that how i can backup data and recover management studio. are there any files which need to be copied and can be replaced after reinstalling. i will be thankful if some one can give sure answer. Again remember its a live system i cannot lose any data. Thanks
I hope that SQL services are still online, you can take backup using sqlcmd and try to repair the management studio.
example.
SqlCmd -E -S Server_Name –Q “BACKUP DATABASE [Name_of_Database] TO DISK=’X:PathToBackupLocation[Name_of_Database].bak'”

Adventureworks restore failed

I've just installed MS SQL Server Express 2014 and SQL Server Management Studio 2014 under Windows 10. I'm following the official Microsoft tutorial on database fundamentals, which uses the Adventureworks DW2008 database. I have tried to restore this dB using the Restore GUI, but it fails every time, as shown here:
AdventureWorks restore failure
I have verified the backup media, but it still fails. I have also restored a different dB, and that worked fine, so I know I am following the correct procedure. I have the file (AdventureworksDW2008Big.bak) in the following location:
C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\Backup
Yes, I have thoroughly researched this, but still apologies if there is already an answer on here - I couldn't find it.
The DW in the filename is for Data Warehouse and only works on that edition of SQL Server. As you only installed SQL Express you cannot use it.
Why not try Adventure Works 2014 Full Database Backup.zip instead. If you really need 2008/R2 try the none-DW from here:
AdventureWorks2008R2_Database.zip
AdventureWorks2008_Database.zip
I do not know if it will solve your problem or not,
but I had same problem. I mean I am using SQL SERVER 2017 and I wanted to restore AdventureWorks2012.
I received restore failed error, and I decided to restore AdventureWorks2017. my queries on AdventureWorks2012 in an older system in university led to the same results as my queries in AdventureWorks2017 in my system. if you are using a version of SQL SERVER and trying to restore an older or another version of AdventureWorks, you can try the same way.
I mean restoring a version of AdventureWorks which is the same as the version of your SQL SERVER.
Best to run SSMS as an administrator to avoid access denied errors (do this by right click on SSMS and choose More -> administrator)
copy adventureworksxx.bak into the sql server DATA directory where by
default all databases are usually located. ( Note: if it is in other directory
the restore may not find it OR may cause errors later)
Restore the database

Can I use a SQL Server project to create/manage a LocalDB file?

I'm new to SQLServer and related Visual Studio tools though I know SQL well.
I want to have a local test DB on my dev PC with some stored procedures (so it needs to be SQL Server not SQLLite). LocalDB seems the answer and I can create a LocalDB MDF file through Server Explorer. But I don't think I can/should be putting an MDF file in version control - other developers need to have this DB for their local testing too.
I feel like the Visual Studio SQL Server Project type is what I'm after here but I don't see how such a project is linked to an actual DB. In my mind I imagine setting up a SQLServer project in VS, adding tables/stored procs/etc, and this will automatically build a LocalDB MDF file.
I'm unsure how thee things hang together and where the files all go, can someone help clarify this?
I'm basically starting from the point: I have a SLN with my C# projects in. My C# code calls certain stored procedures using a connections string from configuration but no DB actually exists in the wild yet. Any developer ideally needs a dummy DB to be created when they build the code, not have to create it manually, without installing SQLServer.
So it seems like I want to create a SQLServer Project in my solution, which will magically create a LocalDB. Is that feasible/correct?
Do you need to use Visual Studio at all, would SSMS not meet the requirements if you only want to execute some stored procedures? SQL Server Express is free, it's just limited on size, I believe that the SQL developers edition is free as of pretty recently, may be worth looking into.
I've got a couple of installations of SQL Server on Hyper-V Virtual machines too for testing purposes, this could be an option.

Restore SQL Server database from a script

I have a database stored on SQL Server with my web site at a regular windows hosting solution. I need to migrate to Azure.
The only backup mean I have is to use SQL Server Management Studio and do a Task -> Generate scripts that saves schema and data in a sql file. I did it and I got a 260Mb file.
My question is about importing that to Azure. Can I do it in Mngt Studio too? How?
Thanks
If you have exported it all to scripts, yes, you can run them against your SQL Database. However, before you do that I'd suggest looking at https://azure.microsoft.com/en-us/documentation/articles/sql-database-cloud-migrate/. It might shed some light on other options that will include verifying compatibility. The BacPac method might be better than the scripts.
To answer the specific question of using SSMS with Azure SQL DB, this article https://azure.microsoft.com/en-us/documentation/articles/sql-database-manage-azure-ssms/ shows how to make the connection.

Uninstalling SQL Server 2012

I need to uninstall SQL Server 2012 on computer with Windows Server 2008, but I need to leave all existing databases. In other words, I need to remove SQL Server, but without deleting all data. How could I manage that? Also, where should be all databases phisically(.mdf files)?
Unless you have or can take backups then you could:
Shut down your database instance using SQL Server Configuration
Manager.
Find where your database files are located and copy these safely
somewhere.
At this point you could try mounting these on an alternative (test) SQL
Server (using the SQL Server 'Attach Database'). This will give you
confidence that the re-install will work on whatever SQL Version you
are planning to move them to.
Then as others have stated, uninstall SQL Server
Reinstall
Re-attach
NOTE - this does not preserve instance level security, so you will need to script out any special security settings for these databases and then re-import it back in (See https://dba.stackexchange.com/questions/58772/how-to-export-all-the-security-related-information-from-a-sql-server-database).
Detach Databases ,keep Database files , run controlpanel program and feature and unistall it.

Resources