About 347,000 results
Open links in new tab
  1. In SQL Server, like "use <<DatabaseName>>", how to "use …

    Oct 30, 2019 · SQL Server - copntrary to some other databases - always handles connections on a server (instance) level, the database is just the "default" database for a statement (you can …

  2. sql server - sql use statement with variable - Stack Overflow

    It appears SSMS validates the existence of the database for all USE statements in the script, even if those lines aren't executed. I was trying a variant of: IF @@SERVERNAME = …

  3. sql server - How can I do something like: USE @databaseName

    Sep 24, 2010 · The fundamental architecture flaw here is in SQL server's inability to easily access different databases at runtime in a simple and safe way, instead forcing us to use dynamic sql …

  4. sql server - Use database inside a stored procedure - Stack Overflow

    Nov 17, 2011 · I need to make a stored procedure which creates a user in more than one database. Something like this: USE [database1] CREATE USER [userLogin] FOR LOGIN …

  5. specify server in sql script - Stack Overflow

    use [my_database] As I have different environments where the same database exists, eg dev, qa, prod, is there any way I can specify in the script the environment the script is for, either by …

  6. SQL-Server: Error - Exclusive access could not be obtained …

    Dec 17, 2019 · the database is in use. Msg 3013, Level 16, State 1, Line 3 RESTORE DATABASE is terminating abnormally. How do I fix this problem ? IF …

  7. sql - EXEC to USE Database - Stack Overflow

    Sep 2, 2014 · I then need to USE that database, in the script, and then disable all triggers. However, this doesn't work: DECLARE @Use VARCHAR(50) SET @Use = 'USE ' + …

  8. sql server - How to Dynamically change the database using TSQL ...

    Sep 4, 2017 · I'm having trouble with trying to dynamically change the context of SSMS to the database specified in dynamic SQL: EXEC sys.sp_executesql N'USE db1 ' ; It executes …

  9. sql server - Using variable for database name - Database …

    Jul 13, 2015 · I am having difficulty in using a variable name for the database. The below script searches through all databases and finds database that match a certain condition. The …

  10. Selecting data from two different servers in SQL Server

    Jul 17, 2009 · How can I select data in the same query from two different databases that are on two different servers in SQL Server?