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

Error 32 When Restoring Database

$
0
0

I'm attempting to restore a SQL Server 2008 R2 backup into a SQL Server 2014 database WITH MOVE but am encountering the following error:

The operating system returned the error '32(The process cannot access the file because it is being used by another process.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'E:\Intuitive8.7Data\iERP87_Data.mdf'.

Following is the code I'm using attempting to accomplish this:

USE Master
GO

ALTER DATABASE iERP87 SET OFFLINE WITH ROLLBACK IMMEDIATE;

RESTORE DATABASE [iERP87]
FROM DISK = N'E:\Temp\iERP81_2008.bak'
WITH
MOVE N'Production70_Data' TO N'E:\Intuitive8.7Data\iERP87_Data.mdf',
MOVE N'Production70_Log' TO N'E:\Intuitive8.7Log\iERP87_Log.ldf',
NOUNLOAD, REPLACE, STATS = 10

ALTER DATABASE iERP87 SET ONLINE WITH ROLLBACK IMMEDIATE;

As a result of searching on-line for help I have user "Process Explorer" to look for processes using the mdf file without finding any and have rebooted the server to ensure there are no other open connections.

I've run out of ideas on this one.  Any help would be most appreciated.


does profiler pick up olap queries too

$
0
0

Hi we run 2008 r2 and i'll be using whatever tool is necessary to capture a 3rd party query to investigate a balancing issue.  It might be relational, might not as we have both kinds of data sources for the type of info being reported.

Can profiler also catch mdx queries or is it strictly a relational query type trace tool?  Also, if I trap my trace in files, how do I deal with the question of which program windows should use to open them?  Right now it doesn't know.

sys.spt_tables_info_view is being blocked

$
0
0
Hi,

I see the below queries is blocked every time ... Another observation is, the query blocked are from different servers connecting using linked servers. 

Query blocked

select
        TABLE_CATALOG           = s_tiv.TABLE_CATALOG,
        TABLE_SCHEMA            = s_tiv.TABLE_SCHEMA,
        TABLE_NAME              = s_tiv.TABLE_NAME,
        TABLE_TYPE              = s_tiv.TABLE_TYPE,
        TABLE_GUID              = s_tiv.TABLE_GUID,
        BOOKMARKS               = s_tiv.BOOKMARKS,
        BOOKMARK_TYPE           = s_tiv.BOOKMARK_TYPE,
        BOOKMARK_DATATYPE       = convert(smallint, 21), --DBTYPE_UI8
        BOOKMARK_MAXIMUM_LENGTH = convert(int, 8),
        BOOKMARK_INFORMATION    = s_tiv.BOOKMARK_INFORMATION,
        TABLE_VERSION           = s_tiv.TABLE_VERSION,
        CARDINALITY             = s_tiv.CARDINALITY,
        DESCRIPTION             = s_tiv.DESCRIPTION,
        TABLE_PROPID            = s_tiv.TABLE_PROPID,
        TABLE_FLAGS             = s_tiv.TABLE_FLAGS
    from
        sys.spt_tables_info_view s_tiv
    where
        (
            (@table_schema is null and s_tiv.TABLE_NAME = @table_name) or
            object_id(quotename(@table_schema) + '.' + quotename(@table_name)) = s_tiv.object_id
        ) and
        (@table_type is null or @table_type = s_tiv.TABLE_TYPE)
    order by 4, 2, 3



Query at the head of blocking chain

SELECT StatMan([SC0])
FROM (SELECT TOP 100 PERCENT [ROLEID] AS [SC0] FROM [dbo].[#TMP_AP_ROLE_USER_______________________________________________________________________________________________000000EAD1DD] WITH (READUNCOMMITTED)  ORDER BY [SC0] ) AS _MS_UPDSTATS_TBL

Suman

Issue using Windows login for Oracle linked server, SQL login works fine with same permissions

$
0
0

I am seeing a issue with one of the oracle linked servers. I as a SA can access everything and am having no issues. One of the sql windows logins which the app is using is having issues with one partiucular oracle table, that login can acess other tables. Login has dbo permissions on the sql database. I created a test sql login and made it dbo on the same db & I got access error to SYS.XP_PROP_OLEDB_PROVIDER, following solved it:

USE [master]
GO
CREATE USER [] FOR LOGIN []
GO
USE MASTER
GO
GRANT EXECUTE ON SYS.XP_PROP_OLEDB_PROVIDER TO [];

---

now the test sql login had no issues running the linked server OPENQUERY t-sqls. I gave the same permission to the windows login but it still fails on a particular OPENQUERY:

SELECT *
FROM OPENQUERY(linkedservernamehere, 'SELECT * FROM problemtablenamehere')

--

giving following error:

The OLE DB provider "OraOLEDB.Oracle" for linked server "linkedservernamehere" supplied inconsistent metadata. The object "[OraOLEDB.Oracle]" was missing the expected column "columnnamehere_which_I_don't_see_when_run_as_sa_on_results".

--

so, all in all, if i login as a SA on SQL - no issues. If I login as a sql login with same permissions as windows login - no issues. But if the app engg logs in using WINDOWS login - then he gets the errors only on a single problem table, he can access others with no issues, not sure how to proceed, thanks.


D

IN Operator

$
0
0

what would be the result , if there is no column ORDERID in the customers table

SELECT * from Orders WHERE ORDERID IN (SELECT orderid FROM CUSTOMERS)


SQL server taking all the CPU and RAM

$
0
0

Dear All,

I have a SQL Server 2008 standard edition with 20 GB RAM and have allocated 17 GB of RAM memory to SQL Server and 4 CPU.
But Since last 1 week i am facing issue in SQL server, The issue is SQL Server reaches 100% CPU usage constantly , have checked there is no single query is running in sql by using below dm views

SELECT Text from sys.dm_exec_request cross apply sys.dm_exec_sql_text(sql_handle)

I have also checked in task manager but only sqlserver.exe taking 100% CPU and Physical Memory Both
Then i have restarted the sql server, during restart process, the utilization gets decreases but Once the service gets started, Again the CPU and Physical Memory reaches to 100 % and it doesn't release the memory.The Only solution which i have used is rebooted the server, but it would not be the solution because the server is in Production.

I thought there might b issue with the antivirus have disabled it but nothing happend good, also checked in counter and found the total sql server memory(KB) is taking all 20GB and all the counter thresh hold values are normal.

I don't know where is the issue, I would thankful to you guys if someone help me.  

Thank you

Procedure is taking much time

$
0
0

Dear Team,

This is to inform you that i have a something like below procedure (PROCEDURE --1) in my production environment, but if i am running this procedure by passing parameter to 1000 it is taking around 5 minute ,

But If i am running second Procedure (PROCEDURE --2) its takes only 2 second 

Have recompile the SP,drop and recreated the same but it is taking same time and i got confused what to do next.

As the Statistics is also updated and reorganizes the index , fragmentation of index is also 0 for the table which is using in the Stored Procedure but haven't found any resolution.

PROCEDURE --1

ALTER Procedure [dbo].[Test1]
(
@rows INT 
)
As
Begin
Declare @internalRow INT
SET @internalRow = @rows
SELECT TOP (@internalRow) ,refclientid from RefClient
END

PROCEDURE --2

CREATE Procedure [dbo].[Test2]
As
Begin
SELECT TOP 1000 * from RefClient
END

SQL Server 2012 CLR allocations problem

$
0
0

Hello everybody!

After upgrading from Microsoft SQL Server 2008 to Microsoft SQL Server 2012 we faced with CLR allocations problem. In earlier versions of SQL Server CLR allocations were in virtual address space (also known as "Memory-To-Leave"). In SQL Server 2008 you can configure max_server_memory for SQL server, prevent starting other processes on server and it will guaranty you that your CLR will not unload due memory pressure (use “lock pages in memory”)

In SQL Server 2012 there were big changes in memory management.  The key change for us was relocating (or splitting) CLR allocations from "Memory-To-Leave" to "max server memory (MB)". And now you can get “AppDomain 2 (work5nt.dbo[runtime].1) is marked for unload due to memory pressure.” message in server log  with future unloading AppDomain when “Query Execution Memory” grows fast.

During our stress tests of SQL server 2012 I had rapid growth of “Granted Workspace Memory (KB)” to more than 50% of max_server_memory (72GB). Top wait on server was RESOURCE_SEMAPHORE and «SQL Memory Manager:Memory Grants Pending»  growth up to 154 processes.

Information from log file about unloading:

2015-03-26 19:49:20.15 spid18s     AppDomain 13 (work5nt.dbo[runtime].82) is marked for unload due to memory pressure.

2015-03-26 19:49:20.15 spid18s     AppDomain 12 (mssqlsystemresource.dbo[runtime].81) is marked for unload due to memory pressure.

2015-03-26 19:49:20.15 spid19s     AppDomain 13 (work5nt.dbo[runtime].82) unloaded.

2015-03-26 19:49:20.15 spid18s     AppDomain 12 (mssqlsystemresource.dbo[runtime].81) unloaded.

2015-03-26 19:49:20.83 spid419     AppDomain 14 (work5nt.dbo[runtime].94) created.

2015-03-26 19:49:20.86 spid245     Unsafe assembly 'log, version=1.0.5498.27124, culture=neutral, publickeytoken=bb8adbf0186b255f, processorarchitecture=msil' loaded into appdomain 14 (work5nt.dbo[runtime].94).

2015-03-26 19:49:20.86 spid419     Unsafe assembly 'seed, version=1.0.5539.32591, culture=neutral, publickeytoken=4d4e4ff7fd85d31c, processorarchitecture=msil' loaded into appdomain 14 (work5nt.dbo[runtime].94).

2015-03-26 19:49:20.89 spid245     Unsafe assembly 'log, version=1.0.5498.27124, culture=neutral, publickeytoken=bb8adbf0186b255f, processorarchitecture=msil' loaded into appdomain 14 (work5nt.dbo[runtime].94).

2015-03-26 19:49:20.91 spid419     Unsafe assembly 'seed, version=1.0.5539.32591, culture=neutral, publickeytoken=4d4e4ff7fd85d31c, processorarchitecture=msil' loaded into appdomain 14 (work5nt.dbo[runtime].94).

 

Our product can get critical error after unloading CLR. (We are working on that problem but it’s not SQL server side problem.)

 

Main memory counters during stress test (perfmon):

Name

Average

Min

Max

Total Server Memory (KB)

75 783 960

75 774 432

75 880 536

ReservedServerMemory (KB)

18 474 365

9 028 744

35 325 584

GrantedWorkspaceMemory (KB):

27 173 700

16 992 392

51 791 136

Reserved/Granted Ratio

0.68

0.53

0.68

So we can see, that highest Reserved Server Memory more than 46% of Total Server Memory! And it is strange.

At the end I have several questions:

Here the first one: How can I avoid unloading CLR due memory pressure on SQL server 2012?

Second one: Can I configure “Reserved Server Memory” for query or server?

And the last one: Is there any extended events to reveal which query consumed a lot of memory? I found sort_memory_grant_adjustment but it does not work or I can’t configure it right.

 

About my system:

Servers HP Proliant BL620c G7

Duble 3PAR StoreServ Storage 7200 with remote copy “on” and adaptive optimization “on”

Virtualization:ESXi 5.5.0, 2302651

Software:

Microsoft Windows 2008 Server R2 Enterprise 7601

Microsoft SQL Server 2012 - 11.0.5058.0 Enterprise Edition (64-bit)  SP2

VM:

Xenon E7-2870 @2.40 GHz 16 cores (2 sockets, 8 cores), RAM 80GB.

SQL Server memory configure:

max server memory (MB) 74000

min memory per query (KB) 2048

minservermemory (MB)  128

sql server starts with  -T 1222 -T 1224 -g 512,

Using locked pages in the memory manager,

Large Page Allocated: 32MB,

CLR version v4.0.30319

  

If you need more information please feel free to contact with me.


Enterprise feature- Data compression in SQL server 2008R2

$
0
0

Hello,

We are downgrading couple of SQL servers from Enterprise to Standard, which we were successfully for one which was not using any of the enterprise features:

But for one, we found that the instance has 4 databases, basically the share point databases, one those start with naming conventions i.e TFS_xx( Foundation server DB;s i believe ) using data compression:

Used below query to identify the objects in those DB using data compression and found quite a number of tables doing so basically using Page compression:

SELECT
SCHEMA_NAME(sys.objects.schema_id) AS [SchemaName]
,OBJECT_NAME(sys.objects.object_id) AS [ObjectName]
,[rows]
,[data_compression_desc]
,[index_id] as [IndexID_on_Table]
FROM sys.partitions
INNER JOIN sys.objects
ON sys.partitions.object_id = sys.objects.object_id
WHERE data_compression > 0
AND SCHEMA_NAME(sys.objects.schema_id) <> 'SYS'
ORDER BY SchemaName, ObjectName

Also, i tried to read more on what benefit we may be getting using above from sp_estimate but not able to figure out if this feature is really needed.

Can someone please help how can i analyse what could be the reason we are using and to proove if its really needed else we can go ahead and downgrade because we cannot proceed unless and until this is removed!

Please suggest, thanks!

how to get multiselect value in a variable in sql server function

$
0
0
i have a column with mulitple ids stored with commas . i want to pass ids and get data along with name from the table..
OR how to get multiselect value in a variable in  sql server function 

SQL 2008 Page Life Expectancy very high

$
0
0

When I run the following query to determine the Page Life Expectancy:  SELECT cntr_valueAS'Page Life Expectancy'FROMsys.dm_os_performance_countersWHEREobject_name='SQLServer:Buffer Manager'AND counter_name='Page life expectancy'

It returns a value greater than 120,000, Shouldn't this value be in seconds?  So that would work out to 33 Hours, that does not seem right?  The server is a Virtual Windows 2008 R2 Enterprise running SQL 2008 Standard.  It has 24 GB in the box and 22.5 allocated to SQL.  The Buffer Cache is roughly 99% and the Target Server Memory (KB) is 21764.  So SQL is not using all of the RAM Allocated to it

SSDT database code relase

$
0
0

Hello Friends,

I would like to know database code deployment from DEV to QA/PROD database server. I can use SSDT tools.

Please help me in this as it has been a problem for us as we have developers in different geo locations.

All I want is to generate new/modified scripts in order with some filter capabilities (because some time not all the change scripts in DEV suppose to go QA or PROD)..

Thanks in advance

Best Practise to Restart SQL Server Services

$
0
0

Hi All,

I know that we can restart SQl Services in different ways Like from

--> Services

--> Configuration manager.

What is the best way out of this?

Do we need stop and start the Services are do we need to restart?

Thanks in Advance

Memory leak on Bound tree (CACHESTORE_PHDR) MS SQL 2014

$
0
0

Hello everybody.

I have problem on one of my test SQL Server 2014 Dev edition (12.0.2495.0 (X64)) on Windows server 2012 standard. It is memory leak on CACHESTORE_PHDR clerk and my query completes  with following error: 

Msg 701, Level 17, State 123, Line 14
There is insufficient system memory in resource pool 'default' to run this query.

In trace I have the same error for 'internal' resource pool.

Before  I got this error , I've checked memory clerks using sys.dm_os_memory_clerks and saw  CACHESTORE_PHDR consumed about 5500MB ('max server memory (MB)' is 6144). I have two different queries with this problem and both of them got error only on one server and one database.

I tried to repeat this error on the same database (backup/restore) on different instance/server but it didn't repeated :( 

How can I find out whatexactly in my tsql code causes memory leak?

Both queries have many self left joins (second one have more than 20 self joins)

Cannot view the SQLDIAG extended events log file with SSMS on SQL Server 2012 SP2 CU5

$
0
0

I have a production SQL 2012 instance recently updated to SP2 and CU5 from RTM release.  To investigate an alwayson problem, I need to view the log file. I tried double clicking the file to view in SSMS but 0 events are displayed even though there is content in the file. I moved the file to another instance elsewhere which is still at RTM level and the file opens up showing content.

On the face of it, this seems like a bug but I may be overlooking something. Any advice would be appreciated. It looks like all other extended events logs have the same issue and just the SQLDIAG extended events logs.


Missing built-in functions

$
0
0

I am using MS SQL Server Management Studio version 10.50. Some built-in functions are missing, such as LAST_VALUE and IIF. Where can I get those?

How to install SSRS

$
0
0

I am using SQL Server 2008 R2. I'd like to set up a reporting server with SSRS but I cannot find out how to install it. Please help.

Thanks

Log size Increases

$
0
0

Dear Team,

Is this Possible, If database is in Simple recovery Mode and the ldf size gets increased?? .

mdf size :  159 GB (171,383,717,888 bytes)

ldf size : 6.46 GB (6,945,505,280 bytes).

My question is if the recovery model is in Simple Mode then why the log gets generated high.

dbcc sqlperf(logspace) --output

DATABASE  Logsize(MB)      Log space used(%)     status

mam        6623.742       0.4305579             0

Is there any issue or it is Normal.

Does restarting a SQL database kill all processes?

$
0
0

A couple of days ago, our SQL Server 2008 R2 was having issues.

All reports coming from it either timed out or took extremely long to run.

Logging onto the server over remote desktop seemed slow as well.

CPU and memory usage on the server was high but not 100% pegged.

Tried to look at Activity Monitor within SSMS but clicking on processes caused a time out as well.

I looked at the running queries but nothing stood out.

I ended up restarting the server itself and after it came back up, the CPU and memory came down like expected but all reports were still slow or were timing out. Activity Monitor still timed out as well.

When I came in the following morning, however, the system worked normally. I didn't change anything, which is driving me crazy.

If you restart the server, does any process just automatically start back up again that could cause the slow down and that same process can time out after a period of time?

This server is running SQL Server 2008 R2 on a Windows 2008 R2 box. Nothing else runs on it besides SQL Server (single instance and 3 databases) and a SSIS package that runs on it overnight that usually takes about 2 1/2 hours to run.


Heath

Configuring 'Tempdb' in sql server 2005

$
0
0

Hello,

For one of our servers, which has its tempdb growing tremendously on this reporting server has become an issue for shortage of space on the drive:

This tempdb has 4 data files and one log file all on same drive of size 200 GB , where tempdb files keep occupying 90 % of space.

When we looked at space usage we see below values in KB

user obj= 1024internal obj= 2560version_store=13824 free_space= 34615680   mixed_extent=2688

After every maintenance activity where servers are rebooted, space from disk is released and later in a day it fills up to nearly 100 GB

As of now we had a server reboot on Sunday and today we see all four files occupying nearly 40 GB with so much of free space as shown above.

So i am wandering, should i split the data files on separate disk? if yes what measures needs to be taken?

The server is SQL server 2005 SP3.

All data files are of initial size 8MB with 100 MB autogrowth , which have all gown to 10 GB each.

Is there something wrong or is it an OK process and we should look for storage?

Please advise.

Viewing all 15872 articles
Browse latest View live


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