Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 807

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

2 votes

How can I remove an index scan from a SQL Server SELECT statement?

One approach that might help would be to specify the (few) columns you actually need instead of just using the "blanket" SELECT *..... When you define a small set of columns to retrieve, you might b …
marc_s's user avatar
  • 9,012
7 votes

How to create unique index for month and year column?

Assuming you have a column of type DATE or DATETIME2 (or DATETIME), you can define two computed, persisted columns for year and month and put an unique index on those: ALTER TABLE dbo.YourTable ADD D …
marc_s's user avatar
  • 9,012
17 votes
Accepted

How to change the instance name of SQL Server Express 2008?

There is no way to change the instance name without re-installing, sorry..... Update: OK, seems there are a few ways of doing this - not sure how well these work, though. I have not ever heard of any …
marc_s's user avatar
  • 9,012
2 votes
Accepted

Is there a way to view the body / contents of a system function in sql server 2008

I don't think Sum is stored as a T-SQL function in your system that you could "peek" into. That's most likely code deep inside the SQL Server core. As a proof - you can e.g. get the body of other sys …
marc_s's user avatar
  • 9,012
4 votes

How SQL server database reorganize memory

SQL Server does its own database file management - it does grow your .mdf file every time you need a few bytes more space. Instead, for each database file, you've defined an initial size and how it w …
marc_s's user avatar
  • 9,012
3 votes

how to select * from XML where id=1?

Try this: select XRows.query('.') FROM @xml.nodes('/row') AS XTbl(XRows) WHERE XRows.value('(Id)[1]', 'int') = 1 This will return the entire <row> XML element as XML
marc_s's user avatar
  • 9,012
8 votes
Accepted

PK Fragmentation on INT IDENTITY column

A primary key on a INT IDENTITY ought to be very close to optimal, and as such should not lead to a significant index fragmentation. However: since your PK is (by default and unless you specifically …
marc_s's user avatar
  • 9,012
133 votes
Accepted

How to force drop database in SQL Server 2008

That is expected and documented behavior: Dropping a database deletes the database from an instance of SQL Server and deletes the physical disk files used by the database. If the database or any o …
marc_s's user avatar
  • 9,012
4 votes

Attaching MDF without LDF

You could try this - if your MDF is intact (which according to your error message it doesn't seem to be.....): USE master GO CREATE DATABASE Test_Data ON PRIMARY (FILENAME = N'D:\Test_Data\Test_Da …
marc_s's user avatar
  • 9,012
14 votes
Accepted

What is the difference between SQLEXPRESS and MSSQLSERVER?

You can install multiple copies of SQL Server onto the same machine. To keep them apart, all "copies" (called instances) except the first (default) one have to be named. So by default, when you insta …
marc_s's user avatar
  • 9,012
158 votes
Accepted

How to query last restore date in SQL Server?

This will list all "most recent" restores for each database on your server: WITH LastRestores AS ( SELECT DatabaseName = [d].[name] , [d].[create_date] , [d].[compatibility_level] , [ …
marc_s's user avatar
  • 9,012
11 votes
Accepted

Deny access to information schema in SQL Server

You should be able to just deny permissions on the entire sys and information_schema schema as a whole: DENY SELECT On SCHEMA::sys To [user_name] DENY SELECT On SCHEMA::INFORMATION_SCHEMA To [user_na …
marc_s's user avatar
  • 9,012