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)

1
vote
2answers
72 views

Group by month and year given yyyy-mm-dd as a date

I have a list of incidents and dates along with them, yyyy-mm-dd then a category. I need to order by the category (speeding tickets, DUIs, etc...) for each month in a year. This is what the two ...
4
votes
2answers
378 views

What happens if a client connection is killed while holding a lock?

What happens if a client establishes a transaction, locks a row or table, and the client process crashes before it has a chance to rollback or commit the transaction? What, if anything, does SQL ...
2
votes
3answers
65 views

Excessive amount of data received from server

We are having a problem with slow queries on a certain table. We tried some things with indexes but that didn't make any difference. Then we discovered that the amount of data being transferred was ...
0
votes
0answers
4 views

Recommendation: Beginner needs to Regularly Post SQL Code for Troubleshooting. Where to? [migrated]

I am doing an internship that requires me to learn how to use SQL within SAS to run queries. Since I have little experience, I will need to frequently post code in order to check it for efficiency as ...
1
vote
1answer
46 views

How to change default security on SQL Server database so that everyone can use it?

I have a database hosted on my machine that I want co-workers to be able to access and edit through a program I created. My current connection string is: ...
5
votes
2answers
57 views

Predicate not resulting in expected scan

So I have this query that I'm trying to tune and am running into an issue that I'm having trouble understanding. First of this is the query I'm using. SELECT si.LoanNbr AS [LoanNumber], ...
-2
votes
0answers
40 views

Remove all instances of SQL Server and Start Fresh [closed]

Under my 'All Programs', I have SQL Server 2005, SQL Server 2008, SQL Server 2008 Community & Samples, SQL Server 2012 (Express). How do I uninstall (Complete clean uninstall) all these and ...
0
votes
0answers
27 views

Can I simulate a sequence in pre-2012 SQL Server, with separate identity column, in function style?

A database on SQL Server 2005/2008/R2 is currently using an identity column in a separate table as primary key source. The reason is that the application, with NHibernate as ORM, needs to know the PK ...
1
vote
1answer
34 views

Statistics needs to be captured for query analysis

What statistics are required to theoretically prove that X query work better than Y query. As per my knowledge I need to look for: Query elapsed time Logical read Logical write Physical read ...
1
vote
0answers
23 views

Does SQL Server 2012 Standard Edition have an option for select a window over time range?

As an example, in StackOverflow they answer the question Finding a count of rows in an arbitrary date range using Oracle. One of the queries is very similar to what I need, but in reverse, I need ...
2
votes
0answers
24 views

SSIS ASCII requirement: “Code page is 1252 and is required to be 20127”

I have a requirement to export a database to a tab-delimited file in the ASCII format. I am using derived columns to convert any Unicode strings to non-Unicode strings. For example, a former Unicode ...
2
votes
2answers
42 views

Query Row Count for All Tables

I need help creating an MSSQL query to pass in every table name to the query below, which returns the number of rows. This is how I get the row count for a single table: SELECT Total_Rows = ...
4
votes
0answers
80 views

Why is my Azure SQL Server so slow?

We currently have a VM that is very underpowered and are proposing to move to an Azure VM with better specs. The problem is, the Azure VM is much slower than the original VM even though it is of a ...
4
votes
1answer
55 views

Reporting Service 2014 Service Pack 1 Failing to work with error - wrong database version

Tonight we upgraded our SQL Server 2012 (SP2+CU6) cluster with SQL Server 2014 Service Pack 1. On that cluster nodes, we have Native mode Reporting Services scale-out configuration. After in-place ...
2
votes
1answer
45 views

How to use a view to span two tables that are identical

We have table A that receives data from our shop floor and we currently have it so that the data is moved from table A to table B after 5 years. I want to streamline this but need help creating a ...
2
votes
0answers
61 views

Weekly SQL database backup failing

I have a weekly SQL database backup job that is failing. If I look at the end of the history of the job, I see the following messages: Executing query "USE [msdb] ".: 2% complete End Progress ...
1
vote
0answers
25 views

SSIS - The value could not be converted because of a potential loss of data, runs fine in BIDS, not on the server

The value could not be converted because of a potential loss of data I'm getting this error when running an SSIS package from a server job. Normally this is some sort of type error, but I can't ...
-2
votes
0answers
10 views

I want to move the listbox one to another listbox and update the particular listbox value [migrated]

Here, Below i used the code. I am new in VBA. I am trying to move the one list box to another listbox, but I am not able to update the database table. I am struggle on few days. Why this error came ...
1
vote
0answers
16 views

BLToolKit save null instead of 0 [migrated]

(Can't use it as tag, but we're Using BLToolkit as ORM) I have this weird problem where BLToolkit saves NULL instead of 0 in our database. If you look the image, this is my values that will be ...
2
votes
4answers
69 views

SQL Server 2008 backup script

I have a lot of SharePoint 2013 databases to backup and if update fail to restore, so I want to automate this operations. ALTER DATABASE [TEST_1] SET OFFLINE WITH ROLLBACK IMMEDIATE GO BACKUP ...
3
votes
1answer
22 views

SQL Server 2012 - How to Remove Partition on Publisher but not Subscriber?

Is it possible to setup partitioning on a SQL Server 2012 publisher table, so that older data can be removed without affecting the same table on a subscriber table? Table exists on Database A (SQL ...
1
vote
1answer
69 views

How do I determine the cause of a very small table responding to queries slowly?

I have a table that stores less than 3 registers, but the queries on it are very slow. This table has only a single Primary Key with 0% fragmentation. > DBCC SHOWCONTIG scanning 'MYTABLE' ...
0
votes
0answers
36 views

Problems with GO keyword [duplicate]

I have a query: DECLARE @str NVARCHAR(max) SET @str = 'SET QUOTED_IDENTIFIER ON' + CHAR(13)+ CHAR(10) + 'GO' + CHAR(13) + CHAR(10) + 'Select 1 from MyTable' PRINT @str EXEC (@str) It returns an ...
2
votes
1answer
27 views

Performing Backup in 2 different ways in parallel?

We wish to perform backup in SQL Server in 2 different ways in parallel. Now currently we have a 3rd party tool that is performing the Backups, Full and transaction log, now the business wants to ...
2
votes
2answers
79 views

SQL Server 2008 R2 Memory Pressure

My SQL Server has a weird problem. It seems it happens with the same matter. It always restarts after running a period of time(about one month long). And I used dbcc memorystatus to check the problem. ...
11
votes
1answer
261 views

Why does referencing a variable in a join predicate force nested loops?

I came across this issue recently and couldn't find any discussion of it online. The query below DECLARE @S VARCHAR(1) = ''; WITH T AS (SELECT name + @S AS name2, * ...
2
votes
2answers
44 views

Restore Error event id 17066 and 3624 while restoring diff backup

I am getting the following error while restoring the Diff back up after restoring the Full backup in Norecovery mode. I am unable use dbcc checkdb as the database in restoring db.Issues happens only ...
0
votes
3answers
54 views

SQL Server: track database changes

I have two very similar database questions related to changes tracking. There are a lot of automation tests for an application, all of them use one database backup. Currently before each test ...
1
vote
1answer
40 views

Intervals query of huge data

My question is more or less theoretical - what is the best approch to get query data by intervals. The situation I have a system that manage counters (thousands of counters - counts consumption of ...
4
votes
1answer
105 views

In SQL Server Mgmt Studio, why don't triggers automatically get updated when tables get renamed?

I ran into an issue last week where we renamed a bunch of tables in a SQL Server and it broke a bunch of triggers. I would have though SQL Server Mgmt Studio would have been smart enough to update ...
2
votes
1answer
40 views

Partitioned Database restore is very slow on SQL Server 2012 with SP2

Team, We have a Partitioned database which is very small in size(112MB backup size). This is partitioned with 15000 files for one table and 7500 files for other table. Currently we are running into ...
0
votes
0answers
25 views

How to Create a Recommended Test Planning in SQL Server

Goal: Make lots of different test for a specific stored procedure named 'sp_test' in order to review if you are retrieving the same data based on data input. Purpose: If you have made lots of ...
9
votes
2answers
99 views

Why isn't the primary (clustered) key being used in this query?

I have a SQL Server 2008 R2 table whose schema structure looks as follows: CREATE TABLE [dbo].[CDSIM_BE] ( [ID] [bigint] NOT NULL, [EquipmentID] [varchar](50) NOT NULL, [SerialNumber] ...
0
votes
1answer
31 views

Moving TempDB data and log files

I had to move tempDB files around. Both data and log file were originally on c:\ drive. I moved the mdf file to E:\ drive and log file to F:\ drive. This was successful and I was able to get SQL ...
-1
votes
1answer
22 views

New to SQL- Delete First and Last Day of Each Month From Data Set [duplicate]

I am extremely new to SQL. I am operating on SQL Server 2012. I am working with an Inventory file that contains the Date the Inventory was taken, item #, and quantity. The first and last day of each ...
0
votes
0answers
32 views

Select sub columns from a view

I have a large view in Sql Server named ViewA which looks like Select ColumnA, ColumnB, ... ColumnZ FROM TableA Join TableB ON ... Join TableZ ON This view gives me exactly what I need in ...
0
votes
0answers
29 views

How can I correct my untrusted foreign key situation?

In our scenario, we have a number of situations in which foreign keys or check constraints are not trusted. Here's some example situations: A "claim" is an entity that is the primary purpose of the ...
0
votes
0answers
17 views

Why is Activity Monitor Login blank, and what is that process doing?

I observe regularly occurring User processes (User Process = 1) connecting from load-balanced application servers to a database server (see Environment Details below) on the same internal network, ...
2
votes
1answer
94 views

How to read detached or offline sql server transaction log? [on hold]

All we know commands that allow to read SQL Server transaction log file. But how to read offline/detached SQL Server transaction log, without SQL Server engine? There are tools like apexsql that ...
1
vote
2answers
78 views

I have a year's worth of inventory data, and I want to extract the first and last day of each month's data. What is the best way to do this? Thanks

I have a year's worth of inventory data, and I want to extract the first and last day of each month's data. What is the best way to do this?
1
vote
1answer
27 views

SQL Server AS: Set ImpersonationMode via PS

Try to create a database in SQL Server Analysis Server (SQLAS, SSAS) version 2012 SP2 if that matters and set Impersonation Mode via Powershell. (try to avoid XMLA script). Here are my attempts. Does ...
7
votes
3answers
421 views

Accidentally change database name (SQL Server 2008)

It didn't happen to me YET. But I was thinking about this. I was messing around with my training environment, and by mistake I clicked in the database name, and then I touched the letter A. Let's ...
5
votes
0answers
114 views

Identical query slower when searching for `T` rather than `F`

I have a legacy database that uses char(1) with 'T' and 'F' for boolean values. The only values in the field are T and F, of the following queries, the first is instantaneous, the second takes 30 ...
1
vote
2answers
36 views

Move a Filestream column between tables

I have a table which has a Filestream column which I would like to move to another table. Is this possible without having to do a "manual" move of the data (create target column; issue UPDATE/INSERT ...
1
vote
5answers
76 views

TSQL insert table using view — performance issue

I have a big view joining multiple tables that in a regular basis materialists itself into a table (this step occurs for viz's tool read a table instead of a view during data source refresh): select ...
1
vote
2answers
29 views

Adding second SQL Server to create 2 Node cluster

I am not a dba. I have general knowledge of SQL Server and T-SQL. Our company currently has a SQL Server 2008 R2 hosting about 30 databases. I've been asked to research adding a second server for ...
6
votes
4answers
173 views

Compare 4 or more columns values

I have a table like: ID A0 A1 A2 A3 A4 14 A B A C A 15 A A A A A I need to compare all 5 columns and check if they have same value and retrive the only one that have all same ...
1
vote
1answer
16 views

Order of DROP_EXISTING and ONLINE for CREATE INDEX

If I call a CREATE NONCLUSTERED INDEX using DROP_EXISTING = ON and ONLINE = ON what order are things done it? What I want is: New index is made in the TempDB Existing Index is dropped New index ...
7
votes
3answers
134 views

IF statement not skipping TempDB when Looping through Databases with sp_MSForEachDB

[SQL Server 2012 SP2 EE] Why does the following script gives me an error relating to tempdb? exec sp_MSForEachDB ' IF ( (select database_id from sys.databases where name = ''?'') > 4) ...
5
votes
1answer
44 views

Adding PRIMARY KEY and IDENTITY attributes to SQL Server 2008 tables

An application is using an SQL Server 2008 database that has ID columns, but these columns are not primary keys and have no IDENTITY attribute. What I need to do now is adding the PKs and IDENTITY ...