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.

learn more… | top users | synonyms (2)

0
votes
0answers
22 views

How should we be alerted of failures in the SQL replication distribution agent job?

When setting up SQL replication, the default retry count for the replication agent job step is 2147483647, retrying every minute. This means that if replication fails, the failure notification for the ...
-2
votes
3answers
58 views

Extract Portion From A Decimal [closed]

I need to extract any value > .5 from a decimal. Here is sample ddl Create Table #b ( fv decimal(16,4) fv1 decimal(16,4) ) Insert Into #b (fv) Values ('.8032') How can I capture the .3032 and ...
-2
votes
1answer
39 views

Can Log Shipping be recovered and resumed by scripts after DR?

Server A has DB1 log shipping to Server B as DB1_LS in a DR environment. Before the company DR exercise, I scripted out the log shipping configuration from DB1 properties window so I basically got one ...
4
votes
3answers
83 views

Make queries and BCP faster on a very large table

This question is somewhat of a continuation to this: Huge data and performance in SQL Server, but different enough to merit its own question. I'm going to copy and paste some of the text from that ...
4
votes
1answer
63 views

Why is my @@Version unchanged after upgrading?

I have SQL Server 2008 R2. I installed SQL Server 2014 with the option: Upgrade from SQL Server 2005, SQL Server 2008, SQL Server 2008 R2 or SQL Server 2012 and the process ended correctly. But ...
3
votes
3answers
313 views

Restore database to point in time from full backup only

I have a database with recovery mode set to FULL. It's a dev database and I have two full backups dated 19th and 27th i.e. latest. One of the developer did some changes on 26th and I want to rollback ...
0
votes
0answers
19 views

DBCC Msg 2576 The Index Allocation Map (IAM) [duplicate]

How do I resolve this error? Msg 2576, Level 16, State 1, Line 109 The Index Allocation Map (IAM) page (0:0) is pointed to by the previous pointer of IAM page (1:32707) in object ID 0, index ...
3
votes
3answers
552 views

Who is the person using a SQL login?

Is it possible to find out who used a SQL-Server login? Let's assume we suspect a person to abuse a SQL login that is supposed to be used by an application only to logon to SQL-Server. Is the domain ...
-1
votes
2answers
69 views

Calculating multiple medians

I have defined function with table value parameter which returns median as per values passed to it. Function defined as: CREATE FUNCTION [dbo].[fn_GetMedian](@List TypeMedian READONLY) ...
1
vote
2answers
100 views

Stored procedure working when run manually, not running in SQL Agent Job

When I execute a Stored Procedure through a SQL Agent Job, I get the following error message: Executed as user: NT AUTHORITY\SYSTEM. XML parsing: line 10, character 33, unexpected end of ...
3
votes
2answers
104 views

Convert int to RGB or hex color

I'm working with a database where colors are stored as integers. For some unknown reason, they are negative integers actually. Now, I need to use them in the CSS background-color property, which ...
0
votes
0answers
48 views

Cannot See Stored Procedure on Linked Server

Cannot see Stored Procedure on Linked Server. I have connected two server using linked server, I can see only tables and views. I'm not able to see stored procedures. I have set RPC to true.
0
votes
1answer
44 views

Conversion failed when converting the varchar value 'Hours' to data type int

Conversion failed when converting the varchar value 'Hours' to data type int. This is my query: Sum(Cast(Cast(DATEDIFF(HH, ld_time_tracker_start_time, fld_time_tracker_end_time)%3600/60 As int) ...
5
votes
0answers
58 views

Restored DB has data, DBCC CHECKDB is clean, but SELECT TOP 1 returns zero rows

Having restored a client's SQL 2014 EE DB onto our Developer Edition instance, without issue, then running a DBCC CHECKDB that found zero errors, and a clustered columnstore index alleging over 1Bn ...
1
vote
0answers
15 views

how columns ordering in sql server database table impact performance? [duplicate]

As I read about database design from logical model to physical databases, I noticed that the column ordering may need to be changed the sequence recorded in the logical data model. The DBMS is SQL ...
10
votes
1answer
153 views

Does CREATE TABLE SomeSchema.#TempTableName have a bug?

Simple test-bed: USE tempdb; GO /* This DROP TABLE should not be necessary, since the DROP SCHEMA should drop the table if it is contained within the schema, as I'd expect it to be. */ ...
10
votes
2answers
309 views

SUM of DATALENGTHs not matching table size from sys.allocation_units

I was under the impression that if I were to sum the DATALENGTH() of all fields for all records in a table that I would get the total size of the table. Am I mistaken? SELECT SUM(DATALENGTH(Field1)) ...
4
votes
1answer
47 views

SQL Server Memory Determination

We will be modifying a SQL Deployment in our Hosted Environment. We have a solution which is currently configured to use one Application (and not SQL) System Database (which holds Security and System ...
0
votes
0answers
42 views

Query Freezes and SSMS Crashes

I feel like I have the syntax set on my query, but anytime I try to run this SSMS freezes and I have to reboot and once I get my PC back up and running no records have been updated. The table only ...
1
vote
1answer
37 views

Return Bit Value based on previous records by Category

How would I return TRUE or FALSE if four of the last six records failed for a given MAKEID? So there has to be 4 failures (or FALSE records) in the last six MAKEID FAILURES CREATEDATE 101 ...
0
votes
0answers
14 views

Setting up SSRS on multiple servers on network

I have a group of virtual machines on the same domain running Windows server 2003 and sql server 2005 standard edition. I already have SSRS set up on one of the virtual machines which is working fine ...
1
vote
1answer
30 views

How to combine 2 SQL statements into one?

I have these 2 SQL statements. Each year, I need to add the new one for the new DB. How can I write it so it will just work for the new years instead of me manually editing this each year? Is there a ...
1
vote
0answers
40 views

How do I enable modify column order in Datagrip [closed]

How do I can enable the up and down buttons for column order in DataGrip? I'm using DataGrip 1.0, Build #DB-143.1410, built on December 15, 2015 with a SQL Server 2008 database. As an example, for ...
2
votes
1answer
77 views

How to select a subset from a query result

I have a query which calculates the Time Difference and Distance Between the Next and Previous Row: SELECT * FROM ( SELECT iVehicleMonitoringId AS PreviousId, ...
2
votes
2answers
46 views

Finding and listing all columns in a SQL Server database with identity [duplicate]

I wanted to RESEED all the identity columns in that database, so I need to create a script so I can find out which column in which table has the identity property.
2
votes
1answer
19 views

Merge data from a MSSQL backup

I have a backup of a MSSQL database that I would like to restore. The issue is that the server that I would restore it to already have a datbase with the same name, layout etc, wich contains data. Is ...
4
votes
1answer
53 views

Permission error when executing a 5.6 GB sqlcmd file

I am trying to run a very large file through the sqlcmd command and it works perfectly with files of 100 MB up to 1.4 GB. This is what I have tested so far, but when I try to run a file which is 5.6 ...
4
votes
1answer
46 views

Performance of a self join in a temporal table with a single day's difference between end_date and start_date

Title says it all really. A pretty standard temporal table design has a start_date and an end_date where the end_date is the day before the next record's start_date. In this case, there is an ...
3
votes
1answer
43 views

How is an Active Log different from MinLSN?

MinLSN is the LSN of the oldest uncommitted transaction: What exactly does Active Log hold? Isn't it supposed to hold all the uncommitted transactions? Does it hold any other log records which are ...
-2
votes
1answer
43 views

why unable to execute table-valued function?

Here is table-value function I have declared like: CREATE FUNCTION fn_GetMedian(@List TypeMedian READONLY) RETURNS INT AS BEGIN RETURN ( Select ( ( ...
4
votes
2answers
344 views

How can I pass column to function in sql?

I'm calculating median as: DECLARE @TEMP TABLE ( ID INT ) Select ( ( Select Top 1 ID From ( Select Top 50 Percent ID ...
1
vote
1answer
24 views

How does a transaction log backup deal with active log?

What happens to the log records that maintain any open uncommitted transactions when a transaction log backup starts? Will these records also be included in the log backup?
4
votes
2answers
71 views

Get 2 Most Recent Records By Product

I am stumped. I need to return a TRUE or FALSE by ProductId if the 2 most recent records created are 'pass' and the LEVEL values are different. PRODUCTID CREATEDATE STATUS LEVEL ABC ...
3
votes
1answer
55 views

Multi Subnet Availability Group IP Requirement for Windows Failover Cluster

Does the Windows Failover Cluster for a multi-subnet SQL Server Availability Group require a static IP entry for each subnet? The instructions I am finding for a Failover Cluster Instance (FCI) in a ...
-1
votes
2answers
43 views

how to Create A SP with table variable and execute 3 SP statements in the same statement

how to Create A SP with table variable and execute 3 SP statements in the same statement . exec [dbo].[sp_KPI_Churn_MTD_Current_Year] exec [dbo].[sp_KPI_Churn_MTD_Previous_Year] exec ...
4
votes
2answers
60 views

Users running expensive queries

I am currently monitoring the expensive queries from the activity monitor for SQL server. How do I see who is running the different queries?
0
votes
1answer
23 views

Scenarios in which you might need to restore large number of databases at once?

I've seen several online sources mentioning that you should always have a restore script automated for the possible need to restore a large number of databases at once and quickly get back up and ...
3
votes
1answer
20 views

SQL Server Service Broker - CHECKDB found consistency errors, how could this happen?

I encountered a weird SQL Server Service Broker consistency problem, namely I have a queue that holds messages (status=1, Ready to receive) which are lying there for a very long time. In the ...
0
votes
0answers
19 views

General capacity guidelines for transaction log and tempdb

Are there general guidelines for the initial size of a transaction log size in SQL Server? Is there a percentage of the total database size that can be estimated for this?
2
votes
0answers
16 views

TLS 1.2 with SQL Server 2008 [duplicate]

I have a VM where I use SQL Server 2008 as a black-box data store for a product I work with. I'm being told by my IT police that my VM is not (or will not be) secure in a short time unless I can ...
3
votes
2answers
78 views

Cube with 2 measure groups (with different relationships to dimensions) returns too many dimension members in reports

I have a cube that contains stock-take data from retail operations. It has 2 measure groups - one containing the number of stock units counted in each stock-take batch (which is related to the ...
8
votes
2answers
255 views

Shrinking a SQL Server Transaction Log

I’m currently having to deal with a SQL Server transaction log that has got out of control. Disclaimer: I’m not a dba and this isn’t my area of expertise so please bear with me. Currently I have a ...
5
votes
1answer
86 views

Monitor table permission changes

I need a solution to monitor table permission changes: how can I implement monitoring of every changes to granted permissions for a specific or any user on a specific table in SQL Server 2008 R2?
4
votes
1answer
405 views

Getting error “must declare the scalar variable” in SQL function even though it is declared

I am altering function like: ALTER FUNCTION [dbo].[fn_CalculateListing](@Listing TypeListingDatePrice READONLY) RETURNS TypePreviousListingResult AS BEGIN DECLARE @tbl_ListingDateDetails ...
-4
votes
1answer
61 views

can anyone help me in generating a automated script to create a database

I need help in generating a automated script for database where I can give parameters for database name, size etc. I need automated script to create a database where in I can give parameters for ...
0
votes
1answer
58 views

Difference installing SQL Server 2014 on stand alone vs. VM Cluster [closed]

I have installed SQL Server many times on standalone servers with DASD and SAN storage allocated to it. We have a new Hyper-V Virtual machine Cluster set up for us by a third party IT shop. I am ...
0
votes
1answer
37 views

If my Data, Log and Tempdb drives are on the same LUN, are they using 1 physical drive?

My SQL Server Data, Log and TempDB resides on different logical drives. But when I check the drive properties under Hardware tab, their location are located on the same Port, Bus, Target ID and LUN. ...
0
votes
0answers
18 views

Mirror Suspended - can't detatch

We have a site where they have MS SQL 2005 and we are mirroring a database. At some point around Xmas it's stopped mirroring after an unscheduled reboot. Trying to resume just throws an error, and ...
5
votes
1answer
45 views

How to run SQL services on NT SERVICE\MSSQLSERVER account if it is running earlier on LocalSystem

Recently just for experimental puprose, I have relocated the default (C:...) data\log file paths in server settings to new location (G:\DBA). Then I've moved the previously existing db's data\log ...
3
votes
1answer
118 views

How to get SQL insert and/or update to not lock entire table on MS SQL Server

Very much a newbie on DB work, so appreciate your patience with a basic question. I'm running SQL Server 2014 on my local machine, and I have a small table and a basic client application to test ...