ssms

SQL Management Studio won't recognize a table exists after scripted create

孤者浪人 提交于 2019-11-30 00:18:59
So if I create a new table in the query editor in SQL Management Studio after hitting refresh on the DB I can see and work with that table. However if I want to run another query referencign that table from withen the query editor it doesn't reconize that table exists. I've tried hitting refresh at the DB level, and the table level but it makes no difference. However if I quit the management studio then reopen it shows up fine. USE [DataBaseName] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[States]( [StateAbbreviation] [nchar](2) NOT NULL, [StateFullName] [nchar](30)

Convert SSMS .rpt output file to .txt/.csv

旧时模样 提交于 2019-11-30 00:18:50
I want to export my big SSMS (SQL Server Management Studio) query result (2.5m lines, 9 fields) as .csv or comma-delimited .txt (with headings). (MS SQL Server 2005 Management Studio.) So that I can then either read it line-by-line into VBA program (to do certain calculations on the data) or do queries on it in Excel (e.g. with Microsoft Query). The calculations are complicated and I prefer to do it somewhere else than SSMS. If I choose ‘query result to text’ in SSMS and a small answer (few lines e.g. up to 200k) I could of course simply copy and paste to a text editor. For my large answer

How do I view executed queries within SQL Server Management Studio?

吃可爱长大的小学妹 提交于 2019-11-30 00:01:12
I am new to SQL Server Management Studio and am wondering: is there is a way to see which queries have been run against a database? In the Activity monitor, there is a "Recent Expensive Queries" report but I'm guessing that isn't all of the queries since I'm not seeing the ones I have run. I am running SQL Server Express 2008 v 10.0.1600.22. Use SQL Profiler and use a filter on it to get the most expensive queries. Use the Activity Monitor. It's the last toolbar in the top bar. It will show you a list of "Recent Expensive Queries". You can double-click them to see the execution plan, etc. If

How to remove cached server names from the Connect to Server dialog?

岁酱吖の 提交于 2019-11-29 23:27:49
Or, to put it another way, where is SqlStudio.bin for SQL Server 2012? It doesn't seem to be in the place that would be expected by looking at this other SO question . As of SQL Server 2012 you no longer have to go through the hassle of deleting the bin file (which causes other side effects). You should be able to press the Delete key within the MRU list of the Server Name dropdown in the Connect to Server dialog. This is documented in this Connect item and this blog post . To be clear, since a couple of people seemed to have trouble with this for months: You need to click on the Server name:

How to connect to a local database in SQL Server Management Studio?

血红的双手。 提交于 2019-11-29 23:01:37
I have downloaded the SQL Server Management Studio (SSMS) 2016 to recover a huge .bak file which is an old backup of a database. But first of all I need to connect to a DB Server. After install, I execute SSMS and it asks me to connect to a DB Server. I don't have any and I saw that it is possible to create a "local" db by typing only a dot '.' for Server Name and use Windows authentication. It is not working; how to do it? You need to download and install SQL LocalDB . It is a special edition of SQL Server that does not allow remote connection and supports windows integrated authentication

How do I create a SQL table under a different schema?

拥有回忆 提交于 2019-11-29 22:43:43
This is from SQL Server 2008, ssms When I create a table, it creates under dbo. I would like to create it under a different schema, but when I use the 'New Table' dialog, I can never find the field where to specify this. Right-click on the tables node and choose New Table... With the table designer open, open the properties window (view -> Properties Window). You can change the schema that the table will be made in by choosing a schema in the properties window. Try running CREATE TABLE [schemaname].[tableName]; GO; This assumes the schemaname exists in your database. Please use CREATE SCHEMA

Management Studio default file save location

元气小坏坏 提交于 2019-11-29 21:14:17
Open a new query window. Write some SQL. Save the script, the Save File As dialog box opens - but always to the same default location in the Profiles directory. Is there any way to set my default file location? ...Like I used to do with apps from the 1980s? Under Tools|Options a default location can be specified for query results. I need the same thing for new queries (the text editor). Tried changing locations in the Registry but SSMS just overwrote my changes. Any suggestions? (I saw this unanswered question at http://www.eggheadcafe.com/software/aspnet/30098335/management-studio-default

How to edit data in result grid in SQL Server Management Studio

回眸只為那壹抹淺笑 提交于 2019-11-29 21:09:59
I want to edit some row values once I get a query output in the result grid. Its true that we can right click the table and say open table to get an editable table output, but what I want is editable query output, only certain rows matching for my criteria, and edit them in the result grid. Can this possible inside Microsoft SQL server Management Studio Express? You can do something similar to what you want. Right click on a table and select "edit top 200 rows" (if you are on SQL Server 2008) or "open table" in SQL Server 2005. Once you get there, there is a button on the top that says "SQL";

How get the T-SQL code to find duplicates?

拈花ヽ惹草 提交于 2019-11-29 20:25:53
MS Access has a button to generate sql code for finding duplicated rows. I don't know if SQL Server 2005/2008 Managment Studio has this. If it has, please point where If it has not, please tell me how can I have a T-SQL helper for creating code like this. Well, if you have entire rows as duplicates in your table, you've at least not got a primary key set up for that table, otherwise at least the primary key value would be different. However, here's how to build a SQL to get duplicates over a set of columns: SELECT col1, col2, col3, col4 FROM table GROUP BY col1, col2, col3, col4 HAVING COUNT(*

Find stored procedure by name

拥有回忆 提交于 2019-11-29 20:09:37
Is there any way I can find in SQL Server Management Studio stored procedure by name or by part of the name? (on active database context) Thanks for help You can use: select * from sys.procedures where name like '%name_of_proc%' if you need the code you can look in the syscomments table select text from syscomments c inner join sys.procedures p on p.object_id = c.object_id where p.name like '%name_of_proc%' Edit Update: you can can also use the ansi standard version SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME LIKE '%name_of_proc%' Assuming you're in the Object Explorer Details