Tagged Questions

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)

3
votes
2answers
152 views

How to create a secondary read-only reporting database with < 15 minute latency

We have a 2012 standard edition instance that is doing log-shipping of 2 related databases every 15 minutes to a secondary 2012 standard edition instance for DR purposes. Although it provides ...
4
votes
1answer
179 views

What is the correct way to ensure unique entries in a temporal database design?

I'm having trouble with the design of a temporal database. I need to know how to make sure I have only one active record for any given timeframe for a store. I have read this answer, but I'm afraid I ...
2
votes
2answers
110 views

Restricting Database Access/Functions to User Groups?

We've been having issues with Databases being DROPed or RESTOREd WITH REPLACE with the incorrect backup etc... I'm developing a plan right now on how to restrict access and I have some questions. ...
5
votes
3answers
324 views

What are some important security-related error codes / events to monitor?

I am setting up alerts in SQL Server and am interested in what events I should be raising alerts for. In particular, I am looking for any events related to security. I am already monitoring error ...
2
votes
1answer
101 views

Select query - group by and sub group by

CREATE TABLE [dbo].[temptable] ( [Id] INT NOT NULL PRIMARY KEY IDENTITY, [uid] INT NOT NULL, [pid] INT NOT NULL, [event] INT NOT NULL, [timeStamp] DateTime NOT NULL ) I want ...
0
votes
1answer
68 views

MS Access migration from Oracle to SQL server?

Let me start off by saying I'm relatively new to databases etc. I have been asked to undergo a project is which I will attempt to migrate about 100 or so existing MS access 2003 databases from using ...
0
votes
3answers
571 views

I can't restore my database on SQL Server 2012. Exceeds size

I'm trying to restore a database from a .bak file. The file is only 89.3 mb large. I'm using the restore with replace option, so that all other data in the database is removed. We are just trying to ...
1
vote
0answers
376 views

Calculate the compound interest with variable annual rate

I'm moving this question from SO Some years ago I was asked to create something to calculate the current value of a lot of insurance policies, I came out with a query that worked fine, but I was ...
0
votes
0answers
71 views

Set max memory lower than minimal

I dont know the best way to fix that, but for lucky now I am using one Transactional Replication Repository server, please someone can save me? The main server is down beacuse I set the max memory to ...
0
votes
1answer
183 views

Failover Cluster - Add Witness Disk?

I'm trying to build SQL Server 2012 Cluster on top of Windows Cluster 2008R2. Can anyone please suggest.. do we need quorum disk in setting up SQL cluster 2012 on top of windows cluster 2008r2
2
votes
1answer
2k views

Writing a query to find all employee salaries that are higher than their managers

I have two tables with some dummy data. I need to find all employees that make more than their managers. I was led to believe the point of the exercise is to learn how to do subqueries. I can isolate ...
2
votes
2answers
342 views

How to do a one-time log shrink on a database with transactional replication

I have inherited a 10 GB database with an 80 GB log [only 3% in use according to DBCC SQLPERF(logspace)]. It seems safe to assume the extreme log growth was due to problems from long before I was ...
1
vote
1answer
46 views

restore database using bak file - resorting to old date?

Last night I made a full backup of my DB in SQL server management, when I restore the DB instead of being complete - it is missing all its data from the last few month. The full backup was taken ...
0
votes
1answer
2k views

Trigger to update a date field on one table when another table is updated

I want to be able to update a date filed in one table when another table is updated. I have the following two tables: Transdetails, Customers. In the Customers table I have a field called ...
11
votes
3answers
658 views

Get streak count and streak type from win-loss-tie data

I made a SQL Fiddle for this question if that makes things easier for anyone. I have a fantasy sports database of sorts and what I'm trying to figure out is how to come up with "current streak" data ...
0
votes
1answer
107 views

SQL Select query to include each row a number of times

This is probably easy to do (I hope), but my experiments with OUTER JOIN and CROSS JOIN etc do not give the results I am after, so here's the question: I need to do do a projection on fields in a ...
1
vote
3answers
144 views

Moved Model Database and now my SQL Server doesn't work

I moved my Model data and log files: ALTER DATABASE Model MODIFY FILE (NAME = 'modeldev', FILENAME = 'D:\Data\model.mdf') ALTER DATABASE Model MODIFY FILE (NAME = 'modellog', FILENAME = ...
0
votes
1answer
392 views

Keyword Search a single SQL Server table for multiple search terms and create a new table from results?

I am not a database administrator. Most of my experience is with MySQL. However I think what I want to do is in the realm of possibility. I want to text query a single large table in a SQL Server ...
4
votes
1answer
102 views

Placing an ASSERT in a SQL Server query

As part of a MERGE query that I want to run I'd like to assert at runtime that a certain condition holds. When a MERGE-match is found I'd like to update a certain column and have the following logic ...
1
vote
1answer
664 views

Does SQL Server allow INSERTs into tables and indexes to be written in parallel?

If I have a table that has many indexes, and I run a statement that inserts rows into the table, will SQL Server insert rows one-at-a-time, or will the rows be inserted using parallelism?
0
votes
0answers
29 views

Enterprise system database strategy [duplicate]

Here is my current database design: Separated databases based on area of domain (Sales, HR, Accounting, Core such as login and menus, etc). Each database has a single service login, each with ...
0
votes
2answers
147 views

Is it possible to speed up this PARTITION BY query?

I've got a timeserie table. Each datapoint has also a statut field which indicates its providing source. I'd like to request last available datapoint as of date T but there could be several results, ...
0
votes
1answer
175 views

How to create a versioning DDL/DML change script for SQL Server?

I have an application which has a database, and some versions of the application introduce schema changes. To make installation easier (?), I figured I want to create a meta table which contains the ...
0
votes
0answers
133 views

SQL Server: mirroring several tables in different databases

I want to keep several tables in two different databases mirrored. Both databases are within the same server, and both are SQL Server dbs. This mirroring only affects the data they contain, not the ...
0
votes
1answer
64 views

NTEXT,Indexing, and lob logical reads

We have an query that would benefit from a covering index but one of the columns that would be returned is a NTEXT data type. I know this can't be added to the index and I also know it would be good ...
2
votes
3answers
2k views

SQL Server 2012 copy database failed

I want to make a copy of database in the same SqlServer . so, When i using the Copy Database Wizard, it throw error: ( I did this steps with a test DB and it works fine !!!!) config: sa user ...
2
votes
2answers
296 views

Backup name in Maintenance plan

I used to have SQL Server 2005 installed on my server. In my maintenance plan, the backup name format was like this: mydatabase_backup_yyyymmddhhss.bak. Now I am using SQL Server 2012 but I am ...
5
votes
2answers
204 views

Any advantage of having a second index with included columns on a primary key?

I'm reviewing our database and noticed that on a particular table we have the following indexes: Table: Col1 INT IDENTITY(1,1) Primary Key Col2 INT ... about 15 more columns .... ColN ...
0
votes
0answers
1k views

Restore a backup from SQL Server 2008 R2 to SQL Server 2014 [closed]

How can I restore a backup from an earlier SQL Server 2008 R2 version to SQL Server 2014? The error I get is 38: reached the end of file although the file is not corrupted. Thank you.
0
votes
1answer
92 views

Table Valued Parameter not pulling the correct data for my sp?

http://sqlfiddle.com/#!3/b2643/5/1 http://sqlfiddle.com/#!3/b2643/5/0 This link above has the sample database tables I created on SQLfiddle. I have 3 main tables in my stored procedure: ...
2
votes
1answer
85 views

Does Index Intersection work with Included Columns?

I've been asked by a report designer whether it is acceptable to add a new index to a table to speed up a particular report. The index would be on a single column, CreatedDate, but would have ...
0
votes
1answer
47 views

How to determine consumption of data for archiving in sql server?

I was told that it could be possible to analyze the consumption of a given row. I already know I can use sys.dm_db_index_usage_stats to see the reads / writes on a given index (thus the table) but I ...
2
votes
1answer
83 views

Replace consective numbers from a string

So if I have a table with values: Name ID ---- --- James 100 James 101 James 102 James 200 James 201 James 202 Alex 100 Alex 101 Alex 102 Alex 105 Alex 106 Alex 109 ...
0
votes
0answers
19 views

Help understanding SQL Server Developer License when users test via webserver [duplicate]

I'm trying to understand how many licenses I may need if we decide to pursue a SQL Server Developer license for our Testing environment. We would have 5 actual developer and DBA's physically ...
2
votes
1answer
205 views

Move log file without taking database offline

I need to move a database log file to a new partition without taking the database offline. The normal way of doing this would be to detach the DB, move the log file then reattach the db. Is it ...
1
vote
0answers
20 views

Large transaction log won't truncate [duplicate]

I ran a full backup on SQL server 2008, but the transaction log stayed in tact. I though a full backup would make a new transaction log. What do I need to do to get my trn to a normal size?
0
votes
0answers
34 views

Is there any possible ways of restoring delete record from database that was never backup [duplicate]

My junior colleague mistakenly delete all the record in our mobile database using delete script. unfortunately neither the user database nor the logs were backup. Is there any possibility of restoring ...
1
vote
1answer
173 views

Sync postgreSQL with SQL Server database- on data change event

I have one PostgreSQL database and its data are being changed regularly. I want to sync all its data with my SQL Server database. One thing I can do is use query to check all required tables and ...
1
vote
1answer
569 views

Understanding sys.dm_exec_query_stats execution_count vs creation_time

I've just downloaded the SQL Server 2012 'Performance Dashboard Reports' and am having some issues interpreting the data shown by one of the results and linking it back to the DMV ...
0
votes
0answers
36 views

Designing a database with Ints [duplicate]

Pretty much a newb when it comes to SQL Server. The question is, in 2014, should I be optimising my int columns - tinyint for status, smallint for fixed size lookups, int/bigint for transaction ...
1
vote
2answers
28 views

How can I set myself as owner of a database ? just using sql

As I want to view dependencies of just a couple of tables in my clients database I want to set myself as the owner of the database. If the database is called MyDatabase and my userName is ...
-2
votes
1answer
222 views

How to restore a database from a .bak file to an existing database via GUI? [closed]

How can I restore a database from a .bak file to an existing database via the GUI instead of using the commands? Will the database be inconsistent if I restore a previous backup and what will happen ...
2
votes
1answer
1k views

Time out errors - MS access front end with SQL backend

First of all I don't know anything about SQL, so I apologise if I make no sense. I have created a MS access database and our IT area migrated the tables to SQL server 2008 and linked the tables to ...
4
votes
2answers
546 views

Why is my plan guide not being used?

We recently ran into the tipping point issue and some of our report queries that used to complete execution within a couple of seconds are now taking more than 2 min because the query optimizer simply ...
1
vote
0answers
28 views

data conversion error in SSIS 2005

I am encountering a tough problem when doing data conversion. My work is to generate fact table in ssis 2005, and there are several data that should be converted to other data type, so I use data ...
3
votes
1answer
46 views

Safe to start Mirroring on Production Server?

We have a 350 Gig DB on SQL Server 2008. We intend to backup and restore it then immediately start mirroring. Is starting a mirror a dangerous operation to do on a production database ? Can I expect ...
2
votes
1answer
96 views

A large percentage of unused space in the table

SQL Server 2005. I have a table size 16GB. Table has 14 GB of free space. sp_spaceused 'FREECLIENTDOC' name rows reserved data index_size unused --------------- ------ ...
1
vote
1answer
156 views

CTE Error (nvarchar to numeric)

I'm using a CTE to convert SSRS stored proc's into BO stored proc's, as apparently I can't use temp tables with Business Objects. I'm having this query: ;WITH cte1 AS ( SELECT cv.issue ...
6
votes
1answer
644 views

Database design for handling 1 billion rows and counting

We receive real-time GPS data at a rate of around 5000 pr. minute (from 4 TCP servers). Each server uses a single connection to insert the data, and buffers data in between inserts. Every 15 minutes ...
1
vote
1answer
54 views

Cannot login using SA with SQL Authentication

I can not log in to SQL Server 2008 in sa mode. I can only log in using Windows Authentication Mode. I chose only defaults while installing SQL Server 2008 R2.