2
votes
0answers
39 views

Finding rows with duplicate values

I have a one to many relationship between the Account table and a ScheduledPayment table. One account can have many payments but there should be a maximum of one payment per day. Although unlikely, ...
1
vote
2answers
32 views

Trying to filter msdb..sysjobs by job_id

I'm attempting to determine the name of the SQL Server Agent Job that is currently running by comparing the output of master.sys.dm_exec_sessions.program_name to msdb..sysjobs.job_id I'm using the ...
1
vote
0answers
39 views

Cursors and concurrent users

I typically avoid cursor operations like the plaque, however, I have come across my first problem where using a cursor outperforms a query. So I am forced to use it. I have created an elaborate ...
1
vote
0answers
15 views

Change Data Capture missing changes for a specific record

I have enabled CDC in SQL Server and it generally works well but sometimes the changes are not recorded for some reason. And only for a couple of records. But then if I issue an UPDATE from SSMS, the ...
2
votes
1answer
57 views

Scripting a maintenance plan

I created a maintenance plan for my SQL Server 2008 R2 using SQL Server Management Studio (SSMS). However, I am unable to export/convert it to a script, in case I need to redo it on another server. ...
1
vote
1answer
41 views

Restoring a database, changing recovery model

I regularly make a backup of my production database, then restore the same onto a test database, so developers can always have recent data for testing. The production database uses full recovery ...
0
votes
1answer
96 views

Why straight SQL query run faster than stored procedure?

I am facing-out a very surprising problem in SQL Server. The problem is when the query run in SSMS window it will return result in ~1 sec and when the query run through a stored procedure it will ...
1
vote
1answer
42 views

Maintenance plan backup and reload the same database

I want in my maintenance plan every night to copy the production database to a backup, and reload the newly-created backup into a test database. By reading here: Restore database - maintenance plan ...
0
votes
1answer
21 views

SSIS unpivot returns different results when run via a SQL agent job

I hope someone can help me. I have an SSIS package which grabs data from an excel (.xls) file, unpivots it from a rubbish format into a 'proper' format, transfers it to a SQL server 2008 R2 db, and ...
1
vote
1answer
66 views

SQL Server Multiple JOINS with Table Value Function - query never ends

I have a query with 4 joins using a table value function to get the data and when I execute it the query never ends. Issue Details Table valued function: CREATE FUNCTION [dbo].[GetIndicator] ( ...
4
votes
3answers
376 views

Why does transaction log continue to grow in Simple recovery mode with nightly backups

Before immediately marking as duplicate, I have read Mike Walsh's Why Does the Transaction Log Keep Growing or Run Out of Space?, but I don't think it gave an answer to my situation. I looked through ...
2
votes
2answers
65 views

Database events that will cause deletion of index

In SQL server if we try to change a data type of a column having index ,then it deletes the indexes associated with that column and changes the data type . I was not aware of it and was faced problem ...
1
vote
0answers
53 views

A query that does a lot of reads, but plan is OK [migrated]

I´m experiencing a strange behaviour in a specific query in the SQL Server 2008 R2. I´ve got a query that does 19 million reads and is very time-consuming and when I try to check its cached plan, the ...
3
votes
2answers
156 views

Alert when Job isn't triggered

I have a Sql Job on my server that is triggered nightly from a remote server (once it has completed its backups). I have successfully configured the job to notify me when it fails, but I would like ...
1
vote
1answer
26 views

Backup Certificate SQL Server and return bytes with a Select Statement

I have a certificate in a database in Microsoft SQL Server 2008 R2. I want to get a copy of the certificate so I can burn it onto a USB device and put it in a safe. I don't want to have to go onto the ...
2
votes
2answers
103 views

Is Information in sys.dm_db_index_usage_stats reliable

I'm archiving data from an old system that has no documentation. Lucky me... I'd like to find out when the tables were created, last accessed etc. Can I trust that this query will give me the correct ...
3
votes
2answers
193 views

Can I update every datetime in bulk?

The current database assumes all times are local to the user. Now we're changing this so the database stores everything in UTC and our application converts the UTC time in the database to the correct ...
5
votes
1answer
57 views

Full Text Search Term Casing Affects Results

I have been experiencing a full text problem when searching using CONTAINS. I have the full text catalog accent sensitive setting set to false. The table contains following rows: Microsoft C# ...
0
votes
1answer
29 views

How to find when change tracking was enabled?

How can I determine when change tracking was enabled on a table in a SQL database? Assume that this table has a regular cleanup routine, which means that looking at the oldest record in the change ...
0
votes
0answers
35 views

Migrating SQL Server 2008 R2 to SQL Server 2014. What are the importing replication changes?

We currently have SQL Server 2008 R2 on our server. I now have the opportunity to migrate to SQL Server 2014. The database we use isn't large. Migration of data is not a issue. The question I have ...
2
votes
1answer
32 views

Reporting services scheduled reports are clogging up sql job history log

This is a bit of a cross-disciplinary question - Hopefully I’ve posted in the right place. SQL server 2008 R2 Question: How can I limit the number of rows in [sysjobhistory] for specific jobs, ...
4
votes
2answers
128 views

How to write a query which finds all circular references when a table references itself? (II)

I have the following schema (names changed), which I cannot change: CREATE TABLE MyTable ( Id INT NOT NULL PRIMARY KEY, ParentId INT NOT NULL ); ALTER TABLE MyTable ADD FOREIGN KEY ...
0
votes
1answer
50 views

How to deploy SSIS package with XML config, using SQL agent

I wonder if anyone can help me with a question. Context I've created a database which needs a front end in MS Excel. When the user presses upload button I want it to start an SSIS package which moves ...
0
votes
0answers
38 views

How to avoid copy of audit trace files

My database is copying all of SQL-Server trace data file everyday. The result is I have to delete them manually everyday because hard disk gets filled. How can I stop this?
1
vote
2answers
79 views

Fixing an error 9004 without taking the database offline

My database (SQL Server 2008 r2) is running fine but I’m getting the following error in my event log. Error: 9004, Severity: 23, State: 6. An error occurred while processing the log for database ...
3
votes
4answers
506 views

How do I place leading zeros for numbers less than 10 without affecting those 10+?

Probably a newb question, but... I have a table with a VARCHAR field containing numbers 1 through 300. I need to place a leading zero in front of any numbers less than 10 while retaining the original ...
0
votes
3answers
64 views

How to display posted on date and time like1 hr ago or 30 min ago

i want to show the posted date like 1 hr ago.. or 30 min ago.. declare @date datetime ='2014-07-24 11:50:22.033'; SELECT CASE WHEN DATEPART(DD,@date)=DATEPART(DD,GETDATE()) THEN CASE WHEN ...
0
votes
2answers
106 views

SQL Server 2008 R2 memory issue

I have read many posts regarding the memory but still its not clear. I have dedicated server SQL Server 2008 R2 with Windows 2008 R2, 32 GB RAM, 2 6 core processor and a database of around 60 GB on ...
0
votes
2answers
54 views

How to provision the SQL Server Agent service after SQL Server Edition upgrade

I have upgraded SQL Server 2008 R2 Express to SQL Server Standard Edition. After I have upgraded it, the SQL Server Agent was stopped. I have tried to start but it fails. Only when I have changed ...
0
votes
2answers
91 views

Upgraded from SQL Server Express to standard but CPU usage is maximum 50% on dual core [closed]

I have upgraded SQL Server Express 2008 r2 to SQL Standard Edition on amazon EC2 with a Intel Xeon E5-2670 v2 (Ivy Bridge) Processors with 2 vCPU. I have verified the edition by running this: SELECT ...
2
votes
2answers
136 views

Table with 4 million records - different size and performance in development and production

At my company we use SQL Express 2008 R2, which supports databases up to 10GB. We have 2 databases with almost the same number of rows in all tables. But, one of them is 4.5 GB in size (which is in ...
0
votes
2answers
94 views

Query Optimization required - Subquery using Inner Join

Could anybody advise how can I optimize this query below please? SELECT IT.[iInternalTransactionID] , IT.[iInternalAccountID] , C.[iContractID] , IT.[dtTransactionDate] AS TransactionDate , ...
0
votes
0answers
57 views

SQL Server 2000 Named Instance cannot connect remotely

To facilitate a migration I installed SQL Server 2000 Standard Edition and Service Pack 4 as a named instance on server with an existing instance of SQL Server 2008R2 RTM. The issue I have is ...
0
votes
1answer
47 views

Sql Server sys.Traces log

Working with traces on production server I found some mysterious entries to me in sys.Traces, When I run below query it shows me status of all traces as ‘Paused’ along with entries in ...
1
vote
1answer
79 views

Enforce referential integrity between two groups of data

I have two sets of records: A collection of rules. A collection of actions to perform based on those rules. What I'm trying to model is something like this: Multiple rules can be grouped ...
0
votes
1answer
65 views

SQL Server 2008R2 Migration to new Platform - What Steps Required?

We are migrating our SQL Server 2008R2 instance from one Windows Server platform to another. SQL Server will remain as 2008R2. The new plaform will have more disk space, memory and CPU. I am doing up ...
1
vote
1answer
124 views

Two SQL Server databases setup with same .mdf and .ldf files

In a SQL Server 2008 R2 instance two databases (the second one being a restore/copy of the first one) have been setup against the same .mdf and .ldf files. How would I go about either deleting the ...
3
votes
3answers
123 views

Log File Management - Space on Disk

At our organisation we have several non-Production environments where Developers run free and wild with TSQL code and databases. The DBA team do not normally monitor or maintain them. Recently several ...
-3
votes
1answer
72 views

Select Top N rows for Employees in a SQL Server table

I would like to select the TOP 2 activities carried out by all employees from an Employees table "Emp" which has a timestamp column. The regular "Select Top 2 * from Emp...." will only fetch the top ...
0
votes
0answers
31 views

Rebuilding an index not working? [duplicate]

I noticed that when I right click manually on an index and choose "Rebuild" or "Reorganize", its not giving any indication that its doing so, then I click on properties again for the same index, I see ...
2
votes
1answer
64 views

SQL Server many-to-many relationship, row reuse?

Below is your typical many-to-many relationship. Pretend there are 2 tasks that have the exact same Tags. because of foreign key/primary key relationship constraints, there is no way for the rows in ...
0
votes
0answers
21 views

Garbage DB Objects Cleansing

How do I find in use db objects from all application pages is there any tool or trick I can use, just like we do search in Visual studio for an object in entire solution
0
votes
0answers
131 views

Error attaching mdf file to SQL Server 2008 R2 [closed]

When I want to attach a .mdf file to SQL Server 2008 R2, but I get the following error: Attach database failed for Server 'BABAK-PC'. Unable to open the physical file ...
4
votes
3answers
138 views

Virtual Log Files (VLFs) Fragmentation

I have a database with 160 VLFs. How do I determine whether the VLFs are fragmented? Further, how do I find the percentage of fragmentation? Another thing that I want to confirm: Are the following ...
0
votes
0answers
45 views

msdb 'backupset' log history

One of our production server‘s backup job is getting failed for one DB because of Low disk space when I looked into ‘physical_device_name’ column in ‘msdb.dbo.backupset’ to get the path of backups I ...
0
votes
1answer
29 views

Using existing SQL Server credentials for log shipping reporting purposes

I have set up log shipping, but I don't see how I can reset orphaned SQL Server credentials on the destination server as databases are in standby/read-only mode. I am getting push-back on ...
2
votes
1answer
324 views

Can I upgrade SQL Server 2008 R2 Standard to SQL Server 2014 Developer?

Is there a migration path to upgrade SQL Server 2008 R2 Standard to SQL Server 2014 Developer? If so, are there any pain points? If not, how would you recommend I proceed? The context of this ...
0
votes
1answer
30 views

Should I add it as an additional column or a seperate table?

I have a table in my SQL Server thats called "Regions", it has information about 9 regions and the 10th row holds the info about our Division. Now that we will be merging another 2 divisions with its ...
0
votes
2answers
68 views

Make a database inaccessible through “sa” user but should be accessible through another user

I have a database BugTracker which is accessible from "sa" user. I have just created new user AdminBugCatcher. I have also mapped "BugTracker" database with this user. But this database should not be ...
0
votes
0answers
49 views

Using SQL Server Import\Export Wizard with Ms. Access as a source DB

I need to copy this Ms. Access database that we have to test it in SQL Server 2008 R2, is the Import\Export wizard will let me copy all tables, queries, forms... without affecting the live database? I ...