ssms

Query times out when executed from web, but super-fast when executed from SSMS

跟風遠走 提交于 2019-11-26 08:06:02
问题 I\'m trying to debug the source of a SQL timeout in a web application that I maintain. I have the source code of the C# code behind, so I know exactly what code is running. I have debugged the application right down to the line that executes the SQL code that times out, and I watch the query running in SQL profiler. When this query executes from the web, it times out after 30 seconds. However, when I cut/paste the query exactly as presented in Profiler, and I put it into SSMS and run it, it

Unique constraint on multiple columns

喜你入骨 提交于 2019-11-26 07:54:13
问题 CREATE TABLE [dbo].[user]( [userID] [int] IDENTITY(1,1) NOT NULL, [fcode] [int] NULL, [scode] [int] NULL, [dcode] [int] NULL, [name] [nvarchar](50) NULL, [address] [nvarchar](50) NULL, CONSTRAINT [PK_user_1] PRIMARY KEY CLUSTERED ( [userID] ASC ) ) ON [PRIMARY] GO How do I add a unique constraint for columns fcode, scode, dcode with t-sql and/or management studio ? fcode, scode, dcode must be unique together. 回答1: By using the constraint definition on table creation, you can specify one or

How do you specify a different port number in SQL Management Studio?

北战南征 提交于 2019-11-26 06:54:19
问题 I am trying to connect to a Microsoft SQL 2005 server which is not on port 1433. How do I indicate a different port number when connecting to the server using SQL Management Studio? 回答1: 127.0.0.1,6283 Add a comma between the ip and port 回答2: If you're connecting to a named instance and UDP is not available when connecting to it, then you may need to specify the protocol as well. Example: tcp:192.168.1.21\SQL2K5,1443 回答3: Another way is to setup an alias in Config Manager. Then simply type

How do I view the full content of a text or varchar(MAX) column in SQL Server 2008 Management Studio?

徘徊边缘 提交于 2019-11-26 06:17:39
问题 In this live SQL Server 2008 (build 10.0.1600) database, there\'s an Events table, which contains a text column named Details . (Yes, I realize this should actually be a varchar(MAX) column, but whoever set this database up did not do it that way.) This column contains very large logs of exceptions and associated JSON data that I\'m trying to access through SQL Server Management Studio, but whenever I copy the results from the grid to a text editor, it truncates it at 43679 characters. I\'ve

How do you view ALL text from an ntext or nvarchar(max) in SSMS?

ε祈祈猫儿з 提交于 2019-11-26 05:00:36
问题 How do you view ALL text from an NTEXT or NVARCHAR(max) in SQL Server Management Studio? By default, it only seems to return the first few hundred characters (255?) but sometimes I just want a quick way of viewing the whole field, without having to write a program to do it. Even SSMS 2012 still has this problem :( 回答1: Options (Query Results/SQL Server/Results to Grid Page) To change the options for the current queries, click Query Options on the Query menu, or right-click in the SQL Server

sql server invalid object name - but tables are listed in SSMS tables list

时间秒杀一切 提交于 2019-11-26 04:58:32
问题 I am attempting to create a Stored Procedure for a newly created database. However the SSMS intellisense does not recognize more than half of the tables which have been created. For example whilst in the left hand column under tables I have a table dbo.Room , when I type \" dbo. \" in the new query window, that table is not listed, in fact only 17 out of 37 tables are listed. I can see no difference between the tables listed by intellisense and those not. If I manually type dbo.Room, it is

Sql Server 'Saving changes is not permitted' error ► Prevent saving changes that require table re-creation

此生再无相见时 提交于 2019-11-26 04:57:06
问题 When I create a table in SQL Server and save it, if I try to edit the table design, like change a column type from int to real, I get this error: Saving changes is not permitted. The change you have made requires the following table to be dropped and re-created. You have either made changes to a table that can\'t be recreated or enabled the option prevent saving changes that require the table to be re-created. Why do I have to re-create the table? I just want to change a data type from

How to connect to local instance of SQL Server 2008 Express

倾然丶 夕夏残阳落幕 提交于 2019-11-26 03:19:48
问题 I just installed SQL Server 2008 Express on my Vista SP1 machine. I previously had 2005 on here and used it just fine with the old SQL Server Management Studio Express. I was able to connect with no problems to my PC-NAME\\SQLEXPRESS instance (no, PC-NAME is not my computer name ;-). I uninstalled 2005 and SQL Server Management Studio Express. I then installed SQL Server 2008 Express on my machine and elected to have it install SQL Server Management Studio Basic. Now, when I try to connect to

What is the use of GO in SQL Server Management Studio & Transact SQL?

心已入冬 提交于 2019-11-26 01:35:35
问题 SQL Server Management Studio always inserts a GO command when I create a query using the right click \"Script As\" menu. Why? What does GO actually do? 回答1: It is a batch terminator, you can however change it to whatever you want 回答2: Since Management Studio 2005 it seems that you can use GO with an int parameter, like: INSERT INTO mytable DEFAULT VALUES GO 10 The above will insert 10 rows into mytable . Generally speaking, GO will execute the related sql commands n times . 回答3: The GO

What is the best way to auto-generate INSERT statements for a SQL Server table?

只谈情不闲聊 提交于 2019-11-25 23:24:48
问题 We are writing a new application, and while testing, we will need a bunch of dummy data. I\'ve added that data by using MS Access to dump excel files into the relevant tables. Every so often, we want to \"refresh\" the relevant tables, which means dropping them all, re-creating them, and running a saved MS Access append query. The first part (dropping & re-creating) is an easy sql script, but the last part makes me cringe. I want a single setup script that has a bunch of INSERTs to regenerate