Is it possible to access the queries in a file created by SQL Server? - sql-server

Is it possible to access the queries and procedures in a file created by SQL Server without installing SQL Server? Problem is that I am having problems to install the SQL server / Express version.

When all else fails - always try to open files in notepad and see what happens.
In this case, .sql files definitely can be opened with notepad - they are just text files. The extension is just there to give you the ability to double-click on them and by default open in Management Studio (or whatever you want to use to edit SQL files).

Related

How to import MSSQL database dump from Plesk into local MS SQL server?

I have a plesk account and an MS SQL database from which I got a dump through this interface they provide:
So I downloaded the dump file but it does not come as a .txt file but it comes without any extension and when I try to import it in my local MS SQL Server it fails always.
And when I try to open the dump file with notepad it shows weird characters(see picture below).
What am I doing wrong?
I got it to work by extracting the dump file from the zip and renaming it with a .bak extension. Then did a Database restore in MS SQL Management Studio and selected this backup file (.bak). Hope that helps.
I finally found my way using a php script found on github I had to fork it to update couple things cause it became obsolete.
I had to go this way for couple reasons:
I didn't have admin access to the plesk server to enable remote DB access
I wasn't able to export it into any format readable by mysql
So with the php script i could load it unto the server and run it,
The script copies an MSSQL into MySQL. Here is my fork.

Remove headers from CSV export in SSRS/VS Designer

I'm not sure where to ask this question. I've been all over the web looking for an answer.
I'm trying to export a report as pipe delimited and without headers. I've found several discussions about how to change the config file on the server. But I'm not there yet.
I'm on my local machine. I'm running VS 2015 (14.0.25431.01 Update 3). It has SQL Server Reporting Services (14.0.806.134) installed. I can create a report as a Report Server Project. When I preview the report then go to export (not deploy) it as CSV the resulting file has headers. I need to remove those headers.
Some say I need to edit the config file rsreportserver.config
For example, "Open rsreportserver.config file under C:\Program Files\Microsoft SQL Server{INSTANCE}\Reporting Services\ReportServer in reporting server."
Why would it be under SQL Server folder? Do I need a SQL Server installed/running to make VS work? I don't think so. What if I have more than one server installed locally? Nothing in my VS setup indicates what server to use. So how would VS ever find this file?
I did find rsreportserver.config in 2 places under a local instance of SQL Server 2016 Developer. Changing these did not affect the VS output. I didn't expect it to since VS knows nothing about any servers until I make some explicit connection.
My question is how can I configure VS Reporting Services Report Designer to create a pipe delimited, no header export?

How to import .sql file into SQL Server Express

I have a plain sql file with some SQL INSERT statements.
Is it possible to import it in my local SQL Server Express instance?
You can use Management Studio Express edition. You can download the latest version here - which will work against SQL Express 2005, 2008 and 2008 R2.
If you don't want to install SSMSE then you can use sqlcmd at a command prompt, e.g. something like this (assuming Windows auth and an instance called "SQLEXPRESS"):
sqlcmd -S .\SQLEXPRESS -E -i "C:\path\file.sql"
The easiest way would be simply open the file in the Sql Management Studio and run it. Since the target table is already created, of course.
You can open it via Query analyser and run
Here is the tool Sql_Server_Script_Executor
You can add single/multiple file/folder and your files will comes up in the list. Click the execute button and done
It contains three transaction modes.
1. Execute scripts within one transaction
2. Execute scripts on separate transaction
3. No transaction
All you have to do is open Microsoft SQL Server 2008 Management Studio.
Then use File -> Open.
Open the file from the proper location and you'll get all the SQL statements there. After that you can execute them.
Hope this helps.

sql server mdf file database attachment

I'm having a bear of a time getting visual studio 2010 (ultimate I think) to properly attach to my database. It was moved from it's original spot to #MYAPP#/#MYAPP#.Web/App_Data/#MDF_FILE#.mdf. I have three instances of SQL Server running on this machine. I have tried to replace the old mdf file with my new one and cannot get the connectionstring right for it.
What I'm really trying to do is to just open a DB instance and run a DB create script. Then I can have a DB that was generated via my edmx (generate database from model) in Silverlight business application (c#)
Right now, when I go to Server Explorer in VS, choose add new connection, choose MS SQL Server Database File (SqlClient), choose my file location (app_data directory), use Windows authentication, and hit the Test Connection button, I get the following error:
Unable to open the physical file "". Operating system error 5: "5(Access Denied.)". An attempt to attach to an auto-named database for file"" failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
The mdf file was created on the same machine by
Connecting to (local) in SQL Server management studio.
Getting a new query.
Pasting in the SQL from the generated ddl file.
Adding CREATE DATABASE [NcrCarDatabase]; GO; before the pasted SQL and
Executing the query.
I then
Disconnected from the DB in Management Studio.
Closed Management Studio
Navigated to the DATA directory for that instance
Copied the mdf and ldf files to my application's app_data folder.
I am now trying to connect to the same file inside visual studio.
I hope that gives more clarity to my problems :).
Connection string is:
Data
Source=.\SQLEXPRESS;AttachDbFilename=C:\SourceCode\NcrCarDatabase\NcrCarDatabase.Web\App_Data\NcrCarDatabase.mdf;Integrated
Security=True;Connect Timeout=30;User
Instance=True
I was getting "access denied" until I ran Visual Studio as an administrator. I then had to detach the database from MSSMS before I could get it into Visual Studio.
You mentioned that your MDF file was moved. Was the MDF properly attached to SQL Express after the move? See: How to: Attach a Database File to SQL Server Express.
Access denied might well mean that you already have an active instance that has opened the file prior to you doing it - and if you have three active instances, it is likely one of them that is the culprit.
You can try to connect to the different instances with Management Studio and see if you can find the base there. If yes, the detach it from the instance and re-try from Visual Studio. Or, if possible, try to shut down all three instances and then re-try from Visual Studio. If that works, restart the instances one by one to determine which of them is trying to get the file.
I've previously answered a similar question that might help.
Your Sql server service runs under a given account. You should determine the account through the service properties then change the db file security access to full access for that account.
Give Security to Full control for your application Folder and .mdf, .ldf files. Write click on the folder which contains .mdf,.ldf files
Go to property
click security in that
Click Full Control in allow.
and them proceed your process.

How to view installed Northwind database?

I have installed a sample database, specifically Northwind from http://msdn.microsoft.com/en-us/library/8b6y4c7s.aspx.
After installing the .msi file, I dont see any Northwind database in my local sql express server when using SQL Server management studio. Am i missing a step? Do i have to run some script?
From the download page:
After downloading SQL2000SampleDb.msi, extract the sample database scripts by
double-clicking SQL2000SampleDb.msi. SQL2000SampleDb.msi will extract the
database scripts and this readme file into this
default folder:
C:\SQL Server 2000 Sample Databases
So it seems to me you have to go to that folder and execute the SQL files installed there for the database to be created.
you don't mention which msi file, but most of them seem to relate to a sample database.
Which database software are you using?
From the download page on the page you linked to:
After downloading SQL2000SampleDb.msi,
extract the sample database scripts by
double-clicking SQL2000SampleDb.msi.
SQL2000SampleDb.msi will extract the
database scripts and this readme file
into this default folder: C:\SQL
Server 2000 Sample Databases
I didn't download it to see what gets extracted, but I'm betting there's a script or two that you can run to create the database. Probably a *.sql, that you can open and run in a query window.
EDIT: I just downloaded and extracted. It looks like all you need to do is execute the contents of instnwnd.sql (which should be in C:\SQL Server 2000 Sample Databases). Open a new query window (in SSMS etc.), load the file, and press F5.

Resources