this thing has a mind of it's own. it keeps switching the active database so that unless you're *really* careful, you can end up running a script against a database other than the one you think you are!!!!! grrrrrr
- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
sql server management studio
Collapse
X
-
-
-
Originally posted by JoJoGabor View PostJust put the statement at the start of the script:
use "dbname"Comment
-
when you click on new query (or hit control-N) it will open a session to which ever database you are currently connected to. This is not constrained to the query windows.
So if you were browsing the live system in the object explorer tree and the window focus was on there then SSMS will open a DB connection to the Live database.
Once you understand the behaviour you'll realise its not just switching... its doing what it is supposed to do and it does it very consitantly.
As JoJoGabor pointed out though - adding the use <dbname> will make sure your scripts are always diverted to the correct database (unless your running a partial section of the query by highlighting then executing)Coffee's for closersComment
-
"it will open a session to which ever database you are currently connected to"
hmmmm..in theory, yes. i still think my copy of ssm studio has an attitude problem though.
"use "dbname""
i know, i know. i ought to do this but sometimes....you just want to be productive and get on with things...something about haste and speed comes to mindComment
-
Originally posted by scotspine View Post"it will open a session to which ever database you are currently connected to"
hmmmm..in theory, yes. i still think my copy of ssm studio has an attitude problem though.
see which db you are connected to
then with the query window active click new query
see which db you are connected to
select a different db in the object explorer and click new query (whilst the object explorer window is still maintaining the application focus)
again see which db you are connected toCoffee's for closersComment
-
If you know knew the amount of times I ran queries against "Master" by mistake on my home system because of the switching
Luckily have policy at work to always use "Use DBName"Comment
-
its not magically "switching" you just don't know how to use it!
The behaviour is perfectly consitant, predictable and documentedCoffee's for closersComment
-
Originally posted by Spacecadet View Post
its not magically "switching" you just don't know how to use it!Comment
-
Originally posted by scotspine View Postit sounds as though you've read the manual???
Seriously though, Query Analyser in Sql Server 2000 behaved exactly the same way and this behaviour was carried through to 2005 and 2008
Don't know about version 7 - I only ever did some basic admin work on thatCoffee's for closersComment
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- Streamline Your Retirement with iSIPP: A Solution for Contractor Pensions Sep 1 09:13
- Making the most of pension lump sums: overview for contractors Sep 1 08:36
- Umbrella company tribunal cases are opening up; are your wages subject to unlawful deductions, too? Aug 31 08:38
- Contractors, relabelling 'labour' as 'services' to appear 'fully contracted out' won't dupe IR35 inspectors Aug 31 08:30
- How often does HMRC check tax returns? Aug 30 08:27
- Work-life balance as an IT contractor: 5 top tips from a tech recruiter Aug 30 08:20
- Autumn Statement 2023 tipped to prioritise mental health, in a boost for UK workplaces Aug 29 08:33
- Final reminder for contractors to respond to the umbrella consultation (closing today) Aug 29 08:09
- Top 5 most in demand cyber security contract roles Aug 25 08:38
- Changes to the right to request flexible working are incoming, but how will contractors be affected? Aug 24 08:25
Comment