Quantcast
Channel: Forum SQL Server Database Engine
Viewing all 15889 articles
Browse latest View live

backup and restore

$
0
0

I have two databases on the same mssql instance - testdb and mirrordb.

testdb has some data. mirrordb has no data.

I want to copy the data of testdb into mirrordb.

so I want to backup testdb and restore mirrordb from the backup file of testdb.

I tried :

BACKUP DATABASE "testdb" TO DISK='c:\mssql\backup\testdb.bkup' WITH NOFORMAT,INIT,STATS=10
restore DATABASE "mirrordb" from DISK='c:\mssql\backup\testdb.bkup' WITH recovery,STATS=10

but get the error :

Msg 3154, Level 16, State 4, Line 1

The backup set holds a backup of a database other than the existing 'mirrordb' database.

Msg 3013, Level 16, State 1, Line 1

RESTORE DATABASE is terminating abnormally.

can somebody tell me how to do this right?

appreciate the feedback.


Linked Server issue which connects to mainframe

$
0
0

I have a linked server which connects to Mainframe in production. The job was scheduled and running for a long time. This is failing now frequently with below error. But job is able to run manually after this failure.

Any help on this is greatly appreciated.

[SQLSTATE 42000] (Error 7399)  Cannot get the column information from OLE DB provider "MSDASQL" for linked server "TEST". [SQLSTATE 42000] (Error 7350).

Thanks.


Create views on index which has union operator

$
0
0

Hi All,

I have a view which is slow. I want to speed up that so i decided to create an index but view has lot of union operators so Is there any way to create a index if not is there any other way to speed up the view.

Thanks 

Can not log back after deleting default database

$
0
0

Hi,

I have deleted my default database on local machine with SQL Server 2008 R2, in order to copy/restore new copy.  But after deleting the database I can not log back in.  Neither with 'sa' or Windows authentication.

The following is the error I am getting:

"Can not connect to 'SQLSERVERNAME'. Login failed for user 'sa'. (Microsoft SQL Server, Error: 18456)"

Server Name: 'SERVERNAME'

Error Number: 18456

Severity: 14

State: 1

Line Number: 65536

This happened right after deleting the default database.  Is there a way of bringing back the deteleted default database or somehow log back in to my local sql server ?

Which Book to prefer?

$
0
0

Hi Folks, I was thinking of diving deep into features like CLR, Database mirroring, Monitoring, HA-DR, performance, profiling, CDC, and other similar (DBA) stuff.

Can anyone suggest me a good book which covers all these topics, and also have a beginners insights (in brief though).

Thanks in Advance.


Chaos isn’t a pit. Chaos is a ladder. Many who try to climb it fail and never get to try again. The fall breaks them. And some are given a chance to climb, but they refuse. They cling to the realm, or the gods, or love. Illusions. Only the ladder is real. The climb is all there is.

The log scan number passed to log scan in database 'master' is not valid.

$
0
0

I get the error below when the SQL server tries to start. They have backups of the SQL server files but not BAK files just Symantec files backups of the SQL Server folder. I’ve tried replacing the master.mdf and mastlog.ldf files from the backups but I still get the same error with different log scan numbers. Also tried replacing the model files and that just created errors.

Looking around online it gets very confusing as some say it’s the master database or
the model or that the user and password has changed. Some say to copy the master
database files from the template folder but there is none on this system.<o:p></o:p>


Any ideas? Thanks.

The log scan number (137:128:37) passed to log scan in database 'master' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.



MEMORYCLERK_SQLBUFFERPOOL

$
0
0
One of UAT server is taking a lot of RAM. It turns out that virtual_memory_committed_kb(1408664) is twice as compared to my Prod.

What should I do? I have restarted the Server a couple of days ago... it was fine for few days but now again the same issue. 

Please help.

Sid

dm_os_performance_counters not being created for "some" new databases

$
0
0

I have noticed that a couple of our SQL 2008 R2 Ent (10.50.4286) servers are having trouble creating the os performance counters (database level only). I rebooted each of them during a planned downtime and the problem cleared. A few days later I added two new databases to one of the previously affected servers.  Nothing special about either database in fact their just empty shells our development team with populate later.  The first database didn't get any performance counters generated for it.  The second populated just fine.  I confirmed through perfmon that I couldn't find the first database in the list of choices.  I am sure a reboot will probably clear the problem.  However, these are production servers so chances to reboot them only come around once per quarter.  I have run the unload and reload counters command and it had no affect.

Anyone else having this issue?


xp_create_subdir() returned error 183, 'Cannot create a file when that file already exists.'

$
0
0

I have an unusual question (error) to resolve.  I have a 2008R2 SQL Server which has localsystem as it's SQL Server Service and SQL Server Agent.  I cannot change this to a domain account due to the application integration (don't ask).  I created a credential using an AD domain account.  I added this domain account to SQL Server Logins and made it 'sa'.  I also mapped the credential to it.

I then created a proxy and linked it with the credential.  I created both T-SQL SQL agent job and a Maintenance Plan job to create backups to our NAS.  I've given the AD Domain account mapped with the cridential full write permissions to the NAS folder.  But I'm getting permission errors.  I've tested the SQL from my workstation, using 'Run As' the service account on SSMS mentioned above and it works fine, so I know the service account can write to the NAS folder.  It's permissions on the server that is using localsystem for it's two SQL service accounts.

I've changed the job step on the Maintenance job from SQL Server Agent to the Proxy.  Proxy is not available on the T-SQL SQL agent job.   

Msg 22048, Level 16, State 1, Line 0
xp_create_subdir() returned error 183, 'Cannot create a file when that file already exists.'
Msg 3201, Level 16, State 1, Line 1
Cannot open backup device '\\someServerName\SomeDirectories\someDatabaseFiles_TodaysDate.full.bak'. Operating system error 5(Access is denied.).
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
Msg 22048, Level 16, State 1, Line 0
xp_create_subdir() returned error 183, 'Cannot create a file when that file already exists.'
Msg 3201, Level 16, State 1, Line 1
Cannot open backup device '\\someServerName\SomeDirectories\someDatabaseFiles_TodaysDate.full.bak'. Operating system error 5(Access is denied.).
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
Msg 22048, Level 16, State 1, Line 0
xp_create_subdir() returned error 183, 'Cannot create a file when that file already exists.'
Msg 3201, Level 16, State 1, Line 1
Cannot open backup device '\\someServerName\SomeDirectories\someDatabaseFiles_TodaysDate.full.bak'. Operating system error 5(Access is denied.).
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
Msg 22048, Level 16, State 1, Line 0
xp_create_subdir() returned error 183, 'Cannot create a file when that file already exists.'
Msg 3201, Level 16, State 1, Line 1
Cannot open backup device '\\someServerName\SomeDirectories\someDatabaseFiles_TodaysDate.full.bak'. Operating system error 5(Access is denied.).
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
Msg 22048, Level 16, State 1, Line 0
xp_create_subdir() returned error 183, 'Cannot create a file when that file already exists.'
Msg 3201, Level 16, State 1, Line 1
Cannot open backup device '\\someServerName\SomeDirectories\someDatabaseFiles_TodaysDate.full.bak'. Operating system error 5(Access is denied.).
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
Msg 22048, Level 16, State 1, Line 0
xp_create_subdir() returned error 183, 'Cannot create a file when that file already exists.'
Msg 3201, Level 16, State 1, Line 1
Cannot open backup device '\\someServerName\SomeDirectories\someDatabaseFiles_TodaysDate.full.bak'. Operating system error 5(Access is denied.).
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.

Things I've tried:

Changed ownership of SQL jobs to the domain account
Changed Maintenance Plan Ownership to domain account
Added domain account to Backup Operators
Added domain account to SQLServerMSSQLUser$....local group

Added domain account to SQLServerAgentUser$.....local group
Added domain account to local admin group

Everything I am finding says to change the service accounts to AD accounts.  I cannot do that.  Any suggestions would be greatly appreciated.

NULL query_plan value from DMV's.

$
0
0

Greetings. Im attempting to get the exec plan from a sproc that occasionally needs to be recompiled. However, as described in this article I'm unable to produce it, and a NULL is returned. 

So I take the PowerShell method outlined in the article. It works for every other sproc I try, but for the sproc in question an empty file is output. 

One interesting fun fact about this sproc is that the query below returns two values, each with a unique plan_handle value. Not sure that's the cause of my issue, but thought it worth mentioning. 

So, does anyone know how I can get this plan?

SELECT * FROM sys.dm_exec_procedure_stats ps
    JOIN sys.objects o on ps.object_id = o.object_id
WHERE o.name = 'mySproc'


TIA, ChrisRDBA

sp_prepexec results in different and bad execution plan

$
0
0

Hi,

We massively imported 1.5 million rows in a software database table a couple of weeks ago. Since that time, the queries in the search screen perform pourly. I caught those requests and figured out an index that would help them. In my tests the index helped the queries a lot but in the application it didn’t change anything. I found out that the queries, when ran in a sp_prepexec, didn’t use the new index, even if I updated the statistics. What am I missing here?

The queries : 

declare @p1 int
exec sp_prepexec @p1 output,N'@P0 int,@P1 int,@P2 int,@P3 int,@P4 int,@P5 varchar(8000)',N'SELECT COUNT(*) FROM (SELECT TOP (301) 1 as countCol FROM ab_abcontact qRoot WHERE qRoot.Subtype IN (@P0,@P1,@P2,@P3,@P4) AND qRoot.KeywordDenorm LIKE @P5 COLLATE French_CI_AI AND qRoot.StateDenorm = 10063 AND qRoot.CountryDenorm = 10039 AND qRoot.Retired = 0) countTable',5,8,9,11,13,'%fix auto beauport%'
select @p1

Returns in 3975ms.

prepexec plan

SELECT COUNT(*) FROM (SELECT TOP (301) 1 as countCol FROM ab_abcontact qRoot WHERE qRoot.Subtype IN (5,8,9,11,13) AND qRoot.KeywordDenorm LIKE '%fix auto beauport%' COLLATE French_CI_AI AND qRoot.StateDenorm = 10063 AND qRoot.CountryDenorm = 10039 AND qRoot.Retired = 0) countTable;

Returns in 59ms.

direct select

Thanks a lot,

Jean-Michel


Jean-Michel




LOGBUFFER and WRITELOG waits but no IO issue?

$
0
0

This is a really odd one.  Everytime I encounter these particular waits at a customer site its due to poor configuration or under sized storage units.  This is happening in house in a test lab where I can verify everything.

I have 90+ queries that are trying to do truncates, inserts, updates, and deletes and are all waiting on one of the above waits.  Perfmon shows no activity on the disk.  The disk array shows no activity on its performance monitor.  I can even run a quick IO sim with test datafiles on the same LUNs and it works as expected.  No Windows errors are showing up in the event log.

Configuration:

  • SQL Server 2012 Enterprise
  • 2 x 8 Core 2.5Ghz CPUs, blade server
  • 128GB RAM, 40GB dedicated to SQL
  • Nothing else on box
  • Blade is using FCoE to blade chassis and then FC to the SAN
  • gobs of RAM on disk array.  stripped over 64 15K FC disks

I'm getting the usual spew of crap into the SQL ERRORLOG:

2012-10-04 16:29:44.96 spid24s     A time-out occurred while waiting for buffer latch -- type 2, bp 00000020FEF9C240, page 1:139, stat 0x9, database id: 6, allocation unit Id: 458752/281474977169408, task 0x0000001D03E27C38 : 0, waittime 300 seconds, flags 0x3a, owning task 0x0000002056BD6188. Not continuing to wait.
2012-10-04 16:30:48.25 spid8s      SQL Server has encountered 14 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [C:\db\tempDB\1\Database24_100_Log_2.ldf] in database [Database_24] (5).  The OS file handle is 0x0000000000001C18.  The offset of the latest long I/O is: 0x000001d09a8a00
2012-10-04 16:31:43.85 spid8s      SQL Server has encountered 5 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [c:\db\log\Database_24_Stage_log.ldf] in database [Database_24_Stage] (6).  The OS file handle is 0x0000000000000C18.  The offset of the latest long I/O is: 0x0000038542bc00
2012-10-04 16:37:27.54 spid8s      SQL Server has encountered 13 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [c:\db\log\Database_24_Stage_log.ldf] in database [Database_24_Stage] (6).  The OS file handle is 0x0000000000000C18.  The offset of the latest long I/O is: 0x000003858eaa00
2012-10-04 16:39:17.73 spid124     Timeout occurred while waiting for latch: class 'ACCESS_METHODS_HOBT_COUNT', id 0000001E9C80B010, type 2, Task 0x000000205800E558 : 0, waittime 300 seconds, flags 0x1a, owning task 0x00000020FD944928. Continuing to wait.

2012-10-04 16:42:15.65 spid8s      SQL Server has encountered 3 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [C:\db\tempDB\1\Database24_100_Log_2.ldf] in database [Database_24] (5).  The OS file handle is 0x0000000000001C18.  The offset of the latest long I/O is: 0x000001d0d90e00
2012-10-04 16:44:17.75 spid124     Timeout occurred while waiting for latch: class 'ACCESS_METHODS_HOBT_COUNT', id 0000001E9C80B010, type 2, Task 0x000000205800E558 : 0, waittime 600 seconds, flags 0x1a, owning task 0x00000020FD944928. Continuing to wait.

2012-10-04 16:48:04.40 spid8s      SQL Server has encountered 13 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [C:\db\tempDB\1\Database24_100_Log_2.ldf] in database [Database_24] (5).  The OS file handle is 0x0000000000001C18.  The offset of the latest long I/O is: 0x000001d10f6e00
2012-10-04 16:49:17.77 spid124     Timeout occurred while waiting for latch: class 'ACCESS_METHODS_HOBT_COUNT', id 0000001E9C80B010, type 2, Task 0x000000205800E558 : 0, waittime 900 seconds, flags 0x1a, owning task 0x00000020FD944928. Continuing to wait.

2012-10-04 16:49:55.60 spid8s      SQL Server has encountered 4 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [c:\db\log\Database_24_Stage_log.ldf] in database [Database_24_Stage] (6).  The OS file handle is 0x0000000000000C18.  The offset of the latest long I/O is: 0x00000385d4d400
2012-10-04 16:50:51.19 spid8s      SQL Server has encountered 90 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [c:\db\tempdb\1\tempdev.mdf] in database [tempdb] (2).  The OS file handle is 0x0000000000000D18.  The offset of the latest long I/O is: 0x00000000226000
2012-10-04 16:53:48.10 spid8s      SQL Server has encountered 6 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [C:\db\tempDB\1\Database24_100_Log_2.ldf] in database [Database_24] (5).  The OS file handle is 0x0000000000001C18.  The offset of the latest long I/O is: 0x000001d13d5e00
2012-10-04 16:55:39.30 spid8s      SQL Server has encountered 13 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [c:\db\log\Database_24_Stage_log.ldf] in database [Database_24_Stage] (6).  The OS file handle is 0x0000000000000C18.  The offset of the latest long I/O is: 0x000003860b2200
2012-10-04 16:57:36.18 spid53      A time-out occurred while waiting for buffer latch -- type 4, bp 000000211D81E7C0, page 1:303, stat 0x40d, database id: 2, allocation unit Id: 72057595871166464, task 0x0000002056BC5C38 : 0, waittime 300 seconds, flags 0x1a, owning task 0x0000002056BC5C38. Not continuing to wait.
2012-10-04 16:57:55.78 spid8s      SQL Server has encountered 2 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [c:\db\tempdb\1\tempdev.mdf] in database [tempdb] (2).  The OS file handle is 0x0000000000000D18.  The offset of the latest long I/O is: 0x00000000260000
2012-10-04 16:59:31.82 spid8s      SQL Server has encountered 6 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [C:\db\tempDB\1\Database24_100_Log_2.ldf] in database [Database_24] (5).  The OS file handle is 0x0000000000001C18.  The offset of the latest long I/O is: 0x000001d164a800
2012-10-04 17:00:21.98 spid74      Timeout occurred while waiting for latch: class 'ACCESS_METHODS_HOBT_COUNT', id 0000002079F738F0, type 2, Task 0x00000020FD065498 : 0, waittime 300 seconds, flags 0x1a, owning task 0x00000020FD944928. Continuing to wait.

Automated database restore from Production to Development

$
0
0
Hello,
Please guide me for Automate Database restore from Production to Development for daily basis. New to this task. Please guide me that would be appreciate. 

SQL Server Domain password

$
0
0
 Is there any way I can recover SQL Service Domain password or password which installed under the SQL Server service. IS there anyway I can decrypt? Please help me.....Thanks

MSSQLSERVER stopped after reboot for domain account

$
0
0

Hi everyone,

I installed SQL Enterprise Server 2012 under a domain account: domain\username. During installation, my domain account is temporarily granted Admin rights and everything runs ok. But after rebooting PC (domain account loses Admin rights), MSSQLSERVER service stopped (actually all SQL server services stopped: MSSQLFDLauncher, MSSQLServerOLAPService etc). 

Can anyone tell me is it a SQL server configuration problem (i.e. need specific settings for domain user) or Windows access rights problem? I use default service setting e.g.: NT Service/MSSQLSERVER.

Regards


Filetable Query Performance

$
0
0

Hi,

I have a small web app that basically provides a Search Engine-like keyword entry to search approx. 50k documents stored in directories, which I access through a Filetable Query on SQL server 2012.

I get great performance on this - typically less than half a second. Except for the first query of the day - it takes over 30 seconds. Then same or different keywords will be back under half a second.

What could SQL Server be initializing? Does anyone else see this kind of behaviour?

I added a schedule to populate the Full-text catalog at 06:00 every day but that made no difference.

Any help appreciated.

sql server 2012 login transfer to 2012

$
0
0

hi,

i have 2 mssql server one is std and another is ent edition.  i created 3 database and transfer them from one sql server to another . it was successfully transfered.now i tried to transfer the login from old server to new one with their respective permission on each database. how can i perform this task. please tell me the simplest way. coz i am very new to sql server. don't know scripting.

plz help.

Where must oledb providers be installed?

$
0
0

I've installed Office 2007 Data Connectivity Components and Access Database Engine 2010 Redistributable on the server.  I've created the following stored procedure and can execute it successfully in SSMS on the server.

CREATE PROCEDURE [dbo].[usp_POLineFollowUpStaging_Insert]
(
 @File VARCHAR(100) = NULL
)
AS
SET NOCOUNT ON
DECLARE @SQL VARCHAR(2000)

SET @SQL =
'SELECT *
FROM OPENROWSET(''Microsoft.ACE.OLEDB.12.0''
, ''Excel 12.0;Database=\\domain\FilePath\' + @File + ';''
, ''SELECT * FROM [Sheet1$]'')'

EXEC(@SQL);

However, when I try to execute this procedure in SSMS on a client it fails.  I would like to understand why it fails when run on a client.  I'm guessing it's because Office 2007 Data Connectivity Components and Access Database Engine 2010 Redistributable are not installed on the client.  Since the procedure, components, and redistributable are all on server I thought it would work.


Kevin

Add IBM.Data.DB2.iSeries.Dll Assembly To SQL CLR Causes Errors

$
0
0

I'm writing CLR procs against DB2. Code works as a standalone. When I try to add the IBM.Data.DB2.iSeries.dll as an assembly to my SQL Server database, I get the following error below. I can't find the assembly in the GAC on my server. What's the dependency chain for this dll?


DJ Baby Anne's Biggest Fan................

looking for a query to find first/last dates in overlapping dates...

$
0
0

Hi,

I'm looking for a query to find the first dates and last dates in a table conaining overlapping dates.

I have a subscription table which has for each Customer start and end date for different subscriptions.

I want to know the different ranges of date where there is subscriptions active.

so if the table has this:

CustID, Start date, end date

1, 2008-01-01, 2012-06-06

1 ,2009-01-01, 2011-01-01

1, 2011-01-01, 2013-02-02

1, 2013-01-01, 2013-08-08

1, 2014-01-01, 2014-04-04

I want to produce this result:

custid, range start, range end

1, 2008-01-01, 2013-08-08

1, 2014-01-01, 2014-04-04

the first row is the range identified from the 4 rows in my subscription table.

thanks :)

Viewing all 15889 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>