sql-server

How can I make MS SQL Server available for connections?

I'm trying to connect to MS SQL Server (running on my machine) from a Java program. I'm getting the following long winded exception: Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection pr...

How can I reset username and password for SQL Server 2008

Shortly after I installed MS SQL Server 2008 on my machine, I forgot the password AND username that I chose. How can I reset them? This question seems promising, but it didn't work for me. When I tried exec sp_password @new='changeme', @loginame='sa' as a query, I received: Msg 15151, Level 16, State 1, Line 1 Cannot alter the login ...

Help me put Oracle terminology into SQL Server terminology

My company is now supporting Oracle for the first time, and most of my colleagues are SQL Server developers who haven't really worked with Oracle. I'm a little bit familiar with Oracle, but far from a genius on the subject. Unfortunately, that is enough to mean that I know more about Oracle than most of my co-workers, so I find myself ...

SQL Server create/update database script

In MS SQL Server 2005, how can I create a script consisting off all the objects in the database (tables, stored procedures, views)? I want to use the script to create the database using SMO or to update its objects (alter, drop) if they already exist. I know about the scripting feature in SQL Server Management Studio, I am however not fa...

Calling stored procedure via query and getting return value in C# without output parameters

Hello Is there anyway I can execute stored procedure via EXEC (so not specifying command type as StoredProcedure in C#) and get result? I tried to execute query DECLARE @R int EXEC @R = proc p1, p2 and then to grab @R but without success. What I don't want is to do it the usual way by adding parameters and using ParameterDirection...

full text search, filter results for best match

I have 3 tables that link up. Restaurants, Cuisines and Cuisine Type. A Restaurant can sell many cuisines of food (that's bad wording but you get idea?) So I have Full text setup on Restaurant:Name, CityTown, Postcode and on CuisineType:Name I have one searchbox on my home page and as the user types results are filtered to best match....

ERROR ON: numApprovals = (int)cmd.ExecuteScalar();

public static int AwaitingApprovals() { int numApprovals = 0; string sql = "SELECT COUNT(Type) AS OpenforApproval FROM dbo.LeaveRequest WHERE Type IN (2, 3, 4, 5, 6, 8, 13, 14, 16, 22) GROUP BY MgtApproval HAVING (MgtApproval IS NULL"; //"SELECT COUNT(EffectiveDate) AS OpenforApproval FROM...

SQL Server 2005 Query Statistics

Where can I find some in-depth information on tuning statistics in SQL Server 2005? I need to really delve in to what statistics are being used in a number of different queries, how they are interacting with indexes, how/when/where to use custom statistics (over and above what the database tuning advisor recommends), when/how to update ...

Finding availability by time

I have three tables. Table (t), a resource in my system. It has a maximum capacity. Booking (b), a reservation in the system, it hase FromDatimeTime, ToDateTime and nrOfPeople BookedTable (bt), connects the booking with table and how many seats that are used by this booking, a booking can have more than one table. The problem is tha...

Multi-Threaded Database Queries

So we have this ultimate fail vendor (it's a long story, but trust me here) that has created an application that has separate, but identical in design, databases that we need to query (10 of them actually). Each of these databases is for a different "location" - but it's all still information relevant to all locations. I've written some...

Stored Procedure and XML

I get this error: The error description is 'Only one top level element is allowed in an XML document.'. Could not find prepared statement with handle 0. The XML parse error 0xc00ce555 occurred on line number 1, near the XML text "<value1>34</value1><value1>33</value1><value1>32</value1>". The statement has been terminated. This is Sto...

Team Foundation Server - Sql Server Version Management

Does TFS offer any enhanced ways of storing changes made to a sql server database other than using it to version text files of sql statements executed on the database? Or is the functionality I'm looking for only available in 3rd party tools like Red Gate's tools or Quest's Change Director? ...

Sql server 2008 service broker millions of queues

I am working on wireframe for new feature in our application. One of the requirements is each user has a list of things to process. I am planning to use SQL Server 2008 service broker to send notifications of to-do items to users. But with the way the broker queue is working I can't isolate messages for users in a single queue. I can o...

Hierarchical Database Select / Insert Statement (SQL Server)

I have recently stumbled upon a problem with selecting relationship details from a 1 table and inserting into another table, i hope someone can help. I have a table structure as follows: ID (PK) Name ParentID<br> 1 Myname 0<br> 2 nametwo 1<br> 3 namethree 2 e.g This is the table i need to sel...

SQL Server Delay Problem

Hello, I have just finished importing an ACCESS db (back-end) to a SQL Server 2008 db. My front-end is still ACCESS 2007 and the back-end is SQL Server 2008. What I've realized is that if I open a form (on a certain record) and then do some calculation which is supposed to fill in some text fields automatically on that form (for that rec...

SQL Server Index performance - long column

In SQL Server (2005+) I need to index a column (exact matches only) that is nvarchar(2000+). What is the most scalable, performant way to approach this? In SQL Server (2005+), what would be the practical difference in indexing on a column with the following types: nvarchar(2000) char(40) binary(16) E.g. would a lookup against an ind...

.NET compression of XML to store in SQL Server database

Hi all, Currently our .NET application constructs XML data in memory that we persist to a SQL Server database. The XElement object is converted to a string using ToString() and then stored in a varchar(MAX) column in the DB. We dind't want to use the SQL XML datatype as we didn't need any validation and SQL doesn't need to query the XML...

Insert into a temp table from a stored procedure on Sql Server 2000

I'm trying to accomplish what is described here: http://sqldev.wordpress.com/2008/05/06/insert-into-temporary-table-from-stored-procedure/ The article says (with support via comments) that this works on SQL sever 2000 but may not be as easy. This was a little tricky pre 2008 – as it turns out in SQL Server 2008 this can be do...

Do Indexed Views Update During a Transaction?

Let's say I've got a SQL Server Indexed View, vwIndexedView, that reads from two tables, tbTableOne, and tbTableTwo. If I perform an action on one of the two tables inside a transaction, what happens to my indexed view? Is it refreshed immediately, or do I have to commit my transaction before the results will feed into it? For instance...

Insert into a table a part of another table

I have two tables, the structure of the first partially recapitulates, iterates the structure of the second: table1 (id, i, j, k, a, b, c, x, y, z) -- requests table2 (id, a, b, c, d) -- essential elements / bank subjects I need to insert into table1 a record from table2 with given ID. What is the best approach to do that? I have two...