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
1answer
7 views

Select when group by contains more than one row with the same value?

I am trying to write a query that returns one row from table A whenever a column in joined table B contains multiple distinct values for a single matching row in table A. (A -> B is a 1 -> many ...
0
votes
0answers
5 views

Cannot Generate SSPI Context Error [duplicate]

I have a weird situation, in my instance i created 2 AG (AG1 and AG2) using the same service account. for couple of both are working fine connecting to Listener1 and Listener2. Last week, one of the ...
1
vote
1answer
28 views

Aggregation by positive and negative values

I have a table called "PROD_COST" with 5 columns: +----+----------+------+-----------+-------------+ | ID | Duration | Cost | COST_NEXT | COST_CHANGE | ...
0
votes
0answers
5 views

Connection between SQL Server 2014 and Oracle 12c [duplicate]

I have to server: 1.Server_A with Oracle 12c 2.Server_B with SQL Server 2014 I want these servers see each other, though I can SELECT anything I want in Server_A from Server_B and vice versa. I ...
5
votes
2answers
30 views

Allocation strategy where tables regularly grow and shrink by large amounts

I have a SQL Server 2014 database with 100+ tables that have a 5% growth rate over the course of a year. Lots of reading, very little writing. This database is going to expand by another set of 20+ ...
2
votes
1answer
56 views

What server configuration and database should I use?

I am new to Database's and want to work toward installing a Database in the small company I work at for production and eventually other uses. The company has only 15 employee's and three departments. ...
0
votes
0answers
12 views

Sql Dependency with Service broker working fine when sql server presents local system but its not working when database is at remote system [on hold]

I have an application which uses sql service broker and sql dependency in c# application. Its working fine when my database is at the local machine but it does nothing when the database is at remote ...
3
votes
0answers
32 views

Remote access to SQL Server 2008 R2 on Windows Server 2012 R2?

I have SQL Server 2008 R2 (named instance) on a Windows Server 2012 R2: Enabled remote access to SQL Server Enabled shared memory & TCP/IP protocols & named pipes for the SQL Server ...
6
votes
1answer
161 views

Azure: Many Failed Login Attempts Logged

I run a SQL Server on an Azure Virtual Machine. I have noticed in the Event Logs of the server lots of failed SQL Login attempts using a ton of different usernames (none of which exist): Login ...
0
votes
0answers
14 views

Event 17058 - initerrlog: Could not open error log file (SQL Server)

I'm new to SQL Server and encountering an error when running sqlservr.exe (Microsoft® SQL Server® 2008 R2 SP2 - Express Edition) Error 17058, Severity: 16, State: 1. initerrlog: Could not open ...
0
votes
0answers
25 views

Sharing a database over the local network [migrated]

We have some plate nesting software at work which I use daily. Recently, I thought I'd try to get the shared database up and working so the boys in the workshop could use the software on another PC ...
-4
votes
0answers
21 views

sql server stored procedure clockin [on hold]

how to create a stored procedure with clockin,clockout columns and I want to show the time worked from them and the min_leave_time when user clockin and out for breaks on a 8 hr. shift with lunch only ...
4
votes
3answers
70 views

Return even empty groups when grouping by date

I have the following query: SELECT DISTINCT COUNT(CD_BarCode) ,CD_Carrier ,SUBSTRING(CONVERT(VARCHAR,DT_Arriving,103),1,11) Date FROM TB_AGIL WHERE ...
5
votes
2answers
265 views

Tell SQL Server a query is ad hoc and not to optimize based on it

Is there a way to run a one-off query against a production SQL Server database and tell it not to make any future judgments based on that query. E.g. Store execution plans, recommend indexes, etc. ...
2
votes
2answers
61 views

Add a flag when certain conditions are met

I have a table where when an employee works LEAVE1 and LEAVE2 paycodes on the same day then in the new column called 'FLAG' we need to put a 1 for LEAVE1 and a 2 for LEAVE2, when these paycodes are ...
2
votes
1answer
23 views

Availability Group environment clone

I've been assigned a project where we have an active secondary environment that I'm confident that Availability Groups would address but have some questions that I hope someone can answer for me. ...
0
votes
2answers
46 views

How to create Date table

I have problems when I try to create my DimDate. That's what I have tried: CREATE TABLE [dbo].[DimDate] ( /*[ID] [int] IDENTITY(1,1) NOT NULL--Use this line if you just want an ...
1
vote
0answers
26 views

Transactional replication taking hours to replicate

I have a bunch of tables replicated from my_publisher to my_subscriber via my_distributor. Some of these tables, not all of them, when updated on my_publisher, take a couple of hours to be updated on ...
4
votes
1answer
164 views

Running a sql server query with as little impact as possible

I'm looking to create some basic scripts that are aimed at running on production systems. I want them to run with as little impact as possible. They shouldn't affect performance whenever possible, ...
2
votes
1answer
30 views

Finding out what permissions are required by the SQL Server Agent Jobs

I've been looking at this for a while and I can't work out an easy way to do this. As it stands every job in the database runs under SA level rights (horrifying thought) I'm sure some of the jobs ...
3
votes
1answer
176 views

Gigantic gaps in IDENTITY column

This question is about strange behavior in SQL Server 2008 R2 SP3 Standard Edition x64. I have read many questions about IDENTITY increments in SQL Server and strange gaps between them. But basically ...
2
votes
1answer
34 views

Meaning of SERVERPROPERTY ('ResourceLastUpdateDateTime')

I have researched a while, a lot of articles name it and tell us to use it - but none really explains the meaning of the date and WHEN exactly it changes. Does anyone know? Samples for articles not ...
3
votes
1answer
25 views

Wide clustered index vs multiple narrow nonclustered indexes?

Say I have a contrived Student table like so: CREATE TABLE Student ( Id IDENTITY INT, SchoolId INT NOT NULL, FirstName VARCHAR(20) NOT NULL, LastName VARCHAR(20) NOT NULL ) ...
-1
votes
3answers
24 views

Selecting multiple rows as one row with “AS” [on hold]

If I have a table of users, for example, and I want to include the users in a query like so: SELECT gameId, player1id, player2id, users.username as player1, users.username as player2 FROM players, ...
0
votes
0answers
33 views

SQL SERVER 2014 windows administrator locked and sa password lost [duplicate]

I am missing the sa password for a SQL Server 2014 instance. Unfortunately the Windows Administrator user is also locked. How can I reset my sa password?
1
vote
0answers
60 views

Routing data from one SqlServer to another

Is there a way in SqlServer 2012 to have data being written to one table routed to another SqlServer on another host ? To clarify, we are using Hibernate Envars to write audit logs. Hibernate Envars ...
2
votes
1answer
62 views

Scramble the data output of a stored procedure

I have a stored procedure that produces data for a call center system every morning. However, the data is sent in the same order daily. Is there a way to send the day in a different order every day ...
0
votes
0answers
23 views

How to install SQL Server Agent in existing SSMS [on hold]

I have been working on SSMS for Data mining, Now I would like to schedule a job. Where I am unable to find SQL Server Agent to schedule a job. Can any one help me how to get SQL server Agent into ...
1
vote
2answers
46 views

Join with comma separated values in SQL Server

I have a table [CourseMaster] LIKE CourseId CourseName ----------------------- 01 ABC 02 DEF 03 GHI 04 JKL 05 MNO 06 PQR 07 ...
2
votes
2answers
25 views

Error 4108: Windowed functions can only appear in the SELECT or ORDER BY clauses

The error in the title is produced when add the second condition in my where clause. I understand the error, have tried using subqueries as seen in other posts to fix this but no luck. Does anyone ...
-3
votes
0answers
25 views

database is not getting restored second time with this query [on hold]

USE master GO ALTER DATABASE Tfs_CoeTest SET SINGLE_USER WITH ROLLBACK IMMEDIATE; GO RESTORE DATABASE Tfs_CoeTest FROM DISK = 'D:\Backup123\Tfs_CoeTest' WITH MOVE 'Tfs_CoeTest' TO ...
1
vote
1answer
55 views

Determining the specific command type in a DDL trigger

Given strings corresponding to DDL commands, how can I determine which DDL command (column addition, constraint addition etc.) it precisely is? I have a DDL trigger on a database that will be fired ...
0
votes
1answer
31 views

SQL Server 2012 - Can't detach database on mirror server

I'm running SQL Server 2012 in a mirror configuration and I need to move the mirror's transaction files. I deleted the mirror setup on the primary but I can't detach the databases on the mirror, the ...
4
votes
1answer
46 views

Zero Rows return on quering DMV sys.dm_os_performance_counters

I have a user on SQL Server 2014 Standard Edition (RTM) with SYSADMIN role with Server View State Permissions but when I execute DMV sys.dm_os_performance_counters it return no record. Any idea what ...
4
votes
1answer
110 views

SQL Server data folder access rights

I did a fresh SQL Server 2014 install. Next, I wanted to attach some databases from a previous SQL Server 2012 server. I copied all mdf and ldf files to the data directory, but when I tried to attach ...
2
votes
0answers
15 views

How to ignore spatial index?

When i do Schema Compare in Visual Studio i see that spatial index in table was changed and this changes will included in generated script. But i do not want see this changes in my script. It's ...
-1
votes
1answer
27 views

Unable to restore the database with the query [on hold]

USE master GO ALTER DATABASE Tfs_CoE SET SINGLE_USER WITH ROLLBACK IMMEDIATE; GO RESTORE DATABASE Tfs_CoE FROM DISK = 'D:\Backupfolder\Tfs_CoE.bak' WITH MOVE 'Tfs_CoE' TO ...
0
votes
0answers
33 views

Method to economically insert Bill of Materials BOM items into a Stock Table?

I’m new to the wonderful world of database design and I’m currently experimenting with an implementation for my little brother relating to Model Train Sets. [I will be using SQL Server 2012 / Asp.Net ...
0
votes
0answers
11 views

Microsoft SQL Data Services OR SAP Master Data Governance / SAP NetWeaver

I want to know in which cases should I use Microsoft SQL Data Services OR SAP Master Data Governance / SAP NetWeaver, and what advantages bring each one comparing with the others.
1
vote
1answer
40 views

Query to remove duplicate calculated values

I have a client running SQL Server 2008 R2 SP1, and I can't seem to write a query that has distinct calculated values. I could change the schema to store the value being calculated, but I was curious ...
4
votes
1answer
32 views

Calculating daily growth using previous row value in new column - SQL Server

I have the following query below that shows size of a database and when this data was collected. I am trying to create a new column that has "average daily growth" which would be determined by the ...
4
votes
1answer
116 views

Finding distinct rows across two tables: Full Outer Join more efficient than Union?

When finding distinct rows across two tables where we can't necessarily ensure are pre-sorted, is it a good idea to use a FULL OUTER JOIN rather than a UNION? Are there any downsides to this ...
7
votes
2answers
66 views

NoSQL : What is unstructured data?

we are currently running at the edge of resources with our mssql server based solution. We have now many traditional options regarding the next move to tackle the load: buy faster CPUs and IO ...
0
votes
1answer
23 views

SQL query to get output

I have two queries. First query: select files.originalfilename from files inner join digitalfiles on files.fileid = digitalfiles.fileid where digitalfiles.path in ( select * from ...
1
vote
1answer
43 views

How is an idle SQL Server connection causing blocking?

I have a busy, transactional SQL Server (2012) which is having intermittent problems with blocking (every couple of days or so). I've been using extended events to capture blocked-process reports, but ...
1
vote
2answers
54 views

Defragmenting Indexes Bloats Log Files

I'm having difficulty "defragging" indexes as a minimally logged operation. Before defragmentation, the database recovery model is switched from FULL to BULK LOGGED. Depending on the fragmentation ...
0
votes
0answers
22 views

stored procedure to display error messages & success when a sp_refreshview is ran

How can I convert this stored procedure to display error messages when a sp_refreshview fails? I need to know which view failed. I would also like to know which "database_name.SQL_View_object_name" ...
1
vote
1answer
27 views

Sql Server Mirroring Failover and Failback

I have the following mirroring setup for DR. Principal (ServerA) Mirror (ServerB). When we do a DR test we do manual failover from Principal (ServerA) to Mirror(ServerB), so now: ServerB is ...
1
vote
1answer
80 views

What collation to use for Ukraine?

We have an accounting program with an SQL Server database and would like to start a Ukrainian version. I am not sure which collation to use: Ukrainian or Cyrillic_General? With a non-technical ...
0
votes
1answer
15 views

SSDT: Create User in a database not being part of the project

I want to give the user of my SSDT Database Project to be created as a user in another db on the same server and give it permissions to connect and the datareader role. I failed to do so. USE command ...