I'm building a site, and while stress testing it I received a few exceptions when the SQL Server was under relatively high load. Originally I was opening the connection when required in a particular Sub as follows (and then closing it when I was finished with it): If Not MyConnection.State = ConnectionState.Open Then MyConnection.Open() The probelm however was that from time to time the connection state was Opening instead of Closed or Open. So I am considering using the following piece of code instead: If MyConnection.State = ConnectionState.Connecting Then Do Until MyConnection.State = ConnectionState.Open Loop ElseIf MyConnection.State = ConnectionState.Broken Or MyConnection.State = ConnectionState.Closed Then MyConnection.Open() End If I'm a little worried about the Do...Loop in there, but I don't see how it should be a problem. Any thoughts?
Hi All, I have a column called TIER in my database which is a long string. There are piece of these strings that are separated by spaces like this: 'A3A00 A2B00 B1A00 C2C06 C3A06 C5A00 D2C00 G6B00 M2B00 M3B00 P7A00 T2A00 G4C00 G3C00 T5A06' How do I select the last 2 characters of the piece of string when the first 2 chacters are M2? I have the following: This is retruning me all the rows that have 'M2'. declare @code varchar (2)set @code = 'M2'select tier from companywhere tier like '%'+@code+'___ %' Any help is appreciated. Thank you in advance.
select sub1.*, case sub1.mdiff when sub1.mdiff<12 then 1 else 0 end as flag
error msg by query analyser Server: Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near '<'. Server: Msg 156, Level 15, State 1, Line 12 Incorrect syntax near the keyword 'as'.
I have the following sqlDataSource. I wan't to display one piece of data, not a whole row, from it. I can find lots of information on putting it into a datagrid, but nothing on puttin one piece in a textbox. I cannot use a formview as we are embedding html in response.write and it breaks in a formview. Thanks.
<asp:SqlDataSource runat="server" ID="myEmpInfo" SelectCommand="Select di.EmpInfo,di.eth,gc.t_level From tblEmp di ,tblMisc gc Where di.empnum = @empnumand di.empnum = gc.empnum" DataSourceMode="DataReader" ConnectionString="<%$ ConnectionStrings : myConnectionString %>">
Hi All, I have a column in my table like so: 'D4B00 L2A00 L3A00 L6C00 P1C00 L2A28 P4B00 ' How do I check in SQL if any pieces have the first 3 character the same. In the above case, L2A is present twice. I need to do this because I need display disctinct items, therefore L2A needs to be displayed only once. Any help is appreciated. Thanks
I have created a procedure with several SQL statement, all are included in a transaction. Some of the code are "insert" in tables that are in remote server. for example:
procedure sp1 is on SERVER B. From SERVERA by linked server we have:
exec serverB.db_B.dbo.sp1 (from serverA the procedure sp1 is called)
CREATE procedures sp1 AS BEGIN TRANSACTION insert into T1 (col1) values (1) insert into serverA.db_A.dbo.T2 (col1) vales ('8vhrfvrf') insert into T3 (col1) values (3) COMMIT TRANSACTION GO
I would like to make that these piece of code ( insert into serverA.db_A.dbo.T2 (col1) vales ('8vhrfvrf') ) is out of transaction. My question is: Is it possible to exclude piece of code from a transction?
You ask me why this: because SQL server do not allow loopback transaction
First I want to say thanks to the folks how have helped me over the past week or two. I'm missing a crucial piece of insight. How do I read a single piece of data from a SqlDataSource which only hold one row of data into a declared variable? string zUserName = SqlDataSource.(get the value in the row that is labeled UserName) It really doesn't matter to me whether it is an SqlDataSource or some other data container that hold the data I've selected. My goal is to be able to read some data from some predefined datasource into a declared variable. If I am approaching this problem in the wrong way any advice or article links you could give me would be grealy appreciate. Thanks, Bill
All the column names in upper case are actually symptom names, and in those columns are values {NULL, 1, 2, 3, 4, 5} and they belong in a column, so the normalized structure should be like this:
CREATE TABLE Symptom ( PatientID INT NOT NULL, Cycle TINYINT NOT NULL, SymptomName VARCHAR(20) NOT NULL, -- from the source column *name* Grade TINYINT NOT NULL -- from the value in the column with the name in uppercase PRIMARY KEY (PatientID, Cycle, SymptomName));
I can untwist the repeating groups with the code I borrowed from Kenneth Fisher's article [ here ], but the part I'm having a harder time with is grabbing the information that's still left in the column name and integrating it into the solution...
I can retrieve all the column names that are in uppercase using this:
DECLARE @db_id int; DECLARE @object_id int; SET @db_id = DB_ID(N'SCRIDB'); SET @object_id = OBJECT_ID(N'SCRIDB.dbo.BadTox'); SELECT name AS column_name , column_id AS col_order FROM sys.all_columns WHERE name = UPPER(name) COLLATE SQL_Latin1_General_CP1_CS_AS AND object_id = @object_id;
but I can't figure out how to work it into this (that I built by mimicking Kenneth Fisher's article...):
ALTER PROC [dbo].[UnpivotMaxGradeUsingCrossApply] AS SELECT PatientID , Toxicity , MAX(Grade) AS MaxGrade
[code]....
The problem is that I need to extract the column names (where ToxicityName[n] would be). I can do that by querying the sys.all_columns view, but I can't figure out how to integrate the two pieces. About the only thing I have even dreamed up is to build the VALUES(...) statements dynamically from the values returned by the system view.
So how do I get both the value from the ToxicityName[n] column and the column name into my final data query?
I have a string column in a DB where it's values contain the following midway through the string ([DOCUMENTGUID] is a uniqueidentifier that is different for each row):
The TSQL below all works except the bolded part at the end. I'm want to grab only the most recently logged piece of equipment not the most recent and all past ones as well which is what I've got doing minus the bolded part below. But I don't know how to say get this Equipment ID etc and only the most recently logged one to find its present location. The bolded part below is just there to show what I want it to do I know you can use an aggregate in a where clause. So in the first table listed tblRdrLog there is a column Time that I want to do this on so a.Time. I don't want to display a.Time just reference.
String dbsql = " SELECT a.EquipmentID " + " , f.Subcategory " + " , c.Area " + " , d.Room " + " FROM tblRdrLog a " + " JOIN tblRdrInfo b ON a.ReaderID = b.ReaderID " + " JOIN tblRdrArea c ON b.AreaID = c.AreaID " + " JOIN tblRdrRm d ON b.RoomID = d.RoomID " + " JOIN tblEquipInfo e ON a.EquipmentID = e.EquipmentID " + " JOIN tblEquipSubcat f ON e.SubcategoryID = f.SubcategoryID " + " WHERE a.EquipmentID IN (SELECT a.EquipmentID " + " FROM tblEquipInfo a " + " JOIN tblEquipCat b ON a.CategoryID = b.CategoryID " + " JOIN tblEquipSubcat c ON a.SubcategoryID = c.SubcategoryID " + " LEFT OUTER JOIN tblEquipMake d ON a.MakeID = d.MakeID " + " LEFT OUTER JOIN tblEquipModel e ON a.ModelID = e.ModelID " + " JOIN tblStatus f ON a.StatusID = f.StatusID " + " WHERE b.CategoryID = '" + this.ddlCategory.SelectedValue.ToString() + "' ";
if (!"".Equals(this.ddlSubcategory.SelectedValue.ToString())) dbsql += " AND c.SubcategoryID = '" + this.ddlSubcategory.SelectedValue.ToString() + "' ";
#region Advanced Search Criteria
// Check whether advanced search submitted if (adv) { if (!"".Equals(this.tbSerialNo.Text.ToString())) dbsql += " AND a.SerialNo = '" + this.tbSerialNo.Text.ToString() + "' "; if (!"".Equals(this.ddlMake.SelectedValue.ToString())) dbsql += " AND d.MakeID = '" + this.ddlMake.SelectedValue.ToString() + "' "; if (!"".Equals(this.ddlModel.SelectedValue.ToString())) dbsql += " AND e.ModelID = '" + this.ddlModel.SelectedValue.ToString() + "' "; if (!"".Equals(this.ddlStatus.SelectedValue.ToString())) dbsql += " AND f.StatusID = '" + this.ddlStatus.SelectedValue.ToString() + "' "; }
I installed Visual Studio over a year and a half ago when I became a Microsoft ISV. I have done all of my SQL Server work from within the Visual Studio framework and UI. I recently was asked to document how a customer's users would set up the customer's system using SQL Server 2005, but not having Visual Studio. I got the book Beginning SQL Server 2005 for Developers and immediately ran into a wall. Dewson (the author) talks about the SQL Server Management Studio. He says you get to it by Start > Programs > Microsoft SQL Server 2005 > Sql Server Management Studio. When I tried, I went Start > All Programs > Microsoft SQL Server 2005 > Configuration Tools.
I have reinstalled my SQL Server 2005 Developer's edition and installed SQL Server 2005 Standard edition every way I can see, but I still can't get SSMS to come up. What am I doing wrong?
I am running XP Pro 2002 with SP 2. It is on a thinkpad with P4-M 1.8 ghz and 512 mb RAM. My Add/Remove programs says I have SQL Server 2005, SQL Server 2005 Backward Compatibility, SQL Server Native Client, SQL Server Setup Support Files, and SQL Server VSS Writer installed.
I installed Red Gate's SQL Search and now I have an Add-ins icon. From the Icon I got to a list of tools, one of which is SSC's script library.
When I downloaded it I got this file "SQLScripts.utmcsr&__utmv=-&__utmk=243779397" which did not trigger an installer when clicking on it. How do I add it.
I have a New default instance of SQL2k5 installed and i am trying to setup access to the this via a vpn.
The VPN is setup and allows access to the server and can T/S to the server and perform everything all ok.
When trying to connect over the VPN with SSMS installed on my laptop I am able to connect using Windows authentication only by using Named Pipes. To accomplish this i perform a Net Use ..... and everything works fine.
However if i specify in the connection tab to use TCP/IP it fails with an unknown username or password. The Event Viewer on the server shows this and for what ever reason the username / pwd is that of my laptop and not of the account used in the VPN setup or the net use.
Also if i try to connect to the SQL Server over the VPN using VS 2005 it also gives the same issue.
I need to get this sorted so that TCP is able to be used.
I created a database on a remote server and trying to manage the database using a local SSMS. I am able to see the tables and other objects of the old databases residing on the same remote server, but not the new database. I have created the users similar to the other databases, have the exact same roles as the other databases.Not sure what I am missing here. Any suggestions??
Is there any way to use SQL Server Management Studio to manage a 7.0 database? I have a few old databases still in 7.0 and would really like to manage them through SMSS. Am I out of luck?
Just installed SQL Server 2005 Standard. When I attempt to connect using SSMS it just sits. No error comes up. The log seems to indicate everythings OK. SQLServer and SQLBrowser services are started. Here's the log:
2007-07-07 09:41:23.07 Server Microsoft SQL Server 2005 - 9.00.3042.00 (Intel X86) Feb 9 2007 22:47:07 Copyright (c) 1988-2005 Microsoft Corporation Standard Edition on Windows NT 5.1 (Build 2600: Service Pack 2)
2007-07-07 09:41:23.07 Server (c) 2005 Microsoft Corporation. 2007-07-07 09:41:23.07 Server All rights reserved. 2007-07-07 09:41:23.07 Server Server process ID is 2412. 2007-07-07 09:41:23.07 Server Authentication mode is WINDOWS-ONLY. 2007-07-07 09:41:23.07 Server Logging SQL Server messages in file 'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLLOGERRORLOG'. 2007-07-07 09:41:23.07 Server This instance of SQL Server last reported using a process ID of 1348 at 7/7/2007 9:35:40 AM (local) 7/7/2007 2:35:40 PM (UTC). This is an informational message only; no user action is required. 2007-07-07 09:41:23.07 Server Registry startup parameters: 2007-07-07 09:41:23.07 Server -d C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDATAmaster.mdf 2007-07-07 09:41:23.07 Server -e C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLLOGERRORLOG 2007-07-07 09:41:23.07 Server -l C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDATAmastlog.ldf 2007-07-07 09:41:23.11 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required. 2007-07-07 09:41:23.11 Server Detected 1 CPUs. This is an informational message; no user action is required. 2007-07-07 09:41:23.34 Server Using dynamic lock allocation. Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node. This is an informational message only. No user action is required. 2007-07-07 09:41:23.36 Server Attempting to initialize Microsoft Distributed Transaction Coordinator (MS DTC). This is an informational message only. No user action is required. 2007-07-07 09:41:23.89 Server The Microsoft Distributed Transaction Coordinator (MS DTC) service could not be contacted. If you would like distributed transaction functionality, please start this service. 2007-07-07 09:41:23.89 Server Database mirroring has been enabled on this instance of SQL Server. 2007-07-07 09:41:23.90 spid5s Starting up database 'master'. 2007-07-07 09:41:24.20 spid5s SQL Trace ID 1 was started by login "sa". 2007-07-07 09:41:24.28 spid5s Starting up database 'mssqlsystemresource'. 2007-07-07 09:41:24.31 spid5s The resource database build version is 9.00.3042. This is an informational message only. No user action is required. 2007-07-07 09:41:25.65 Server A self-generated certificate was successfully loaded for encryption. 2007-07-07 09:41:25.67 Server Server local connection provider is ready to accept connection on [ \.pipeSQLLocalMSSQLSERVER ]. 2007-07-07 09:41:25.67 Server Server local connection provider is ready to accept connection on [ \.pipesqlquery ]. 2007-07-07 09:41:25.67 spid9s Starting up database 'model'. 2007-07-07 09:41:25.67 Server Server is listening on [ 127.0.0.1 <ipv4> 1434]. 2007-07-07 09:41:25.67 Server Dedicated admin connection support was established for listening locally on port 1434. 2007-07-07 09:41:25.68 Server SQL Server is now ready for client connections. This is an informational message; no user action is required. 2007-07-07 09:41:25.68 spid5s Server name is 'LAPTOP'. This is an informational message only. No user action is required. 2007-07-07 09:41:25.71 spid12s Starting up database 'msdb'. 2007-07-07 09:41:25.71 spid13s Starting up database 'ReportServer'. 2007-07-07 09:41:25.71 spid14s Starting up database 'ReportServerTempDB'. 2007-07-07 09:41:25.71 spid15s Starting up database 'testx'. 2007-07-07 09:41:27.45 spid9s Clearing tempdb database. 2007-07-07 09:41:28.65 spid9s Starting up database 'tempdb'. 2007-07-07 09:41:28.78 spid5s Recovery is complete. This is an informational message only. No user action is required. 2007-07-07 09:41:28.78 spid12s The Service Broker protocol transport is disabled or not configured. 2007-07-07 09:41:28.78 spid12s The Database Mirroring protocol transport is disabled or not configured. 2007-07-07 09:41:29.25 spid12s Service Broker manager has started. 2007-07-07 09:57:23.54 Server CPU time stamp frequency has changed from 117988 to 200203 ticks per millisecond. The new frequency will be used. 2007-07-07 10:09:23.85 Server CPU time stamp frequency has changed from 200203 to 242307 ticks per millisecond. The new frequency will be used. 2007-07-07 10:20:03.20 spid12s Service Broker manager has shut down. 2007-07-07 10:20:04.25 spid5s SQL Server is terminating in response to a 'stop' request from Service Control Manager. This is an informational message only. No user action is required. 2007-07-07 10:20:04.25 spid5s SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.
I have SQL Server 2005 SP2 (developer edition) installed on my machine along with Visual C# 2005 express and Visual Web Developer 2005 express. I uninstalled the 2005 Visual tools and installed the 2008 versions which in turn installed .Net 3.5.
Now, when I right click on a table and select designer, I get the following error message.
TITLE: Microsoft SQL Server Management Studio ------------------------------ Class does not support aggregation (or class object is remote) (Exception from HRESULT: 0x80040110 (CLASS_E_NOAGGREGATION)) (Microsoft.SqlServer.SqlTools.VSIntegration) ------------------------------ BUTTONS: OK ------------------------------
Similarly, when I right click on the indexes folder under a table so that I can create an index, I get the same message but with more details (details are at the end of this post due to size). My research into this problem indicates that it is a problem with the .Net frameworks and I need to reinstall .Net 2.0. It appears that I would have to uninstall 3.5 to accomplish this.
I imagine that I can uninstall the 2008 Visual tools but I really don't want to go backwards. Does anyone know how I can fix the SS2005 instance or am I just going to have to tolerate the errors until I can get a copy of SS 2008?
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.Runtime.InteropServices.COMException (0x80040110): Class does not support aggregation (or class object is remote) (Exception from HRESULT: 0x80040110 (CLASS_E_NOAGGREGATION)) at Microsoft.SqlServer.Management.UI.VSIntegration.ISqlToolsVSHlpFactory.CreateHierarchyWrapper(Guid& clsidInnerHier) at Microsoft.SqlServer.Management.UI.VSIntegration.SqlWorkbenchHierarchy.CreateHierarchyWrapper(Type typeToWrap, ILocalRegistry localReg) at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ScriptFactory.get_SqlVirtualProject() at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.IndexMenuAccessHandler.Enabled(INodeInformation source) at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ToolsMenuItemBase.UpdateMenuCommandStatus(MenuCommand menuCommand) at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.DefaultMenuHandler.UpdateMenuCommandsStatus(MenuCommand menuCommand) at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.DefaultMenuHandler.GetMenuItems(ArrayList items) at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.DefaultMenuHandler.GetMenuItems() at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ExplorerHierarchyNode.ShowContextMenu(Point windowPos) at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.LazyTreeView.WmContextMenu(Message& m) at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.LazyTreeView.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Granted there are nearly 8000 tables in this particular database. What needs to be installed or what bit needs to be flipped so the user can see all tables in SSMS?