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)

0
votes
0answers
14 views

Cursor brings back Null when run

I'm trying to create a proc which assists in creating an XMLSitepath. I am trying to use a cursor but its not behaving as it should. Please could someone take a look and tell me where I am going ...
0
votes
0answers
22 views

Questions about the SET DATEFORMAT command [on hold]

How do I set the dateformat for a column, where dates exist as '2014-12-28' and '2014-23-12' in the same column? I want it set as yyyy/mm/dd format.
0
votes
0answers
15 views

count for time periods?

I have a table with [ComputerGroupid], [Computerid], [Userid], [loginTime], [logoffTime] and I want to get a table with [ComputerGroupid], [StartTime], [endTime], [numberOfcomputerBeingUsed] I am not ...
0
votes
1answer
17 views

join on just the next closest date?

I want to get a table of [file], [folder], [DateAdded], [DateRemoved] I have a log table of changes that has [file], [ChangeDate], [OldFolder], [NewFolder] Files have moved in and out of ...
1
vote
1answer
31 views

Results for every hour of the day even data if not present

I am trying to write a query to show the count of users for each hour of the day. If there is no data for that hour, I want to record the hour with a count of zero. Source data ...
1
vote
0answers
11 views

SQL Native backup MIRROR TO performance

We are moving to SQL 2014 Expensive Edition Q1 next year. Right now we are on 2005 Standard Edition, so we don't have access to the oh-so-wonderful MIRROR TO option for our backups (We use Ola ...
3
votes
2answers
50 views

Help with SQL Query to XML output

I have the following query: SELECT [ID] AS [NewID] , ( CASE WHEN LEN([MiddleName]) > 0 THEN [LastName] + ', ' + [FirstName] + ' ' + LEFT([MiddleName],1) + '.' ...
0
votes
0answers
16 views

Suspended query causing high CPU usage

Environment detail: SQL Server 2008 R2. I have applications running on JBoss that access the DB using JDBC driver. Issue: My online DB server was experiencing high CPU usage. Using the ...
0
votes
1answer
29 views

transaction log restore

we have an external production database (maintained by another company) and we are trying to build an internal database that replicates the production database for reporting purposes (both ...
1
vote
2answers
29 views

Filling in date holes in grouped-by-date SQL data

The actual problem involves far more data and joins, but I've created a small sample to demonstrate the issue: -- create example table DROP TABLE dbo.EventRecords GO CREATE TABLE dbo.EventRecords ...
4
votes
2answers
146 views

Backup Database Task - What's the number at the end of the filename?

When using a SQL Server 2012 EMaintenance Plan for backup purposes, the Backup Database Task creates a unique filename. I understand the format all the way to the final set of numbers. For example, a ...
2
votes
0answers
16 views

How do I determine the spid of the session that is making a query on a linked server?

I have a session running on a SQL Server instance that is blocking other sessions (holding on to a lock without releasing it). Querying sys.sysprocesses yielded the hostname of a different SQL Server ...
8
votes
3answers
220 views

Retrieving n rows per group

I often need to select a number of rows from each group in a result set. For example, I might want to list the 'n' highest or lowest recent order values per customer. In more complex cases, the ...
0
votes
1answer
43 views

Is my SQL Job causing the High Disk usage?

I have a concern regarding High Average disk queue length for one of my server with below configuration: Version: SQL 2005 with SP3, standard edition. windows: version 2003 r2 SP2 No Processors= 4 ...
0
votes
1answer
24 views

The purpose of transaction log in Restore First

Based on this article , the golden role for restore first After restoring full database backup, restore latest differential database backup and all the transaction log backup after that to get ...
1
vote
0answers
34 views

Why is Update Query Slow with correct Indexes?

I have a query that updates a temp table. There are 2 Filtered indexes (by date) used in this query. However, the update take 8-10 mins to run. I am struggling to find out why it is so slow. There is ...
7
votes
0answers
35 views

Visualizing SQL Server Extended Events data

Lately I've been exploring using Extended Events in SQL Server to help me benchmark and optimize various queries. So far, to view the event data I have been using the "Watch Live Data" feature in ...
12
votes
1answer
81 views

Excessive sort memory grant

Why is this simple query granted so much memory? -- Demo table CREATE TABLE dbo.Test ( TID integer IDENTITY NOT NULL, FilterMe integer NOT NULL, SortMe integer NOT NULL, Unused ...
0
votes
0answers
13 views

How to copy architecture of an existing database to a new database in SQL Server

I'm using Microsoft SQL Server 2012 (SP1) - 11.0.3153.0 (X64) Express Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) (Hypervisor) and I need to copy the database ...
-2
votes
0answers
25 views

Can not connect to SQL Server due to low memory allocation

I accidentally set max memory to zero on Production SQL Server and SQL Server allocated 16MB which is not enough and I am not able to connect to SQL Server using SSMS. DAC is not enabled and the only ...
1
vote
1answer
32 views

Installing SQL Server 2012 - Wait on the Database Engine recovery handle failed

I am installing SQL Server 2012 SP1 on a new Windows 8.1 machine. During installation I get this error: (Screenshots similar to this question) TITLE: Microsoft SQL Server 2012 Service Pack 1 ...
-1
votes
1answer
19 views

Sorting a table based on nullable Position field that has to match the position on the result set

I'm using SQL Server 2012 I have a simple table that has a Nullable (int) Position and a (datetime) Created field. I would like to do a select * from this table order by created desc but ...if a ...
1
vote
1answer
44 views

Delete back ups more than 2 weeks in sql server

I am not a DBA, I need to delete the USER_DATABASE backups older than 2 weeks. Is this below stmt work for this scenario? EXECUTE dbo.DatabaseBackup @Databases = 'USER_DATABASE', @Directory = ...
0
votes
1answer
48 views

Update and Insert Statement taking forever

I have a database with two columns that is called using the following query: SELECT TimesUsed, Word FROM Predictions WHERE (Word LIKE @partialWord) ORDER BY TimesUsed DESC In my application it is ...
0
votes
1answer
22 views

Selecting row multiple times, as specified by a field in that row

As part of an redesign, there's need for an different schema in one of the main tables in our database. The data in one of the existing tables will be kept as legacy data. To make the changeover ...
3
votes
1answer
20 views

What is the PREEMPTIVE_REENLIST wait type in Microsoft SQL Server 2008 R2

This is not urgent, just curiosity. QUESTION: I was trying to troubleshoot a slow server today, and I came across a high figure for a wait type called PREEMPTIVE_REENLIST. I'm not able to find this ...
2
votes
3answers
61 views

Conversion of a varchar data type to a datetime data type resulted in an out-of-range value

I am trying to run a simple query to get all rows created in November: SELECT COUNT(*) FROM dbo.profile WHERE [Created] BETWEEN '2014-11-01 00:00:00.000' AND '2014-11-30 23:59:59.997'; SMSS ...
2
votes
2answers
130 views

Lines starting with colons in SQL Server

Playing around with DB projects, Visual Studio generated a change script with the following lines: GO SET ANSI_NULLS, ANSI_PADDING --etc.; SET NUMERIC_ROUNDABORT OFF; GO :setvar DatabaseName "Foo" ...
-1
votes
0answers
31 views

SQL Server 2008 R2: After Insert Trigger and Query returning unexpected results for a split second

I am having trouble with an After Insert trigger and a query running right afterwards. The query goes and finds the most current record in each table by using OUTER APPLY with a table-valued ...
2
votes
3answers
433 views

Releasing Free Space

I am running a rather large database on SQL Server 2008 R2 Express. Recently I hit the 10GB limit, so the system would not allow me to create anymore objects, ect.. I have archived off a very large ...
1
vote
1answer
59 views

Indexed View - how to verify if it is worthy?

I have the following indexed view: CREATE view VProcessStatus WITH SCHEMABINDING AS select processstatus, StatusCount = COUNT_BIG(*) FROM DBO.tbltaxtransaction GROUP BY ...
1
vote
1answer
16 views

Create a log file for check which time import has been done and to split the import files

How to create a log table for when does the last import has been done and also for Query for split the records in to 1000 while importing. to avoid the bulk insert For example : If the data ...
4
votes
2answers
53 views

Using Database Engine Tuning Advisor in production

I have a SQL Server 2008R2 OLTP database which is experiencing performance issues during work hours. I would like to run Database Engine Tuning Advisor on this instance but I don't know how it will ...
0
votes
3answers
59 views

I do not understand SQL Server Transaction Logs

I understand that a Microsoft SQL Server Database has two components: A database file A transaction log file Whenever I make a change to a table, does it get written to both the database file AND ...
-1
votes
0answers
29 views

Database design for different wildlife types

I am planning to design a database for wildlife details (such as fishes, birds, and animals) in a certain state, e.g. what kind of wildlife is present. I have created a table in SQL Server 2014 in ...
4
votes
0answers
25 views

Enabling TDE in SQL Server with mirror without breaking existing mirror

I've been trying to enable TDE in a mirrored SQL Server 2008 R2 configuration. Enabling TDE is not so difficult, though when I enable TDE on the principal, the mirror database goes in to a suspended ...
0
votes
1answer
70 views

Small business SQL Server

I'm asking the experts.. I work in a small business (<10 employees) but I need a production database. I wouldn't go as to say I'm a DBA but I well versed in creating databases, tables, ...
2
votes
1answer
126 views

Alter table and update in sql server transactions

I'm trying to do an alter table to add a new column on a table, then I would like to do some update on the existing rows in the table to add a value to the recently new added column and finally do a ...
3
votes
1answer
40 views

for xml missing null columns

When we use for xml clause to create xml from a row like as follows select * from Menus where MenuID=100 for xml path('') The xml will miss the columns which have NULL as the value. I have a found ...
-2
votes
0answers
44 views

What are the alternates to replication? [duplicate]

I don't have any experience with database administration. What are the alternatives to replication in SQL Server (one-way)? I am looking for an alternative mainly because of the licensing. The ...
1
vote
0answers
9 views

“Skipping the default startup of database” SQL notification for AlwaysOn Cluster

So I set up our SQL servers to notify us of alerts at severity 17 or higher (as advised by various SQL Server articles). I've done this to each node of a SQL Server Always On Availability Cluster, ...
2
votes
2answers
65 views

What SQL Server database version do I need?

I am not a database experts but part of the project I am currently interested in accepting requires to do a DB replication. The system will have many outlets... says Site A, Site B, Site C, etc.. ...
2
votes
1answer
47 views

Threshold for sort spill and random cardinality estimates

I wanted to test tempdb spill warnings so I run the following script on SQL Server 2014: USE tempdb IF OBJECT_ID('tempdb..tblTest') IS NOT NULL DROP TABLE tblTest CREATE TABLE tblTest ( ...
-1
votes
1answer
46 views

How to know which columns value is different between two rows

I am trying to compare two addresses from the same ID to see whether they match. For example: Id Adress Code Address 1 1 123 Main 1 2 123 Main 2 1 ...
1
vote
1answer
39 views

How to join a table with a table valued function?

I have a user defined function: create function ut_FooFunc(@fooID bigint, @anotherParam tinyint) returns @tbl Table (Field1 int, Field2 varchar(100)) as begin -- blah blah end Now I want to join ...
1
vote
1answer
32 views

Dual site active-active highly available database

I have an application that is being run on two separate sites. Ideally they would share a database, because each application needs to see what the other is writing to the database. However, the sites ...
1
vote
1answer
37 views

Create copy of Azure SQL Database using SQL Server Management Studio

When running the following query on an Azure SQL Database "Master" in SQL Server Management Studio: CREATE DATABASE myDbBackup AS COPY OF myDb; The following error is produced: Msg 40818, Level ...
2
votes
1answer
83 views

Database with multiple .mdf files

I have search online but not found what I am looking for. The problem/query is to my knowledge a database in SQL Server should have One .mdf file and maybe some .ndf files and One .log file. I ...
2
votes
1answer
67 views

Ola Hallengren index maintenance - long periods of time between commands?

I run the Ola Hallengren scripts on all of my servers for index and statistics maintenance. When I look through the command log table, I notice long periods of time between a command ending, and the ...
0
votes
2answers
17 views

ASPStateTempApplications and ASPStateTempSessions tables creation in tempdb after sql server restart

I have a implemented SQL server session state management. So created ASPState database and ASPStateTempApplications and ASPStateTempSessions tables in TEMPDB database. When I restart SQL Service, ...