How to import a . sql extension file into SQL Server 2014?

Asked

Viewed 251 times

-1

I received a file that it has the . sql extension, so every time I import something into sql server is from .bak. Is it possible to do this? If yes, how?

1 answer

1


Files . sql normally contain SQL statements. These files, unlike . Bak are not imported, but "run" for example using SQL Server Management Studio (SSMS).

Heed that the file may contain indiscriminate SQL which can be quite dangerous if it is not certain of its origin. I always suggest that you check your content before trying to run it.

With SSMS you can simply do:

- Iniciar o SQL Server Management Studio
- Efectuar a coneção à base de dados
- Ficheiro > Abrir > Seleccionar o ficheiro .sql
- Executar (F5)

If the file is abnormally large (more than 50/100MB), you can use the sqlcmd, that it is a tool that is usually installed with SQL Server and that allows the execution of SQL statements through various forms. One of which allows the execution of SQL statements stored in a file.

Here is an example of use:

sqlcmd -S NOME_SERVIDOR\INSTANCIA -i C:\caminho\para\ficheiro.sql -o C:\caminho\ficheiro_saida.txt

The output will be stored in the output file.txt.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.