Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sql-server]

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

3
votes
1answer
36 views

Select/Join multiple row values from Column A if dates in Column B are within 'x' seconds of each other

I have the following Database structure and need a query to work in SQL Server 2008 and also SQL Server 2014. Database: ASSETS Table: COMPUTERS PK (GUID) (nvarchar) (nvarchar) | ...
0
votes
1answer
33 views

Script for migrating server role permissions - SQL Server

I need to obtain a script for all the user-defined server roles in my SQL Server instance with their assigned permissions, such as the below: GRANT ALTER ANY AVAILABILITY GROUP TO [ServerRole1] What ...
8
votes
0answers
88 views

Always On Availability groups resolving state after failover - Remote harden of transaction 'GhostCleanupTask' failed [on hold]

My explanation will be opinion based as it is based on my findings. If more information is needed, I am always happy to add it. The setup We have 4 SQL Server 2016 Instances, and all 4 underlying ...
2
votes
0answers
35 views

What the “Reads” Column in Profiler exactly mean?

Can any one explain, whats the "Reads" column in SQL Server Profiler exactly mean ? Why sum of logical reads get by SET STATISTICS IO ON are different from number of reads in SQL Profiler? Which ...
1
vote
1answer
40 views

Database file location change on standby site after restore standby database

I am configuring Log shipping from SQL Server 2008R2 to 2016 using NORECOVERY option with Log Shopping jobs. I have successfully configured Backup, Copy and Restore jobs. When I perform a restore on ...
2
votes
1answer
57 views

Does Batch Mode only apply to Agg Functions on ColumnStore Index

Azure SQL Database - Standard Edition (S3 Service Tier) Why does Batch Mode only come into effect when using Aggregate Functions? DROP TABLE IF EXISTS dbo.TransCS CREATE TABLE dbo.TransCS ( ...
0
votes
1answer
66 views

Database Maintenance Job and Backup Scheduling

I would request to have expert advise on scheduling maintenance and backup jobs. Below was the scenario prior to my change: Full backup of database scheduled to run at 12:30AM everyday. Differential ...
0
votes
1answer
32 views

Missing data in SQL Server

I need to find the data that is present in Oracle, but missing from SQL Server. I have tried the below query, but am getting the following error: The multi-part identifier "PS.TXN_ID" could not be ...
-1
votes
0answers
55 views

SQL Server command line throws unwanted “d” characters in output

I'm running SQL Sever version 14.0.1000.169. When I enter sql statements from the command line, I get the character 'd' in the output -- it looks like it's showing up instead of a space. Here are ...
1
vote
1answer
35 views

How do I shrink the MASTER log file in SQL Server 2008?

This is for a non-system database: USE AdventureWorks GO ALTER DATABASE AdventureWorks SET RECOVERY SIMPLE GO DBCC SHRINKFILE (AdventureWorks_Log) GO ALTER DATABASE AdventureWorks SET RECOVERY FULL ...
0
votes
1answer
26 views

SSIS and SSRS Tutorials [on hold]

Does anyone have a tutorial for ssis ? I took my db class but we didnt learn how to do that so i m half way there but its erroring..i m also trying to figure out reporting services tutorials
1
vote
3answers
192 views

Execute new query when current query finalises

I am in the process of inserting some data into a SQL Server (2016). Since this is a manual one-time load, I have not bothered spending a lot of time writing it the most efficient way; however some of ...
1
vote
1answer
22 views

SSIS: Scripts in package part not being executed when target server is 2016

I am having an issue with SSIS packages where scripts included in package parts ar not executed when the target server version is SQL Server 2016. Create an SSIS project, set target server version to ...
1
vote
1answer
48 views

Deadlock Explanation

I've inherited a SQL Server 2012 database that uses triggers to copy all changes made to dbo tables into an audit schema, providing functionality similar to system-versioned temporal tables. One of ...
3
votes
1answer
30 views

Full Text Search only performs 'starts with' searches

Pretty basic question, but how can I get the containstable search to do an actual 'contains' search, rather than a 'starts with' one? For example, from the examples in the documentation: CREATE ...
0
votes
0answers
25 views

Always Encrypted returning Timeout error

I am trying to encrypt a number of tables (1 column in multiple tables) in two different databases. On Database A I manage to encrypt these, while on database B it fails with an error: 'Unable to ...
1
vote
0answers
76 views

Optimize multiple JOINs with large data

I have 3 tables with this structure: +-----------+ +-----------+ +-----------+ | Files | | Programs | | Channels | |-----------| |-----------| |-----------| | ID | | ID ...
6
votes
2answers
279 views

Datetime conversion fails when filtered index is placed on partition column

I've got a mysterious error of char data conversion at the moment of insertion a new row into a table. Troubleshooting reveals that a filtered index is the source of the problem. The index's filter ...
0
votes
0answers
46 views

Can we find who killed a SQL Server process? [duplicate]

I am using SQL Server 2012 Enterprise Edition. We are running SSIS package which usually take more than 5 hours to complete execution. Some time we find that the transaction is being killed by someone ...
2
votes
2answers
83 views

SQL Server mistaken update rows without backup

I did a mistake UPDATE query yesterday. Database engine is MSSQL and the version is 2017. I have not any backups. All I have is the database itself. Do you know any ways to redo my modifications to ...
2
votes
2answers
65 views

Can't import flat file into SqlServer

I've got this tab-delimited flat file with fifty columns and two million rows. I am trying to import it into Sql Server 2017 Express. (I first tried working with it in Excel... hopeless.) I see two ...
3
votes
3answers
449 views

Difference Between a Staging and the Production DWH

I have a general question on a Data Warehouse Architecture. I have heard a lot of a Staging and a Production, so that data should be loaded via SSIS first into a staging dwh and then via SSIS to the ...
1
vote
1answer
59 views

Privileges on SQL Server

I come from Oracle Database and now I am trying learn SQL Server and I don't undestand why may I viewer others databases, like the master for example, with a common user without privileges in this ...
-3
votes
0answers
31 views

How to write a query for ATM transactions

Mr. Ali and Mr. Adnan singed a deal and by which Mr. Ali has to pay 50,000 to Mr. Adnan and he wanted to transfer by ATM machine, you are required to write a procedure for ATM machine which make a ...
0
votes
1answer
34 views

How To get value of column when it exist in content value of column by sql server 2016

I want To get value of column when it exist in content value of column by sql server 2016 For Example: Table1: Title1 ---- Jack Benz Volvoo Table2: Description Names ---- ...
0
votes
0answers
36 views

A transport-level error has occurred when receiving results from the server. Error 10054

I have been using SQL Server & Azure for almost two years with Zero problems. Now for some reason I am getting the following error when I try to connect to my Azure database from SSMS. I have ...
0
votes
2answers
60 views

Restoring more than one .bak files in a TSQL query

Can any one share a script that will allow me to restore all the .bak files in my one folder into SQL Server using a TSQL script?
1
vote
1answer
98 views

How to clear temp database content in SQL Server?

As the title implies, I am going to clear the content of my temp database in SQL Server. SolarWinds is generating a critical alert and I want to clear the tempdb workfiles and worktables. How can I ...
-1
votes
1answer
55 views

Where clause in an inner join in SQL Server [on hold]

I have the below query SELECT b.CreateDate, * FROM ConsolidatedData_DealSheet AS a INNER JOIN Deals AS b ON a.DealNo = b.DealNo Result Set 2007-11-13 15:40:15.627 ...
-1
votes
0answers
25 views

Ola Hallengren backup Linux default location [closed]

The documentation for Ola Hallengren's backup scripts states that a @Directory of NULL will use the default backup location. I keep getting this error under SQL 2017 running on RHEL Linux: The ...
0
votes
0answers
38 views

Slowly Changing Dimension table Index Optimization

What is the optimal way to created index on slowly changing dimension tables which have Begin and EndDates? If I want to select when Customer owned house or enrolled in school. Should EndDate be in ...
2
votes
2answers
59 views

SQL query to check if secondary database is removed from availability group

I have an AG with one primary replica and one secondary replica. I have created a script that queries transaction log backups from these database replicas and restores them to a target database. ...
8
votes
2answers
119 views

Fastest way to split/store a long string for charindex function

I have a 1 TB string of digits. Given a 12-character sequence of digits I want to get the start-position of this sequence in the original string (charindex function). I have tested this with a 1GB ...
-1
votes
0answers
39 views

Resources for learning how to read query plans [closed]

Most posts on StackExchange DBA assume that readers can understand query plans. What is the best resource (book, website, video tutorial, etc.) for learning how to read and understand query plans? ...
0
votes
1answer
54 views

Different manifestations of the same logic yield very different execution times [closed]

Assume that the widgets_population table records every widget which has rolled off the assembly line, while the widgets_tested table is the subset that have been tested. For every widget in the ...
-1
votes
2answers
24 views

SQL to return preferred duplicate rows

Have a data set that some rows have a duplicate. Looking to return the row with IND = Y if it is present, otherwise to return the N. +------------+---------------+------------+----------+ | ...
2
votes
0answers
40 views

Can't seem to repair a clustered index [on hold]

Okay... so I'm not hopeful about fixing this one, but maybe someone here will have some secret magic trick... We've got a DB that we couldn't get nightly backups of. Ran DBCC CHECKDB, and got an ...
0
votes
1answer
41 views

CONVERT to datetime fails on Dynamic SQL - “Conversion failed when converting date and/or time from character string” [on hold]

I've spent a few hours with this and still can't get it to work. I'm trying to get the path to the most recent file that matches a pattern for a dynamic SQL query where I'm loading a CSV file into a ...
2
votes
0answers
32 views

What do I need to check why log_reuse_wait_desc keeps coming back to REPLICATION

What should I do to check or need to do why log_reuse_wait_desc is REPLICATION? A database of ours keeps coming back to REPLICATION for the log_reuse_wait_desc after essentially following this ...
0
votes
0answers
14 views

SQL Server Best Practices on Amazon RDS [closed]

We are migrating from an Always On Ag environment with Windows Security to an Amazon Multi AZ environment. We were told we had to move to a SQL Server user model when we go to RDS. I see ...
2
votes
0answers
23 views

How to handle normalizing the concept of a grid, and also plan for data versioning?

I have inherited a database that has a normalized structure, except for its data tables which are aggressively denormalized. Our system mostly renders grids into a browser, and the previous developer ...
2
votes
0answers
30 views

CNAME alias from named SQL instance to default instance [duplicate]

I know I can use CNAME alis to point from one SQL Server to another for upgrade or such log shipping, but what if one is named instance and other is default instance? Do I need SQL alias? Do i need ...
-2
votes
1answer
36 views

Optimize SQL syntax with conditional WHERE clause

Is it possible to optimize the following parts of the stored procedure regarding the WHERE clause without using dynamic SQL? The only difference between the two alternatives is that if Admin = 1 then ...
1
vote
1answer
54 views

Clarifications on Transparent Data Encryption

This is the first time we are applying TDE on production databases that are critical and I have the questions below. While TDE is in progress: Can we still access the application that is working on ...
0
votes
0answers
18 views

SSMA Selecting Specific Trigger

We are beginning work on migrating an Oracle Database to SQL Server and I have installed the appropriate SQL Server Migration Assistant. While I am not planning to use this to build the actual ...
0
votes
0answers
28 views

Replication Alternatives for Contained Databases

My team and I are in the process of designing a new application using the microservice architecture approach. Each application is going to to be responsible for releasing changes to its own database ...
0
votes
0answers
14 views

Ιndexed view after replication

I am trying to find a smart (no redundunt dataflow) way to aggregate data on views/tables to be used from our reporting tools. One given is that the reporting database is different from the oltp one, ...
4
votes
1answer
193 views

SQL Server: are backups between same major/minor version but different build compatible among them?

For example a backup executed on SQL Server 10.50.6000.34 can always be restored on SQL Server 10.50.4000.0 or 10.50.2500.0. All of them indicates an SQL Server 2008 R2 (10.50.xxxx.xx) but different ...
0
votes
1answer
34 views

Does Lazy Writer spend resources on flushing out pages from the buffer pool?

In MS SQL Server, does Lazy Writer spend resources to make pages out of the buffer pool after periodically checking free buffer list and marking some clean pages as free? Or free marked clean pages ...
2
votes
0answers
79 views

Kimball Data Warehouse: “Denormalize” Hierarchy Attributes

I have many different flat files. We have Property Owners, who own Properties, which are under a Tax Assessment (Tag Code). Property Owners flat file does not have SSN/Id, so sometimes same property ...