Questions tagged [sql-server-2008]

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

Extended support for SQL Server 2008 and 2008 R2 have ended on July 9, 2019. That means the end of regular security updates. (source: SQL Server 2008 End of Support.)

If you're still using SQL Server 2008, you should seroiusly consider upgrading your SQL Server to a supported version.

SQL Server 2008 (codename Katmai, version number 10.00) was released on August 6 2008, and aims to make data management self-tuning, self organizing, and self-maintaining with the development of SQL Server Always On technologies, to provide near-zero downtime. SQL Server 2008 also includes support for structured and semi-structured data, including digital media formats for pictures, audio, video, and other multimedia data. In current versions, such multimedia data can be stored as BLOBs (binary large objects), but they are generic bitstreams. Intrinsic awareness of multimedia data will allow specialized functions to be performed on them. According to Paul Flessner, Senior Vice President, Server Applications, Microsoft Corp., SQL Server 2008 can be a data storage backend for different varieties of data: XML, email, time/calendar, file, document, spatial, etc as well as perform search, query, analysis, sharing, and synchronization across all data types.

Other new data types include specialized date and time types and a Spatial data type for location-dependent data. Better support for unstructured and semi-structured data is provided using the new FILESTREAM data type, which can be used to reference any file stored on the file system. Structured data and metadata about the file is stored in the SQL Server database, whereas the unstructured component is stored in the file system. Such files can be accessed both via Win32 file handling APIs as well as via SQL Server using T-SQL; doing the latter accesses the file data as a BLOB. Backing up and restoring the database backs up or restores the referenced files as well. SQL Server 2008 also natively supports hierarchical data and includes T-SQL constructs to directly deal with them, without using recursive queries.

The Full-text search functionality has been integrated with the database engine. According to a Microsoft technical article, this simplifies management and improves performance. Spatial data will be stored in two types. A "Flat Earth" (GEOMETRY or planar) data type represents geospatial data which has been projected from its native, spherical, coordinate system into a plane. A "Round Earth" data type (GEOGRAPHY) uses an ellipsoidal model in which the Earth is defined as a single continuous entity which does not suffer from the singularities such as the international dateline, poles, or map projection zone "edges". Approximately 70 methods are available to represent spatial operations for the Open Geospatial Consortium Simple Features for SQL, Version 1.1.

SQL Server includes better compression features, which also helps in improving scalability. It enhanced the indexing algorithms and introduced the notion of filtered indexes. It also includes Resource Governor that allows reserving resources for certain users or workflows. It also includes capabilities for transparent encryption of data (TDE) as well as compression of backups. SQL Server 2008 supports the ADO.NET Entity Framework and the reporting tools, replication, and data definition will be built around the Entity Data Model. SQL Server Reporting Services will gain charting capabilities from the integration of the data visualization products from Dundas Data Visualization, Inc., which was acquired by Microsoft. On the management side, SQL Server 2008 includes the Declarative Management Framework which allows configuring policies and constraints, on the entire database or certain tables, declaratively. The version of SQL Server Management Studio included with SQL Server 2008 supports IntelliSense for SQL queries against a SQL Server 2008 Database Engine. SQL Server 2008 also makes the databases available via Windows PowerShell providers and management functionality available as Cmdlets, so that the server and all the running instances can be managed from Windows PowerShell.

Source

53837 questions
106
votes
15 answers

Listing information about all database files in SQL Server

Is it possible to list information about the files (MDF/LDF) of all databases on an SQL Server? I'd like to get a list showing which database is using what files on the local disk. What I tried: exec sp_databases all databases select * from…
M4N
  • 94,805
  • 45
  • 217
  • 260
106
votes
8 answers

Is there a way to persist a variable across a go?

Is there a way to persist a variable across a go? Declare @bob as varchar(50); Set @bob = 'SweetDB'; GO USE @bob --- see note below GO INSERT INTO @bob.[dbo].[ProjectVersion] ([DB_Name], [Script]) VALUES (@bob,'1.2') See this SO question for the…
NitroxDM
  • 5,039
  • 10
  • 44
  • 56
106
votes
3 answers

FULL OUTER JOIN vs. FULL JOIN

Just playing around with queries and examples to get a better understanding of joins. I'm noticing that in SQL Server 2008, the following two queries give the same results: SELECT * FROM TableA FULL OUTER JOIN TableB ON TableA.name =…
CptSupermrkt
  • 6,844
  • 12
  • 56
  • 87
105
votes
11 answers

What's the best way to store co-ordinates (longitude/latitude, from Google Maps) in SQL Server?

I'm designing a table in SQL Server 2008 that will store a list of users and a Google Maps co-ordinate (longitude & latitude). Will I need two fields, or can it be done with 1? What's the best (or most common) data-type to use for storing this kind…
Jonathan
  • 32,202
  • 38
  • 137
  • 208
104
votes
5 answers

What does "select 1 from" do?

I read some articles but really didn't understand what does select 1 from do? Someone says "you should use select 1 instead of select *". Here is an example table: cust_id cust_name cust_address 1000000001 Village Toys …
Mehmet
  • 1,435
  • 4
  • 13
  • 15
104
votes
6 answers

Compare dates using SQL Server

I have two dates (datetimes): date1 = 2010-12-31 15:13:48.593 date2 = 2010-12-31 00:00:00.000 It's the same day, just different times. Comparing date1 and date2 using <= doesn’t work because of the date1 time. So date1 <= date2 is wrong, but it…
grady
  • 12,281
  • 28
  • 71
  • 110
103
votes
3 answers

How to catch SqlException caused by deadlock?

From a .NET 3.5 / C# app, I would like to catch SqlException but only if it is caused by deadlocks on a SQL Server 2008 instance. Typical error message is Transaction (Process ID 58) was deadlocked on lock resources with another process and has…
Joannes Vermorel
  • 8,976
  • 12
  • 64
  • 104
102
votes
5 answers

Comma separated results in SQL

I have the following code which will create a comma delimited list for my results: DECLARE @listStr VARCHAR(MAX) SELECT @listStr = COALESCE(@listStr+', ' ,'') + INSTITUTIONNAME FROM EDUCATION WHERE STUDENTNUMBER= '111' SELECT @listStr The problem…
PriceCheaperton
  • 5,071
  • 17
  • 52
  • 94
101
votes
8 answers

Simple DateTime sql query

How do I query DateTime database field within a certain range? I am using SQL SERVER 2005 Error code below SELECT * FROM TABLENAME WHERE DateTime >= 12/04/2011 12:00:00 AM AND DateTime <= 25/05/2011 3:53:04 AM Note that I need to get rows…
ove
  • 3,092
  • 6
  • 34
  • 51
101
votes
2 answers

How can I have multiple common table expressions in a single SELECT statement?

I am in the process of simplifying a complicated select statement, so thought I would use common table expressions. Declaring a single cte works fine. WITH cte1 AS ( SELECT * from cdr.Location ) select * from cte1 Is it possible to…
Paul Rowland
  • 8,244
  • 12
  • 55
  • 76
100
votes
5 answers

Find all columns of a certain type in all tables in a SQL Server database

How can I find all columns of a certain type (for example NTEXT) in all tables in a SQL Server database? I am looking for a SQL query.
SwissCoder
  • 2,514
  • 4
  • 28
  • 40
100
votes
5 answers

Clustered vs Non-Clustered

My lower level knowledge of SQL (Server 2008) is limited, and is now being challanged by our DBAs. Let me explain (I have mentioned obvious statements in the hope that I am right, but if you see something wrong, please tell me) the scenario: We have…
Craig
  • 18,074
  • 38
  • 147
  • 248
100
votes
7 answers

Script entire database SQL-Server

Is there a way I can get a scripting of all tables, procs, and other objects from a database? I know there's an option to script the database but it only gave me some sort of top level script, certainly not a script to create all tables, procs,…
PositiveGuy
  • 46,620
  • 110
  • 305
  • 471
99
votes
10 answers

How to get the size of a varchar[n] field in one SQL statement?

Suppose that I have a SQL table that has a varchar[1000] field called "Remarks". I would like to craft a single SQL statement, which when executed, will return 1000, or whatever the size of the varchar field might be changed to in the…
Vivian River
  • 31,198
  • 62
  • 198
  • 313
97
votes
9 answers

Database design: Calculating the Account Balance

How do I design the database to calculate the account balance? 1) Currently I calculate the account balance from the transaction table In my transaction table I have "description" and "amount" etc.. I would then add up all "amount" values and that…
001
  • 62,807
  • 94
  • 230
  • 350