Microsoft's SQL Server is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. It originated from the Sybase SQL Server codebase, which is why both products use the extension of SQL called Transact-SQL (T-SQL).

learn more… | top users | synonyms (2)

2
votes
1answer
2k views

Prevent a single query from hogging all resources

I have a production database server running SQL Server 2008 R2. How can I keep a user query on one database from hogging all the system resources and bogging down all the databases on the server? The ...
17
votes
2answers
21k views

When To Update Statistics?

I've inherited a Maintenance Plans that does the following: Cleanup old data Checks DB integrity Performs Database and Transaction Log Backups Reorganizes Our indexes Updates Statistics Delete old ...
2
votes
2answers
2k views

How to log successful login attempts to a database?

Is there a way to log database name when auditing logins in SQL Server (2005 and above)? I basically want to log the username and the database name the user successfully connected to. I have tried ...
5
votes
1answer
413 views

SQL Server Linked server query problem (group by)

I have been using an old SQL Server 2000 installation for a long time that is linked to several Oracle servers, and it all works very well. I am trying to migrate to SQL Server 2012 via SQL Server ...
11
votes
4answers
4k views

Sort order specified in primary key, yet sorting is executed on SELECT

I'm storing sensor data in a table SensorValues. The table and primary key is as follows: CREATE TABLE [dbo].[SensorValues]( [DeviceId] [int] NOT NULL, [SensorId] [int] NOT NULL, [SensorValue] ...
2
votes
2answers
474 views

How can we automatically replace a table with a view for a specific user?

We currently have some reports that query a specific table, but one of our users wants the ordering to be different. I don't want to go through and fix each of the reports, because that's rather a ...
0
votes
3answers
538 views

Can a RDBMS connect to a remote server, execute a select query and copy them into a local table just with SQL commands?

I'm sorry it may sound stupid but I've been wondering about how multiple databases are automated before the virtualization era. Can a DB Adminsitrator make a stored procedure to get data from a remote ...
5
votes
1answer
493 views

SQL Server 2008 Multi Page Allocation

When a query or stored procedure has an execution plan greater than 8000 bytes, instead of using plan cache in buffer pool, it will use MPA (multi page allocator) which used memory outside buffer ...
3
votes
1answer
7k views

Create a view with dynamic column headers based on original table row data? [closed]

Given the two sample tables here: Tickets Table ID User Description ------------------------------------ 0 James This is a support ticket 1 Fred This is a ticket too Properties ...
1
vote
1answer
2k views

Why do I only see SYS and INFORMATION_SCHEMA tables? Access 2007 ODB to SQL Server 2008

I was finally able to create my ODBC connection but now when I go to External Data > ODBC > LINK TABLES using my ODBC connection in Access 2007 I get a huge list of tables such as ...
6
votes
2answers
950 views

Parameter Sniffing: Why Does This Become An Issue?

Today, I had an issue with a SPROC Timing Out (took longer than 30 seconds) when it was run from an ASP.NET webpage, but executed quickly when run from SSMS (took 5 seconds). After suspecting ...
3
votes
2answers
474 views

SQL Server 2008 ODBC

My SQL Server 2008 is located on a remote computer so I am trying to create an ODBC connection using SQL Server Authentication. My problem is that the way i normally connect to my SQL Server is by ...
5
votes
1answer
604 views

Are SQL Server's Date values stored as a single int?

SQL Server stores DATETIME internally as two INT values, as SQLDenis explains. Is it correct (by logical extension) that DATE types (SQL Server 2008+) are stored as a single INT?
3
votes
1answer
151 views

How to update conflict resolver when upgrading from SQL-Server 2005 to SQL-Server 2008

We have recently upgraded from SQL Server 2005 to SQL Server 2008 (R2, SP1). This upgrade included some publications, where all tables are published with a default conflict resolver based on the ...
1
vote
2answers
23k views

Convert Rows to columns using 'Pivot' in SQL Server when columns are string data type

I need to know whether 'pivot' in SQL Server can be used for converting rows to columns if there is no aggregate function to be used. I saw lot of examples with aggregate function only. My columns are ...
2
votes
1answer
563 views

SQL 2012: Import DB changes original data scheme

I'm migrating data from SQL 2008 R2 Servers to SQL 2012. Therefore I'm using SSMS Import Data Task on the SQL 2012 machines. As a test I copied the data files of one of the DBs, did an "Attach ...
2
votes
2answers
626 views

How To Set Up Web Synchronisation With IIS 7.5

I set up merge replication web sync using a pull subscription. When I try to start the merge agent at the client side I get this error, The Merge Agent could not connect to the URL ...
5
votes
1answer
752 views

Custom aggregation for non-leaf level nodes to avoid double counting

I have a fact table with the following columns: WorkerName OrderId NumberOfPackagesPerOrder Note that neither WorkerName nor OrderId is unique in this fact table. Multiple users could work on a ...
1
vote
1answer
1k views

SQL Server 2008 R2 : multiple files and filegroup

I am getting bit confused regarding advantages of multiple files and filegroups in SQL Server Using SQL Server 2008 R2, I have following filegroups and files configuration Drive D: Primary Filegroup ...
6
votes
2answers
9k views

Create new function by code if it doesn't exist

I want to create new function by script in my database. The script code is below: IF Exists(Select * From sys.sysobjects A Where A.name =N'fn_myfunc' and xtype=N'FN') return; CREATE FUNCTION ...
5
votes
1answer
311 views

difference of left join and left outer join

In SQL Server join syntax we can use LEFT JOIN or LEFT OUTER JOIN and query result with each of above join not difference. this is a question for me that which are more useful.
10
votes
1answer
746 views

Why does 10^37 / 1 throw an arithmetic overflow error?

Continuing my recent trend of playing with large numbers, I recently boiled an error I was running into down to the following code: DECLARE @big_number DECIMAL(38,0) = '1' + REPLICATE(0, 37); PRINT ...
6
votes
2answers
204 views

How to script database validations?

I want to create a smart way to execute a SQL script when rolling out DB changes into QA, UAT and production environments in order to smoke test database changes are correct after maintenance has been ...
5
votes
1answer
576 views

Why is the page life expectancy 0 (zero) on SQL Server 2005

We have been wanting to know the page life expectancy for our SQL Server. So we look at the counter using Perform. The value is ZERO and never changes. I thought there must be some bug, so I checked ...
2
votes
2answers
1k views

Query intermittently fails with “The multi-part identifier could not be bound”

I've got Schrodinger's query here; you can run it once successfully, then 5 times in a row, and it works fine. Change anything in the query, even whitespace, run it again, and it might stop working ...
1
vote
2answers
504 views

Tools for Identifying Needed Indexes

I want to create the best indexes for each table in my database. Is there a query or tool in SQL Server to help with this process?
2
votes
1answer
898 views

Resource Usage Statistics by Login

Is there a way to get resource usage statistics by login in SQL Server? Ideally, I'd like to have a version of sys.dm_exec_sessions that tracks usage for all sessions, rather than just the ...
5
votes
3answers
1k views

Some book suggestions for performance tuning

I am in the process of improving performance on our database application. While I am not a DBA, I am pretty comfortable with SQL. I am after a book that can help me understand how queries written in ...
-1
votes
1answer
79 views

Index Proposals

As a theoretical database question, if you are asked 'which indexes would you propose and why?' are the answers from primary, clustering and secondary index? How would we know if we should introduce ...
2
votes
1answer
299 views

Calculate number for each row

My table structure is below: CREATE TABLE [ACC].[Document]( [DocumentID] [int] IDENTITY(1,1) NOT NULL, [Date] [date] NOT NULL, [SalesCompanyFinancialPeriodID] [int] NOT NULL, ...
2
votes
1answer
636 views

Any problem with same conversation handle used by multiple services communicating with one target queue in a multiplexed service broker order queue?

I asked a question about implementing conversation groups in a SQL Service Broker setup which has several User Services communicating with the Server Service (Processing xml data requests to be sent ...
-2
votes
1answer
3k views

How can I get my LEFT OUTER JOIN to work in SQL Server 2008?

I trying to create a table with this school data in it? Year Month Days Referrals 2012 1 16 10 2012 2 20 7 2012 3 15 11 Year, Month and Count of Days from one ...
3
votes
1answer
449 views

Limiting database security

A number of texts signify that the most important aspects offered by a DBMS are availability, integrity and secrecy. As part of a homework assignment I have been tasked with mentioning attacks which ...
3
votes
2answers
617 views

can I add a custom SSRS e-mail subscription that forces the “TO” address

I would like to know if it is possible to add a custom delivery extension(?) in SSRS that will enable me to force a value into the "TO" address for particular subscriptions? Big picture: I am ...
1
vote
2answers
1k views

Convert datetime stored as char the YYYMMDDHHmmSS format to datetime

I'm working with a table where the date and time of an event is stored as a char in the format YYYMMDDHHmmSS or '20120606122012'. I need to compare this to the current timestamp to see if it's been ...
5
votes
2answers
694 views

Release SQL Server Memory usage

How can release memory usage of sql server by command. my system have 16GB RAM, but when get huge query by sql server, memory usage become full. if I restart SQL Server service memory usage become ...
3
votes
1answer
638 views

Service Broker Procedure that will be used by multiple initiators to begin dialog conversation.. how to pass a parameter into it

The standard format for beginning a dialog is like this: Declare @dialog_handle UNIQUEIDENTIFIER BEGIN DIALOG CONVERSATION @dialog_handle FROM SERVICE initiator_1 TO SERVICE 'target_1' ON ...
6
votes
2answers
7k views

How to get last identity row Inserted when using instead of trigger

When I insert into tables using instead of triggers, @@Identity, IDENT_CURRENT('Table') and SCOPE_IDENTITY() return null. How I can get the last identity of inserted row?
1
vote
1answer
621 views

How to sync a table between oracle and sybase

I have a table in Sybase (destination) that I would like to keep it synced with a table in Oracle (source) I cannot truncate and populate the table in Sybase because it is used by an application, I ...
2
votes
2answers
123 views

Ways to stop access to a SQL express database

I have a SQL express database and was wondering what options I have for securing it? More specifically it is a replicated database using merge replication. I want to stop a user with a replicated ...
2
votes
1answer
483 views

How does merge replication work with SQL Server CE

I have been trying out merge replication with SQL Server databases, and was just wondering how merge replication works on SQL Server CE? For instance merge replication with SQL Server databases ...
3
votes
1answer
2k views

How does performance of SQL Server CE and SQL Server Express compare?

We have an application that runs on netbooks. It currently uses a SQL Server CE 3.5 database, and we are thinking of upgrading to SQL Server Express. Just wonder if there are any benchmarks to ...
7
votes
1answer
805 views

Transactional replication from SQL Server 2000 to 2008

I have legacy databases on two SQL Server 2000 servers that I am trying to replicate to a SQL Server 2008 R2 database using transactional replication. The 2008 server is not in the same LAN, so I am ...
4
votes
2answers
114 views

Mirroring and Buffer Page Write/s

Is the "Buffer Manager: Page writes/sec" (* 8 KBytes) a good indicator of how much bandwidth will be used to replicate all databases via Availability Groups? If not, why are these not equivalent? Is ...
4
votes
2answers
3k views

Using the correct database when calling a system stored procedure in SQL Server 2008

I think there's something I'm missing when it comes to which database is being used when running a custom system stored procedure. I have the following in my stored procedure (edited for brevity): ...
5
votes
1answer
6k views

sql server , set N prefix as unicode for all queries by default

Is there any option in ms sql server which use N prefix for my database. There are many query in my application which non of them use N prefix for nvarchar fields , and now I have to set N for all of ...
7
votes
2answers
377 views

Why do we have SHRINKDATABASE command in SQL Server

I have read across the internet where Finest Developer says shrinkdatabse should be avoided as it causes increase in fragmentation and decrease in performance . I would like to know from you guys ...
4
votes
1answer
274 views

What Happens When Identity Range IsExceeded?

I am using identity columns in my merge replication solution to give people an id they can tell us over the phone (i.e. to support staff). A rowguid column would be too hard for this. I have noticed ...
7
votes
1answer
2k views

Recursive CTE performance

Need help with recursive CTE performance. Below CTE is running very slow as it is trying to pull heirarchical data recusively. Table is big with every root id having upto 3 recursive itemid. There ...
2
votes
1answer
363 views

Multiple Publications for Merge Replication?

I am designing a system which will have one SQL server 2012 central database. Each client will user merge replication to take an offline copy of their data to edit on the road. If I add a ...