Questions tagged [sql-server]

All versions of Microsoft SQL Server (not MySQL). Please also add a version-specific tag, like sql-server-2016, since it is often relevant to the question.

Filter by
Sorted by
Tagged with
0
votes
0answers
3 views

Querying system health data is sometimes fast and other times too slow

We get the data from system health XE within SQL server and load into tables for later querying. Part of that statements which gets pretty slow is INSERT INTO TABLE1 ( [object_name] ...
3
votes
4answers
68 views

Why would shrinking TEMPDB log lead to slowness?

I recently accidentally shrunk tempdb log to almost 0 after getting alerted that log drive filling up. I am told that it will lead to slowness. Can someone please explain why it will lead to slowness?
0
votes
0answers
28 views

Column as an Included column or as a key column

I have a query which has an optional where condition on column classID(not unique). This same classID is being displayed as a select column in various other queries. Currently i have classID as an ...
-2
votes
0answers
58 views

generate views from meta data using STRING_AGG function

I want to generate the DDL for views from a table of meta data. Since every value for my_column_name maps to a single short_column_names the order is important. If they are both sorted by their ...
1
vote
2answers
40 views

Is DB mail supported on SQL Server hosted on Azure VM (IaaS)?

Is DB mail present in SQL Server hosted on Azure VM (IaaS)? If DB mail is not supported, then what are the features available?
1
vote
1answer
299 views

Mirroring on-premise SQL Server to AWS EC2 SQL Server

Trying to mirror an on-premise SQL Server instance to EC2 instance, but not much information is available on this topic. The closest one I managed to find is: Implement SQL Server High Availability ...
7
votes
3answers
3k views

Get SSMS to show the time a query completed at?

I'm using Sql Server Management Studio 2012, and I'm wondering if there is a way to have a query show me at what time it was run and/or completed at. Basically just some kind of timestamp so that I ...
0
votes
3answers
35 views

SQL server 2016/2017 in terms of better performance

Which SQL version or edition should we use out of SQL server 2017std/ent or 2016std/ent in terms of better performance gain when you are dealing with SP's (approx 1000 or more)in single database which ...
3
votes
3answers
23k views

Pass parameters to a procedure with SQLcmd

I use this SQL command: sqlcmd -v first_date="30/09/2015" last_date="15/09/2016" And I would like to pass that parameters to a stored procedure: ALTER PROCEDURE [dbo].[_testProcedure] WITH ...
1
vote
1answer
240 views

SQL Server - error running 'sp_addsubscription' when not sysadmin

Windows 2008 R2 MSSQLSERVER 2012 (SP1) Standard When running sp_addsubscription under account within db_owner role of both user and distribution databases, I get the following error: Msg 14260, ...
-1
votes
0answers
18 views

SSIS Package won't run SQL agent

I've upgraded my sql server and moved all the Databases and agent jobs to a new server from 2012 to 2016 and exported and imported the SSIS packages. I have maintenance job which run a SSIS package ...
1
vote
2answers
101 views

How to pass a table-valued parameter to sp_execute_external_script?

I have a stored procedure that calls an external script via a SQL Server language extension. I would like for my stored procedure to use a caller supplied table valued parameter (TVP) to then submit ...
-1
votes
1answer
35 views

Problem adding a replica to an Availability Group

I'm getting an odd problem in trying to add a replica to an AG. This is part of a POC project to upgrade a 2-node AG running on Windows 2012 and SQL Server 2012 to a new 2-node AG running under ...
6
votes
1answer
361 views

Replace long GROUP BY list with a subquery

This is a repost of my question on Stack Overflow. They suggested to ask it here: I found an online article from 2005, where the author claims, that many devs use GROUP BY wrong, and that you should ...
-1
votes
0answers
18 views

DBDEFENCE for SQL Server [on hold]

Has anybody used DBDEFENCE as SQLdb encryption solution in production? If yes, Could you provide a overall feedback about it(like Reliability, performance,durability, easy etc). Thanks
1
vote
2answers
63 views

How to check actual execution plan of a query after it has been executed

In SQL Server, how can we see actual execution plan of a query, after it has been executed? As per my knowledge, only estimated execution plan (not actual execution plan) are stored in plan cache. is ...
1
vote
0answers
19 views

Football Matches - build temp standings table for each Gameweek

I have the following data in a sql database and i need that for each game in the table to add new columns with the Rank in Table, Number of Points and Goals Scored at home, for each Gameweek (the ...
1
vote
1answer
35 views

Install last CU for SP2 without installing SP1 in sql server

A client asked me to update their SQL Server. It's an 2016 base release (13.00.1601.00) Microsoft already released the SP2 CU10. I know that cumulative updates are... like... cumulative, but even ...
0
votes
1answer
32 views

How to use comma separated columns in CASE WHEN Statement?

I am trying to add below CASE WHEN Statement in SQL WHERE Clause, But SQL Server not allowing me to do so. All column used are of same Data Types but still its giving me error, Can anyone please check ...
1
vote
1answer
228 views

Conditional MS SQL replication

I have an issue that I want to do conditional replication to one of my enterprise level client databases. This database is very large: approximately 300 GB MDF file and a 160 GB LDF file because of ...
4
votes
1answer
82 views

Deadlock Graph - Surviving Statement inputbuf does not show the object that was locked

I have captured a deadlock on my system and the (anonymised) XML output is as follows: <deadlock> <victim-list> <victimProcess id="processf4d9233468" /> </victim-...
0
votes
1answer
38 views

Deadlock in SQL Server

I have been trying to resolve this deadlock for a while now with no success, its seems like the users are opening multiple tabs when executing this task. Below is the deadlock trace from red gate. Can ...
0
votes
1answer
33 views

How to find average of transactions every 15 min in Sql server for last 7 days?

This question might not be new in forums , but struggling to get the expected out put. Please any body share the similar requirements if we face with solutions. I would like to find average of total ...
11
votes
2answers
53k views

Transaction in a stored procedure

I need to perform an UPDATE and an INSERT in a single transaction. That code works fine on its own, but I'd like to be able to call it easily and pass in the required parameters. When I try to nest ...
1
vote
1answer
62 views

Query Slowness Despite Index

Problem I need to create a chart of User Retention over time, similar to this: Ignoring the percenages for a minute, I have a query that shows unique users for a given "cohort" and then the number ...
0
votes
0answers
25 views

Granting temporary sysadmin rights

Using SQL Server 2017. I have an issue that I need to allow a Windows authenticated user the ability to read excel files that are on the network. They have public rights as well as a host of different ...
9
votes
4answers
28k views

SQL Server is started but didn't listen on any port

I newly installed SQL Server 2012. No database created yet. And I can open the Management Studio with sa/password. The Binn\sqlservr.exe is started as a service and I can see it started in the service ...
0
votes
1answer
88 views

Mssql query problem. Column '' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause

There is a problem I have experienced in mssql. ( but I don't have this problem in mysql. ) They know two different engines. but I could not find a solution. Do you think I can fix this error? My ...
-1
votes
2answers
69 views

SQL database stuck in recovery

I have SQL server 2017. I have one 3 TB size database there. Somehow due to long running transaction the database got stuck 'IN Recovery' mode after SQL server Restarted. When I checked the sql error ...
1
vote
2answers
62 views

How to find unused logins in SQL Server?

I have a couple of databases on my server, each with its own users. Now I need to find and delete all those logins, which are not mapped to any user in any database. But I've also seen that it is ...
1
vote
1answer
456 views

Cannot run a job to update table on a linked server

I am running SQL Server 2012 on a server (server 1) and have set up a job to run a stored procedure which will summarize data from a series of tables and update a table on a linked server (server 2) ...
1
vote
1answer
223 views

SQL Server 2012 MSG 4145 [on hold]

I'm trying to upgrade one of our applications and we have to create the database again due to the app now requiring case sensitive collation. I've created the new DB and run the table creation ...
-1
votes
0answers
34 views

Name matching - 1 million row under 1 seconds [on hold]

I have requirement to have fuzzy name matching for around 1 million row under 1 second. I use a simple Jaro Winkler function for 20k row it cost around 5 seconds to execute and the rate increase ...
2
votes
2answers
234 views

SQL Query optimization - Long running query

I have a database with the following tables : CREATE TABLE [Document]( [IdDocument] [int] NOT NULL, [DocumentType] [int] NOT NULL CONSTRAINT PK_Document PRIMARY KEY CLUSTERED (IdDocument)...
0
votes
1answer
20 views

Querying sys.server_principals does not return results for specific user

I'm trying to figure out why this query: SELECT * FROM sys.server_principals WHERE sid = SUSER_SID('Domain\User') OR name = 'Domain\User' Does not return results for one specific user? At the same ...
0
votes
1answer
571 views

Access SQL Server Configuration Manager on a remote server

I am trying to add a traceflag as a startup parameter to a distant SQL Server 2016, installed on a Windows 2016 core server and I am following these instructions At this point in the document: ...
1
vote
1answer
368 views

Re-initializing a transactional replication wihch was initially synced from backup

I have a transactional replication which was initially synced from backup. Now I need to add a new table which is really big so we have decided to backup and restore a fresh copy of the db to ...
2
votes
2answers
134 views

logins without any users

There are several logins in my SQL Server that don't have user mappings to any database; they are simply dummy logins. Someone created the login but it does not have any associated users. I need to ...
6
votes
2answers
123 views

Why selecting rowversion using outer join never returns null

Using SQL Server 2014. Given table with rowversion column, other table to join with and a select like this: CREATE TABLE dbo.FooTable( [Id] [int] IDENTITY(1,1) NOT NULL, [RowVersion] [...
1
vote
2answers
3k views

The EXECUTE permission was denied on the object 'SPROC', database 'DATABASE', schema 'dbo'

I have a few users that are unexpectedly receiving this error message today when they attempt to refresh a stored procedure via Excel: The EXECUTE permission was denied on the object 'SPROC', ...
0
votes
1answer
34 views

Database Consistency History fails in SQL Server 2017 Express

When I run the Database Consistency History report using MSSM I get an error message: unable to retrieve data for this section of the report. Following error occured Msg 19050, Level 16, State 5 ...
17
votes
2answers
1k views

Which collation should I use for biblical Hebrew?

Which SQL Server collation should I use for biblical Hebrew? The database under consideration needs to accommodate diacritics (i.e., vowels, accents, trope, etc.).
1
vote
2answers
37 views

I need to reference the same two columns multiple times in where clause

I've got a table that stores survey question information and I'm looking to find out a count based on gender, race, etc My issue is that I have to reference the same columns multiple times in the ...
2
votes
1answer
260 views

Startup Parameters greyed out in SSCM for new instance

We do not appear to be able to change the startup parameters for a new SQL Server instance, using SQL Server Configuration Manager (see screenshot below). We are members of the sysadmin fixed server ...
0
votes
2answers
40 views

Should I query from a snapshot or use a backup for reporting purposes

I have a very large select query for reporting purposes that can take up to 1-2 hours to run. There are a few issues with this query. It takes up too much system resources and this server can't ...
0
votes
1answer
20 views

fn_LShortNameToLCID in SQL Database

My question sound stupid but i didn't understand and searching on google didn't helped either. I have a SQL query which i use in SCCM Reporting. I just want to say that my hands are bit tight in SQL ...
2
votes
1answer
194 views

Identity management in Transaction replication with updatable subscription

I have migrated my publisher DB to new server yesterday. For migration what I did was removed subscriptions and publication completely backed up DB on which publication was configured restored DB to ...
2
votes
1answer
89 views

How to store x,y graphs: (a) Using x,y columns for each point, or (b) to store the set of points as comma separated strings?

We are designing a database to store the X,Y graph data of electronic devices apart from other entities. Business domain description We have a collection of objects A, each object A has a collection ...
0
votes
2answers
547 views

Alter All Data Types To Different Data Type

I have a database that has multiple tables with datetime2 fields. I need to convert all of these to datetime fields. I ran this syntax that produced over 300 tables that need to be altered with ...
1
vote
1answer
87 views

Mirroring issue with mirror server

I am running two Windows Servers 2012 R2 with SQL Server 2014 Standard Edition. I have strange issue on mirroring. I configured mirroring on for 15 databases, no Witness server. The Principal server ...