sql-server

Timeout Expired: Connection Pool

Here is the error we are getting. We moved app and db servers to x64 from 32-bit. Framework 2.0 service pack 2 is installed on the servers. Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Here is...

How to bootstrap sql server express and my database into my custom c# applicaiton

I am designing a database using sql server express. Once completed how can I include sql server express and my database into the msi package to automatically install in the client's machine? ...

How to restore a database from C#

I have a SQL 2008 DB. I am running a form that backs that DB up, then tries to update it. If the update fails the idea is to restore that backup. Here is the code I am using to restore the backup. public void RestoreDatabase(String databaseName, String backUpFile, String serverName, String userName, String password) { Restore sqlRe...

SQL inline conditional in Select

I was wondering if something like this was possible: SELECT name or alt_name FROM users Where userid=somenum I have also tried this: SELECT name IF NOT NULL ELSE alt_name ... If anyone has any insight I'd appreciate it. ...

How to find the item index number in a query result

Hi, is there a simple way to get the number of the current item in a simple SELECT? I need to deliver a column based on a calculation that involves the number of the current index in the select. I am simplifing my problem to an extreme, but roughly speaking, here is an example: SELECT column1 * ITEMINDEX FROM table I hope I am being c...

SQL Row_Number() function in Where Clause

Hi All, I found one question answered with Row_Number() function in where clause. When I tried one query, I was getting the following error. "Msg 4108, Level 15, State 1, Line 1 Windowed functions can only appear in the SELECT or ORDER BY clauses." Here is the query I tried. If somebody knows how to solve this, please let me know....

SQL Server Stored Procedures: do they queue up?

I should probably be able to find an answer to this but my Google-fu is weak today. When I have the same stored proc called multiple times by a web app, do the calls queue up or do they run independently? ...

Tracking changes in SQL Server during transactions

My employer has developed a utility that will run a stored procedure line by line against a DataTable, passing the fields of each row as parameters into the Stored Procedure. This is particularly useful for automated imports. However, I now need to extend this to provide a transactional-ized version so that we can see the potential resu...

Sending Notifications from a SQL Server 2000 Job without SMTP Server on the Box

I have SQL Server 2000 installed on Windows 2003 Server. We do not have SMTP installed on the box, so when creating a notification for a failed SQL Agent job, the email is not sent. Is there a way to send out a notification without installing SMTP on the box? ...

NHibernate query optimization

I have an nhibernate query which generates a query like this. I just extracted the example scenario SELECT ID FROM EMPLOYEE WHERE EMPLOYEE.NAME = @P1 AND AND MANAGER_ID IN (@p2, @p3, @p4...@pn )etc. Using NHprofiler I found the query takes around 500 ms. Table has index on name and manager_id. Employee table is around 6 million record...

How can I insert random values into a SQL Server table?

I'm trying to randomly insert values from a list of pre-defined values into a table for testing. I tried using the solution found on this StackOverflow question: stackoverflow.com/.../update-sql-table-with-random-value-from-other-table When I I tried this, all of my "random" values that are inserted are exactly the same for all 3000 re...

Case-insensitive REPLACE() in SQL Server 2000

I have a field that contains strings such as 'Blah-OVER', 'Blah-OveR', etc. and want to select them without the 'over's. This only catches the first case (so to speak) and not the others: SELECT field as "before", REPLACE(field, 'OVER', '') as "after" How do I just get them all to say 'Blah-' (preserving the case of what's left) with...

How to optimize a table for fast inserts only?

I have a log table that will receive inserts from several web apps. I wont be doing any searching/sorting/querying of this data. I will be pulling the data out to another database to run reports. The initial table is strictly for RECEIVING the log messages. Is there a way to ensure that the web applications don't have to wait on thes...

VS 2005, SQL 2008, KB954961 Won't Install - Win7 x64 Issue?

I recently installed Win 7 x64 on my machine. I have Visual Studio 2005 Standard, and need to install the update for SQL 2008 support, so I can connect to the remote SQL Server within VS. http://www.microsoft.com/downloads/details.aspx?FamilyId=E1109AEF-1AA2-408D-AA0F-9DF094F993BF&displaylang=en When I try to run the update, I get ...

sql server 2000: release lock on table?

I run the following query select * from my t1 where c1 = 22 and query runs for ever.. How can I find out whats locking that row? I tried runnning sp_who, sp_who2, sp_lock, and googled for information but still no resolution in sight. Please help. I am using sql server 2000. ...

SQL query need to get certain counts of data item

here is the whole picture. There is a table (table programparticipants) that stores all participants of all programs, there is another table (table programs) that stores all the programs. What I need to accomplish is the following: Acquire the programs where a user has attended more than one program (done) Acquire the other programs (f...

SQL Server 2005 - How do I convert image data type to character format

Background: I am a software tester working with a test case management database that stores data using the deprecated image data type. I am relatively inexperienced with SQL Server. The problem: Character data with rich text formatting is stored as an image data type. Currently the only way to see this data in a human readable for...

Determine whether to generate ExecuteNonQuery or ExecuteReader from schema

I am attempting to create a stored procedure/ADO.NET mapping mechanism where a stored procedure with parameters becomes object MyStoredProcedure.Execute(out returnValue, param1, param2, ...) The problem comes when trying to generate the actual data retrieval method. I can easily obtain most of the schema information I need from the I...

Using GUIDs in Primary Keys / Clusted Indexes

I'm fairly well versed in SQL server performace but I constanly have to argue down the idea that GUIDs should be used as the default type for Clusterd Primary Keys. Assuming that the table has a fairly low amount of inserts per day (5000 +/- rows / day), what kind of performace issues could we run into? How will page splits affect our ...

Selling Sql Server 2008 to upper management? How?

I know the advantages of upgrading from sql server 2005 to sql server 2008, but upper management could care less about t-sql debugging, intellisense, the merge statment, etc..., so what are some features in sql server 2008 that upper management might actually find worth while. ...