Use other SQL Server Databases

Jose Rodriguez's Avatar

Jose Rodriguez

18 Jun, 2014 11:54 AM

I have I library that creates and drops databases on the fly and for obvious reasons I cannot drop the master database.
Is it possible to connect to a different database in the server?

Thanks!

  1. 1 Posted by Rob Morgan on 18 Jun, 2014 02:07 PM

    Rob Morgan's Avatar

    We are using this command at the moment. I think I just need to tweak a few parameters to make it work:

    sqlcmd -U sa -P Password12! -Q "create database phinxtesting;GO;"
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: Could not open a connection to SQL Server [2]. .
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
    
  2. Support Staff 2 Posted by Feodor Fitsner on 18 Jun, 2014 05:29 PM

    Feodor Fitsner's Avatar

    That's right you can drop and create any databases as you have admin access on build worker.

    @Rob I think you are missing SQL instance name in your script. Also, make sure SQL Server service is enabled on Environment tab of project settings.

    More info: http://www.appveyor.com/docs/services-databases

  3. 3 Posted by Rob Morgan on 19 Jun, 2014 09:47 AM

    Rob Morgan's Avatar

    I am trying this now, still not working but I think we're almost there!! Any tips?

    sqlcmd -S ".\SQL2008R2SP2" -U sa -P Password12! -Q "create database phinxtesting;"
    8Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. .
    9Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
    10Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
    

    Cheers,

    Rob

  4. Support Staff 4 Posted by Feodor Fitsner on 19 Jun, 2014 05:33 PM

    Feodor Fitsner's Avatar

    Make sure SQL Server service is enabled on Environment tab of project settings (or in YML if you use it).

  5. 5 Posted by Rob Morgan on 20 Jun, 2014 09:42 AM

    Rob Morgan's Avatar

    Ok Guys, I cracked it. The problem was the order or execution, MSSQL hadn't started when I was trying to create the DB.

  6. Support Staff 6 Posted by Feodor Fitsner on 20 Jun, 2014 07:21 PM

    Feodor Fitsner's Avatar

    Great, thanks for the update!

    - Feodor

  7. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 01:45 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac