Questions tagged [sql-server-2008-r2]

Use this tag for questions specific to the 2008 R2 version of Microsoft's SQL Server.

Important Note: Extended support for SQL Server 2008 (including 2008 R2) ended on July 9, 2019.

Microsoft will no longer release security updates for any version of SQL Server 2008. Don't let your infrastructure and applications go unprotected. We're here to help you migrate to current versions for greater security, performance and innovation.

If you are still using 2008 R2 version you should seriously consider upgrading.

SQL Server 2008 R2 (codename Kilimanjaro, version 10.50), released in April 2010, is the successor to SQL Server 2008.

This version of Microsoft SQL Server is the 3rd form to utilize the .Net framework for operating with a database framework.

This product includes:
  • Server/Database/Table Triggers
  • Stored Procedure (SProc) & Functions
  • Database Maintenance processes & features
  • Automated SQL Agent with time triggers

Reference

11320 questions
68
votes
8 answers

Using IF ELSE statement based on Count to execute different Insert statements

While I am searching through my database, I run an INSERT statement if I find that a particular item does not exist, and I run a different INSERT statement if I find one or more of this item. I am not entirely sure how to use the IF ELSE…
user1934821
  • 727
  • 1
  • 8
  • 10
66
votes
10 answers

How to rewrite IS DISTINCT FROM and IS NOT DISTINCT FROM in SQL Server 20008R2?

How do you rewrite expressions containing the standard IS DISTINCT FROM and IS NOT DISTINCT FROM operators in the SQL implementation in Microsoft SQL Server 2008R2 that does not support them?
Jason Kresowaty
  • 16,105
  • 9
  • 57
  • 84
65
votes
5 answers

Explicitly drop temp table or let SQL Server handle it

What is best practice for handling the dropping of a temp table. I have read that you should explicitly handle the drop and also that sql server should handle the drop....what is the correct method? I was always under the impression that you should…
scarpacci
  • 8,957
  • 16
  • 79
  • 144
64
votes
5 answers

What is the syntax meaning of RAISERROR()

I just created a Instead After Trigger whose syntax is given below: Create trigger tgrInsteadTrigger on copytableto Instead of Insert as Declare @store_name varchar(30); declare @sales int; declare @date datetime; select…
63
votes
10 answers

Create a view with ORDER BY clause

I'm trying to create a view with an ORDER BY clause. I have create it successfully on SQL Server 2012 SP1, but when I try to re-create it on SQL Server 2008 R2, I get this error: Msg 102, Level 15, State 1, Procedure TopUsers, Line 11Incorrect …
El Sa7eR
  • 881
  • 3
  • 10
  • 17
63
votes
6 answers

Getting error while running 50 MB script on SQL Server 2008 R2

I am using SQL Server 2008 R2, I have a script to update the DB, that script is approx 50 MB in size and contains some about 800,000 lines. Error: TITLE: Microsoft SQL Server Management Studio Cannot execute script. ADDITIONAL…
Vikrant More
  • 5,182
  • 23
  • 58
  • 90
62
votes
11 answers

Remote Procedure call failed with sql server 2008 R2

I am working with SQL Server 2008 R2. I am unable to connect to my database remotely. I got the following error. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was…
Karthik Bammidi
  • 1,851
  • 9
  • 31
  • 65
60
votes
6 answers

SQL list of all the user defined functions in a database

I am looking for a SQL query that outputs the function definitions for all of the user defined functions in a database catalog. I have found as far as SELECT OBJECT_DEFINITION (OBJECT_ID(N'dbo.UserFunctionName')) AS [Object Definition] and SELECT…
stackuser83
  • 2,012
  • 1
  • 24
  • 41
60
votes
3 answers

How to use a CTE statement in a table-valued function in SQL Server

I have come to understand that some versions of Microsoft OLE DB Provider for SQL Server (mostly on Windows XP) do not support WITH statement. So, I decided to move my SQL statement into a table-valued function, and call it from my application. Now,…
iMan Biglari
  • 4,674
  • 1
  • 38
  • 83
60
votes
7 answers

Unique key vs. unique index on SQL Server 2008

I have a table called countries and I define the country_name column to be unique by creating a “Index/Key” of type “Unique Key” on SQL Server 2008 R2. But I have the following questions: will creating “Index/Key” of type “Unique Key”…
John John
  • 1
  • 72
  • 238
  • 501
59
votes
9 answers

How to find out what is locking my tables?

I have a SQL table that all of a sudden cannot return data unless I include with (nolock) on the end, which indicates some kind of lock left on my table. I've experimented a bit with sys.dm_tran_locks to identify that there are in fact a number of…
58
votes
6 answers

Get last 30 day records from today date in SQL Server

I have small question about SQL Server: how to get last 30 days information from this table Sample data: Product: Pdate ---------- 2014-11-20 2014-12-12 2014-11-10 2014-12-13 2014-10-12 2014-11-15 2014-11-14 2014-11-16 2015-01-18 Based on this…
58
votes
1 answer

Error Invalid prefix or suffix characters in SQL Server Management Studio

When I try to edit table data in SQL Server Management Studio 2008 R2 (right click in table object, Edit Top 200 rows) I receive this error: "Invalid prefix or suffix characters. (MS Visual Database Tools)".
Renzo Ciot
  • 3,746
  • 2
  • 25
  • 29
57
votes
20 answers

IntelliSense is not working in SQL Server Management Studio

We use SQL Server Management Studio 2008 R2. IntelliSense works with SA account perfectly. But it is not working with Windows Authentication user. The user has access master db with db_owner role but it's not sysadmin. How do I fix this issue?
Ethem Kuloglu
  • 703
  • 1
  • 5
  • 9
57
votes
9 answers

T-SQL split string based on delimiter

I have some data that I would like to split based on a delimiter that may or may not exist. Example data: John/Smith Jane/Doe Steve Bob/Johnson I am using the following code to split this data into First and Last names: SELECT SUBSTRING(myColumn,…
Sesame
  • 3,370
  • 18
  • 50
  • 75