Questions tagged [sql-server-2008-r2]

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

SQL Server 2008 R2 was introduced in April 2010. Current build versions include:

  1. 10.50.1600 RTM
  2. 10.50.2500 Service Pack 1, released July 2011
  3. 10.50.4000 Service Pack 2, released July 2012
  4. 10.50.6000 Service Pack 3, released September 2014 (final)

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

3780 questions
53
votes
1 answer

Is there an analog of GETDATE() that returns DATETIME2

According to MSDN, Getdate(), GetUtcDate(), and CURRENT_TIMESTAMP all return DATETIME. I ran a short test, which confirms that: CREATE TABLE #t(T DATETIME2(7)); GO DECLARE @i INT ; SET @i=1; WHILE @i<10000 BEGIN ; INSERT #t…
A-K
  • 7,244
  • 3
  • 32
  • 50
19
votes
6 answers

Is there a shorthand way to 'Auto_Fix' all Orphaned Users in an SQL Server 2008 R2 database?

It's fairly straight forward to fix up a single orphaned SQL user to a login using: EXEC sp_change_users_login 'Auto_Fix', 'user' I could script this, but is there an existing stored procedure which automatically tries to fix up every orphaned…
Daniel James Bryars
  • 701
  • 1
  • 5
  • 17
14
votes
2 answers

Performance Tuning for Huge Table (SQL Server 2008 R2)

Background: I have a fact table in UAT Phase. Objective to load 5 yrs of data in Prod (expected size 400 Mn records). Currently it has only 2 years of data in Test. Table Features: No of Dimensions ~ 45 Measures ~ 30 Non-additive measures and…
user1801862
  • 141
  • 1
  • 3
11
votes
1 answer

How can I get all orphan records in a single query?

I just noticed few tables that has orphan records (foreign keys) that no longer point to any primary key. How can I query the tables to get a list of all such rows? When these parent records got deleted or how to handle this? I'm using SQL Server…
Shayma Ahmad
  • 645
  • 7
  • 18
  • 27
9
votes
1 answer

SQL Server 2008 R2 Setup Client Tools Connectivity

During SQL Server 2008 R2 setup I see a checkbox for "Client Tools Connectivity" and "Client Tools Backward Compatibility" installation options. It says these are component for client server communication. Can anyone explains what are these…
SQL Learner
  • 3,011
  • 4
  • 28
  • 39
8
votes
2 answers

The best way to rename the tables after development completed

What is the easiest and most reliable approach to rename the database tables and columns in SQL Server 2008 r2? We have finished development and for some reasons, we are required to rename some tables and afew columns. Is using synonyms the good…
Sky
  • 3,684
  • 16
  • 49
  • 68
8
votes
4 answers

What is the best way to rebuild a date from integer inputs?

I've got a bunch of financial reports, and we want to be able to pass them two inputs (year and quarter) as variables. I'm doing it this way, but I really don't like it: declare @quarter int, @year int, @date date set @quarter = 4 …
James
  • 2,612
  • 5
  • 26
  • 49
8
votes
1 answer

Restore MSDB data to a new server

I'm trying to move everything from a SQL Server 2008 R2 (enterprise) instance to a new instance on a different server. To do this, I thought (after some research) that I'd be able to move the system databases - master, msdb and model. To accomplish…
paulH
  • 1,444
  • 1
  • 20
  • 39
7
votes
3 answers

Running Total which Resets when Customer changes (keeping existing RowNumbers)- attempt included

I have a table where the RowNumber is of essence. It has a range of clients, and a running total for that client - which resets every time the Client changes. e.g. client rownr amount runtotal Company A 1 1.00 1.00 Company A 2 1.00 …
Peter PitLock
  • 1,375
  • 4
  • 21
  • 31
7
votes
3 answers

identify blocking and send alert

I need to create an alert that will notify me when any query has been blocked for more than 60 seconds. For example if someone has a transaction open on a table and forgets to run a commit or a rollback. Is this possible to get from the system…
Lumpy
  • 2,109
  • 8
  • 32
  • 43
6
votes
3 answers

Best Way to Grant Read All Permission in SQL Server 2008 R2?

What is the best method to grant read access to all current and future databases to a user (AD Group in this case)? Currently I have a flaky scheduled job that does this using (going to start debugging the following, but maybe I am doing it wrong…
Kyle Brandt
  • 2,345
  • 8
  • 29
  • 37
6
votes
2 answers

Reclaiming data file free space after deleting a large amount of data

I am an accidental DBA. We have a sql cluster that hosts 10 databases. Suddenly the size of one of the database increased drastically from 100GB to 250GB. When we checked the datafile, the size had grown more than twice over the last few days. We…
Info23
  • 163
  • 1
  • 2
  • 9
6
votes
1 answer

SQL Server 2008 R2 Restore Database From File - "failed: 38(failed to retrieve text for this error. Reason: 15105)"

I'm running a database restore on a backup file that was created up on a clients server, the backup file has been moved to our server (same SQL version 2008 R2) and I'm getting the following error after the T-SQL has been running for nearly 7…
Mark Collins
  • 61
  • 1
  • 3
6
votes
1 answer

Practical application of EXISTS vs. LEFT JOIN to find addresses for delivery

Our end users have many ways of shipping product to our customers. They can use the customer address in one table ([customer]), a specific delivery address in another ([dropship]), or yet another delivery address in another table (for customers with…
swasheck
  • 10,665
  • 4
  • 47
  • 88
6
votes
2 answers

Setting up filtering for server-side tracing

I'm trying to set up a server-side trace in SQL Server 2008 R2. While I have no trouble selecting events and data columns, the filtering seems a bit odd... I was trying to set up a filtering on both the duration of the SQL batch or stored procedure…
marc_s
  • 8,932
  • 6
  • 45
  • 51
1
2 3
13 14