Questions tagged [sql-server-2008]

SQL Server 2008 (major build version 10.00.xxxx). Please also tag with sql-server.

SQL Server 2008 was introduced in August 2008. Current build versions include:

  1. 10.00.1600 - RTM
  2. 10.00.2531 Service Pack 1, released April 2009
  3. 10.00.4000 Service Pack 2, released September 2010
  4. 10.00.5500 Service Pack 3, released October 2011
  5. 10.00.6000 Service Pack 4, released September 30, 2014 (final)

SQL Server 2008 left mainstream support on 2014-07-08, and will leave extended support on 2019-07-09.

3899 questions
8 answers

How to query last restore date in SQL Server?

Is there a T-SQL query that shows the last restore datetime for a certain database?
Kees C. Bakker
  • 1,223
  • 1
  • 8
  • 9
1 answer

How to force drop database in SQL Server 2008

I'm trying to force drop a database, but after dropping the database, when I try to recreate the database, I'm getting the error cannot create file C:\Program Files.....[databasename].mdf because it already exists Here's my query to force drop…
  • 901
  • 1
  • 6
  • 6
4 answers

How to identify which query is filling up the tempdb transaction log?

I would like to know how to identify the exact query or stored proc which is actually filling up the transactional log of TEMPDB database.
7 answers

Writing a simple bank schema: How should I keep my balances in sync with their transaction history?

I am writing the schema for a simple bank database. Here are the basic specifications: The database will store transactions against a user and currency. Every user has one balance per currency, so each balance is simply the sum of all…
12 answers

Passing array parameters to a stored procedure

I've got a process that grabs a bunch of records (1000's) and operates on them, and when I'm done, I need to mark a large number of them as processed. I can indicate this with a big list of IDs. I'm trying to avoid the "updates in a loop" pattern,…
D. Lambert
  • 1,027
  • 1
  • 8
  • 8
6 answers

What are the main causes of deadlocks and can they be prevented?

Recently one of our ASP.NET applications displayed a database deadlock error and I was requested to check and fix the error. I managed to find the cause of the deadlock was a stored procedure that was rigorously updating a table within a…
  • 4,412
  • 3
  • 30
  • 35
5 answers

I can't connect to my servers SQL database via an IP Address

I have setup a server that runs Windows Server 2008, and has SQL Server 2008 Express installed. I can connect to the machine's SQL Server Express database via the MACHINENAME/SQLEXPRESS. However when we come to connecting through any software or…
Shaun S
  • 673
  • 1
  • 6
  • 6
2 answers

What is the purpose of the database 'owner'?

Today while troubleshooting a service broker problem, I discovered that the database owner was the Windows login of an employee who had left the company. His login had been removed and thus the query notifications were failing. Supposedly the best…
  • 2,559
  • 2
  • 28
  • 35
8 answers

How do I shrink all files quickly for all databases?

In SQL Server (2008 in this case) how can I quickly shrink all the files, both log and data, for all databases on an instance? I could go through SSMS and right click each and choose Tasks -> Shrink, but I'm looking for something faster. I scripted…
  • 6,206
  • 4
  • 40
  • 66
3 answers

How do I get back some deleted records?

I mistakenly deleted around 2,000,000 records from a remote SQL Server 2008 table. The server is not granting me access to the backup files on the server side. Is there any way to get back these records?
4 answers

What are Objective Business Reasons to Prefer SQL Server 2012 over 2008 R2?

My company is facing the decision whether to purchase SQL Server 2012 Denali or SQL Server 2008 R2 for a new database server. I am looking for objective reasons to choose one over the other. Our requirements: Standard edition (for financial reasons…
  • 7,180
  • 5
  • 29
  • 58
8 answers

Writing select result to a csv file

We need to write the SELECT query results to a csv file. How can it be done using T-SQL in SQL Server 2008 r2? I know that it can be done in SSIS, but for some reasons, we don't have this option. I tried to use the suggested proc in the article…
  • 3,654
  • 15
  • 46
  • 67
4 answers

How do I identify the column(s) responsible for "String or binary data would be truncated."

I am generating some queries automagically with code I wrote to SELECT from a remote Pg database, and insert into a local SQL Server database. However, one of them is generating this error: [Microsoft][ODBC SQL Server Driver][SQL Server]String or…
Evan Carroll
  • 57,249
  • 39
  • 210
  • 433
3 answers

The database principal owns a schema in the database, and cannot be dropped message

I am trying to delete a principal from the database but can't because it owns a schema. When I go to edit the user, however, the box to uncheck schemae is blue and unremovable. How can I remove the principal from these schemas?
  • 821
  • 1
  • 7
  • 12
4 answers

Why is my database still fragmented after I rebuilt and reindexed everything?

I have a database which I tried to defragment all the tables at once by running this T-SQL: SELECT 'ALTER INDEX all ON ' + name + ' REORGANIZE;' + CHAR(10) + 'ALTER INDEX all ON ' + name + ' REBUILD;' FROM sys.tables And then…
Justin Dearing
  • 2,637
  • 4
  • 32
  • 49
2 3
99 100