No Available Databases In A New Query In SSMS 2005
Mar 7, 2007
When I create a new query window in SSMS 2005 (SP2) , I do not have any available database in de SQL Editor pane. Though in the Object Explorer window below, I can access all objects of all databases. The only way to query a table is by using the 'Open Table' feature in the Object Explorer window, then right-click on Pane-->SQL .
I also can open a stored procedure, but not modify it as the SQL Editor pane is disabled.
The SQL-Editor pane is available for all the other servertypes (Analysis, Reporting, Integration).
All services all started.
I re-installed completely SQL2005 and SP2 : nothing changed.
What am I missing ???
Versions = Microsoft SQL Server Management Studio 9.00.3042.00
Suddently System Databases Folder is not showing on Studio 9.0 for all the SQL servers instance. Do you know why ? Is there any option other than De-attach them?
In MS Sql Server 2000, if you run a stored procedure that query's morethan 8 databases, you get this error gets raised:Maximum number of databases used for each query has been exceeded. Themaximum allowed is 8.In 2005, does this maximum number still exist? if so, is it still 8, orhas the number been increased?Thanks,Mike
We are running SQL 2005 Standard on Windows 2000 Server Standard. We are trying to connect via SSMS with the Object Explorer to the server and it is failing with an error message stating:
"An exception occurred while executing a Transact-SQL statement or batch.
Using profiler, I tracked down that it is a call to xp_instance_regread. This is something that SSMS is issuing - not me.
We've found in the past that rebooting the server fixes the problem. But it keeps cropping up. The only thing running on this server is SQL 2005 - so if something is monkeying with the registry - it's got to be SQL Server itself.
Querying works just fine - we can use the editor to perform queries without any issue - it's just explorer that goes kaboom.
We have SP2a installed on the server and on most (if not all) of the clients.
This is getting frustrating because it's a production server and we're having to reboot this to fix it.
Previous to 2012, grid results from SSMS queries pasted into Excel beautifully and were easy to format.in 2008, The results from this query pasted into a spreadsheet with the query contained in a single Excel cell:
(sample - not the whole script) select top 300 Avg_CPU_Time ,Total_Physical_Reads ,convert(datetime,Last_execution_time) as Timestamp ,Stored_Procedure ,Query_text from dbadmin.dbo.History_CPU_IO_ByQueryAndSP
This was wonderful. I could deliver to developers wonderfully tidy reports on query resource usage with timestamps along with which stored procedure the queries came from.
Can't do that in SSMS 2012. Try it. It's a disaster. The Query_text, when pasted, spreads across multiple Excel columns, including the ones designated for other data. The result is totally unreadable.how to make the query_text stay in it's own cell? I've tried converting query_text to varchar and ntext. Same results.
I have also posted this in microsoft.public.sqlserver.programming.
I have a query which, depending on where I run it from, will either take 10 milliseconds or 10 seconds.
The query works perfectly when run in SQL Server Management Studio... in my database of around 70,000 items it returns the results in around 10ms. It uses all my indexes and indexed views correctly.
However when I run the identical query from my ASP.NET application, it takes around 10 seconds... 1000 times longer. Looking at it in Sql Server Profiler I can't see any difference in the query, except from ASP.NET it needs 62531 reads and from SSMS it needs only 318 reads. If I copy the slow running ASP.NET query from the profiler into SSMS, then it runs quick again. The results returned are the same.
I have provided more details of the query below, but I guess my real question is: What is the best way to debug this? I'm not an expert with SQL Server, so any pointers on where I should start looking to find the difference in how the query is being executed would be a great help.
The query is of the form:
WITH RowPost AS ( SELECT ROW_NUMBER() OVER(ORDER BY DateCreated DESC) AS Row, ItemId, Title, .... FROM Items_View WITH(NOEXPAND) WHERE ItemX >= @minX AND ItemX <= @maxX AND ItemY >= @minY AND ItemY <= @maxY ) SELECT *, (SELECT Count(*) FROM RowPost) AS [Count] FROM RowPost WHERE Row >= @minRow AND Row < @maxRow
Where Items_View is an indexed view, and WITH(NOEXPAND) is being used to force it to use the indexed view (this is optimal). The line beginning "SELECT Count(*)" is to get the total number of results (without having to run the inner query a second time).
This is running against SQL Server Developer Edition.
Experiencing a little weirdness with SQL Server Management Studio...Have created a login, that has fixed server role "securityadmin".The login can create/drop logins, add/remove them as users indatabases, etc.The login can change another login's password, using SQLfrom a query window (e.g. alter login bob with password='abc')However, the login *cannot* change another login's password,using SSMS GUI (e.g. "Security", "Logins", double-click "Bob",change password, say "OK"). The error text is:Change password failed for Login 'Bob'. (Microsoft.SqlServer.Smo)Additional information:An exception occurred while executing a Transact-SQL statement orbatch.(Microsoft.SqlServer.ConnectionInfo)Cannot alter the login 'Bob', because it does not exist or you donot have permission.(Microsoft SQL Server, Error: 15151)Has anybody else experienced this?
The environment is Server 2008 32-bit, SQL 2012 SP2 Standard 32-bit (11.00.5058), and Visual Studio 10 SP1 (10.0.40219.1).
I have a query that begins with MERGE <tablename> USING (SELECT blah, blah, blah While in SSMS, I can parse the query with no issues. I can execute the query and see the results I expect. But when I put the same query into an Execute SQL Task in SSIS, it won't parse. It gives me one of those very informative messages that I so love - Query failed to parse. Incorrect syntax near the keyword "MERGE".
I don't know if the 32-bit/64-bit thing has any bearing or not, but I have taken the exact same project folder, copied it to a 64-bit box, and it works fine in both SSMS and SSIS. That one is running Server 2012 R2, SQL 2012 SP2 Standard (11.00.5343), and Visual Studio 10 SP1 (10.0.40219.1).
The value of one of the columns in my table is 14000 lines(678913 characters). The datatype of that column is varchar(MAX). I am doing the following select query but its truncating the results.
select value -- this is truncating the text. from dbo.GUISETTINGS
The length is shown as below when I do the query:
SELECT DATALENGTH(VALUE) from dbo.GUISETTINGS -- return 707951 as the length.
I even tried running the query below but still the value is getting truncated. However, if I right-click and select "Save Results As" a file, then it shows all the lines/characters fine.
select value, cast(value as text), cast(value as varchar(max)) from dbo.GUISETTINGS
I have installed SQL Server Management Studio 2005 and have beenfinding the equivalent of the Data Transfer Services in SQLServer2000. I think I have worked out that it is in SQL Server IntegrationServices but when I open File-New-Project I do not see the SQL ServerIntegration Services there, though Help assumes that it is availablefor selection when starting a new project..How can I make it visible in the New Project window?I have successfully used the import function so I think this meansthat Inegration Services is there somewhere.I would appreciate some advice,Best wishes, John Morgan
I've created an SSRS report in Visual Studio 2005 which runs fine in the preview. I have a list of server names which when clicked on expands to a list of databases on the chosen server. When I click on a database it then queries a table of information and displays information on that database. The query is something like:
SELECT * FROM MyDB.dbo.DB_info WHERE ServerName = @ServerName and DBname = @DBname
This works fine in preview mode. When I run it in SQL Management Studio via the Custom Reports menu it only works when the chosen server is the one that contains MyDB. I've run a trace and can see the query being issued when I use preview mode. However, when I run it from SSMS I don't see any query being issued to the database. This seems strange as it does return data in the instance described above and if I put MyDB into single-user mode it then complains that it can't access it so it is obviously trying to communicate with the database but not showing up on the trace. I've selected all events and only put a filter on the database name.
Seeing as all of the information is in the same table it seems odd that they query only works when the server name is the one where the database is held and that the query is not shown up in a trace. I'm running the report under the same credentials too.
I'm completely baffled by this so I'd be very grateful if someone could explain what might be happening here.
Okay, so I came across an odd performance issue that I'm wondering if some guru can help me out with.
I have a query that uses a paging algorithm that uses a paging algorithm and a table variable, then gets a page of data based on a join to that table variable. Here's a simplified query using the algoritm:
--declare table variable... not shown for brevity
--make sure we only store the least amount of records possible SET ROWCOUNT ( @pageNumber + 1 ) * @pageSize
--insert into table variable INSERT INTO @TableVariable( Key ) SELECT key FROM table WHERE whatever = @p1
--we only want one page of data SET ROWCOUNT @pageSize
--now get the page of data from the table SELECT key FROM table WHERE whatever = @p1 AND [TableVar Identity Column] > @pageNumber * @pageSize
The algorithm works great for our needs, BUT, I noticed something a little odd about its behavior during performance testing.
In particular, when I run the query using Sql Server Management Studio, where I manually DECLARE all the variables it ends up needing only 156 reads to complete the job. When I call it from the app using ADO.NET, however, I noticed it needs 310 reads! Huh?
I looked for differences, and the only one I could determine was that ADO.NET passes the query and uses sp_executesql and passes the parameters vs. declaring and setting them statically before executing the query. I confirmed that this was the issue by manually running sp_execute SQL and seeing that it took roughly the same number of reads (274) to process the query.
Naturally, I don't want the time it takes to perfrom my query to double, but and frankly I don't understand why there would be a difference in performance. Can anyone help me track down what is going on and suggest to me how to fix the problem.
I assume that SQL Server Management Studio optimizes the execution path somehow, but I'm not sure how to gain the same benefit for my passed query. Can I enable something with hints? Is there something else going on that I should know about?
I thought I saw this done once before. So today I hunted around inBooks OnLine and did a Google search. So far I have found nothingclose. So if you know how to do it, please tell me or if cannot bedone, I'd appreciate know that too.Thanks in advance,IanO
I have two queries yielding the same result that I wanted to compare for performance. I did enter both queries in one Mangement Studio query window and execute them as one batch with the actual query plan included.Query 1 took 8.2 seconds to complete and the query plan said that the cost was 21% of the batchQuery 2 took 2.3 seconds to complete and the query plan said that the cost was 79% of the batch.The queries were run on my local development machine. I was the only user. No other programs were running at the time of this test. The results are repeatable.I understand that the query with the lowest cost is not necessarily the fastest query. On the other hand, the difference is quite big. The query that has approx. 80% of the cost takes 20% of the time and the other way around. I have two questions:
Is such a discrepancy normal?Can conclusions be drawn from the cost distribution? For instance, does the query that takes 8.2 seconds but only costs 21% scale better?
is there a way to change SSMS 2012 default query save location?
Scenario:
1. Open SSMS 2. Create new query 3. Click Save
I see "DocumentsSQL Server Management Studio" folder, but I want to change it to be "d:". How do I do this? I tried:
1. [URL]- in folder "DocumentsSQL Server Management StudioSettingsSQL Server Management Studio" there is a file NewSettings.vssettings, setting it to "d:" or "d:" didn't work.
2. Changing HKEY_CURRENT_USERSoftwareMicrosoftMicrosoft SQL Server100ToolsShell VisualStudioProjectsLocation didn't work too. There is no "Shell" under "110Tools"
Did I do something wrong, or is there another way?
I just restored my SQL server 2000 database on the SQL server 2005. after this i ran the Service broker sample ("Hello World") on this database by changing the AdventureWorks name to the new database name. The "setup.sql" runs fine. When i run the "SendMessage.sql" i was not getting any rows in the output (The message was not getting inserted into the queue). I checked the Service broker is enabled on this databased using the query "select is_broker_enabled from sys.databases where name = 'newdbname' " It was 1. I even tried the ALTER DATABASE SET ENABLE_BROKER. but it didnt work.
When i tried the sample on a newly created database it worked fine.
Is there any solution to make the restored database to work for service broker.
Wonder if you could help. Am working in an environment where I have an output table in a new SQL db. The queries to populate and update this table reference tables in another db on the same server. So effectively, my SQL inserts and update join tables across databses. PROBLEM - they seem to take forever to run! Any ideas / experience with cross db joins queries???????
Help, don't quite understand, or more likely I've missed the point! Using VWD 2005 Express, I can create, manage/modify and SQL 2005 database aswell as maintain any data I enter into it. Fine, no problem there. However, when it comes to doing the same kind of thing with the database using MSSQL 2005 Management Studio Express, I remain mystified!? Any database I create above, through VWD 2005 Express, shows as being an attached DB in SQL MSExp and I'm able to detach and re-attach them. However, they are always attached as read only files so are unmodifiable!!! So... What is it I'm missing? What do I have to do to be able detach, attach, re-attach such databases in a modifiable form, ie NOT read-only Pulling my hair out over this one, so any advice gratefully rec'd Thanks in anticipation.......!!!
I recently upgraded from SQL Server 2000 to 2005 in our test environment. In 2000 I used Enterprise Manager to view my databases, users etc. but where can I see my databases in 2005?
I've put together the following query, but it has been unsuccessful running it so far.
Code:
select * from Contractors.dbo.Contacts where VendorNo in (select No_ from [BMIS Live Database].dbo.[BMIS Live Database$Vendor] where [Name] like '%of%')
I receive the following error when I run it in Query Analyzer:
Code:
Server: Msg 446, Level 16, State 9, Line 1 Cannot resolve collation conflict for equal to operation.
I'm trying to grab values from the column, "No_" in the Bmis.. database then only select data from the Contractors database if the VendorNo column holds one of the values grabbed from the Bmis.. database. I think my syntax is just completely wrong but hopefully someone might pick up on my mistakes. Any help would be greatly appreciated, thanks!
We are having atleast 7 - 8 servers in SQL Server 2000 and 2005 and each constituting around 2- to 30 databases and each database consists with a column related to date format.
We have problem in checking the LEAP YEAR significance in each and every database of every table to verify as there is no problem with the FEBRUARY 29th, to comply with.
I need to check the query which will do for all the databases and their in-built tables.
Can anyone one help me in this regard to check the above criteria.
On this server I have a few databases. I need to run the below query against each database. Since the server has approx 50 databases this will take time.
Is there any way for me to modify this so as it will automatically run against each database one at a time and then create a single output file with all the results.
I do not want it to run against all of the databases at the same time as it will kill my server so it must run and gather results on each database at a time.
QUERY to be run
SELECT RelativeFileName
FROM Collection, Saveset
WHERE Collection.CollectionIdentity = Saveset.CollectionIdentity
Hello all, Can anyone please tell me what query to use for joining two tables in two databases together?
Basically, we have two databases called 'system' and 'site' respectively. The 'system' database has a table called 'users' and each user has a unique id which is also linked to the tables in the 'site' database.
The only problem i have got is, I want to be able to get the actual user names not the unique id and the only way to get this from my SQL statement is to be able to link the uniqueid for each user in the 'site' database to their corresponding uniqueid in the 'system' database.
We have adedicated MS-SQL Server for our CRM database and we have another MS-SQL database server for in house applications, written in c#.Net 2.0. To avoid duplicating information already in our CRM database, it would be nice if we could build a query that combined columns from both data sources.Example
Code Snippet
CRM database on Server1 Table Accounts
Columns AccountID UniqueIdentifier Primary Key
Name NvarChar(50)
Application Database on Server2 Table Transaction
Columns
TransactionID UniqueIdentifier Primary Key
AccountID UniqueIdentifier Amount Money
Would it be possible to create a T-SQL statement that will select
From Server1.CRM.Accounts INNER JOIN Server2.Application.Transaction
ON (Server1.CRM.Accounts.AccountID = Server2.CRM.Transaction.AccountID)
I appreciate there will need to be 2 connections and therefore some credential information would need to be passed too.
Is anything like this possible? I do not wish to copy the Name field from Server1.CRM.Accounts to Server2..Application.Transaction as this is duplication and any change to the value of Server1.CRM.Accounts.Name would not be reflected in the results.