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

Control CPU and Memory Resources by databases

$
0
0

SQL Server 2008 R2, 2012, 2014

Windows OS: Windows 2008 R2, Windows 2012

Hello, 

We have a need to control CPU and Memory by databases used. We are looking into Resource Governor. Another option is to install multiple instances and control Memory through Max/Min Memory and CPU through affinity mask. I was wondering if there are any other options or 3rd party tools that can help accomplish this need.

Thank you.

-Jeelani


Excel multi connection

$
0
0

Hi guys, very often I connect excel file with SQL (table or views). Now I was wondering if is possible to have a multi connection by sheet. That means, sheet 1 with table A, sheet 2 with table B, sheet 3 with table C etc. ? Is it possible?

Thanks

Linked servers: from sql2k12 to sql2k8 not possible?

$
0
0

Hi, I want to establish one remoting connection from my SQL Server 2012 to my 2008 server; both SQL version are in the same standalone machine (my laptop)

Let me know where am I failing 'cause remote login and local login are exactly the same

1)Network error does make any sense 'cause both servers are in the same core.

2)Login time out? It's stupid as well

3)Both servers Allow Remote Connections enable.

OLE DB provider "SQLNCLI11" for linked server "xxxxxxxxxxxx" returned message "Login timeout expired".

OLE DB provider "SQLNCLI11" for linked server "xxxxxxxxxxxx" returned message "A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.". (Microsoft SQL Server, Error: 2)


Compare database

$
0
0
I have 2 database, the first one act as development and the second one as test.

Would like to compare two databases and see the difference? is there any script that I can use to do this or a native tool with SQL Server?

Please help

Compare database scripts

$
0
0
Hi all,

My requirement is to move the database objects changes done in Testing DB to the Production DB (only the structual changes, not the data).

What is the best way to achieve it?

How to setup SQL Linked Server to connect to IBM DB2 using ODBC instead OLEDB?

$
0
0

I heard MS OLEDB Provider for DB2 will go away because Microsoft wants to use ODBC instead OLEDB connection for all applications. How can we connect to IBM DB2 ODBC driver from SQL Linked Server? Or is there any other way to connect to DB2? Currently we have SQL Server Linked Server setup to DB2 using MS OLEDB provider for DB2, and looks like this is only way to setup to connect to DB2... I am not sure how to convert it to use other connection. Please help.

thanks,

Heidi

ACTIVITY MONITOR TIMED OUT

$
0
0

Hello everyone,

Can anyone help me on this issue!

I tried to look into activity monitor getting the following error message, kindly help me how to troubleshoot on this!

Thanks,

V


DBA

Error: The connection's current state is closed

$
0
0

Hello -

I have an application that fails to upgrade due to the following error:

Failed to run SQLscript:  ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.

I've checked activity monitor and don't see anything out of the ordinary.   I am not sure where else in SSMS I can check or whether this is something on the application side?    Anyone run into this error before?  What steps did you take to resolve it?

thanks


Linked server error from a SQL Server 2014 instance to a SQL Server 2008 R2 instance

$
0
0

Hi,

I need to connect to a SQL Server 2008 R2 (with SP2) instance from a SQL Server 2014 instance.

So I've tried to create a native linked server, but I've this error message:

I've tried also to use the OLE DB provider for SQL Server obtaining an analogue result.

I can create rightly a such linked server inside a SQL Server 2012.

Does it exist a compatibility issue between 2014 and 2008 R2 versions about the linked servers?

Any helps to me, please? Thanks

Why Table compression is not defined by default?

$
0
0

hi,

I am testing different tables in my development db and all of them could benefit if apply DATA COMPRESSION

So I am just wondering why SQL by default don't establish compression?¿

Varying performance on a recursive query/view/CTE SQL-server 2008 R2

$
0
0

I ask for help on the next problem.

We're using a view with a recursive select statement in it (see below). On a specific server (server A) the performance of this view is varying a lot. Respons times differ between 100 ms and 30 seconds or even more. We've tested the same view on a backup of the database on an other server (server B) which results in a stable and good performance. A backup of the database installed on server A without any other interactions results again in varying performance. We compared the OS and database settings of server A and server B. There are no differences. 

We need extra input to solve this problem. So please help!

Regards

Ad

create view [dbo].[vwMarketSegmentsAll] as



WITH MarketSegmentsAll (MSID,MSVersion, MSName, MarketSegmentFK, SegmentCategoryFK, RegionFK, CountryCode, CountryFK, GlobalSegmentFK, MSLevel, MSCode, FirstActiveYear, LastActiveYear, Label, RootMarketSegmentFK, CropSegmentFK, CropFK) AS
(
-- Anchor member definition
SELECT ms.ID, ms.Version, ms.Name, ms.MarketSegmentFK, ms.SegmentCategoryFK, ms.RegionFK, r.CountryCode, r.ID as CountryFK, ms.GlobalSegmentFK, 1, MSCode = CAST(ms.GlobalSegmentFK as nvarchar(50)), ms.FirstActiveYear, ms.LastActiveYear,gs.Label, ms.ID, gs.CropSegmentFK,gs.CropFK
FROM MarketSegment  AS ms
join Region r on r.id = ms.RegionFK
join  GlobalSegment as gs on gs.id = ms.GlobalSegmentFK
where not ms.GlobalSegmentFK is null
UNION ALL
-- Recursive member definition
SELECT ms.ID, ms.Version, ms.Name, ms.MarketSegmentFK, ms.SegmentCategoryFK, ms.RegionFK, msc.CountryCode, msc.CountryFK, msc.GlobalSegmentFK, msc.MSLevel + 1, CAST(MSCode + case when ms.SegmentCategoryFK is null then '' else '-' + CAST(ms.SegmentCategoryFK as nvarchar(3)) end as nvarchar(50)), ms.FirstActiveYear, ms.LastActiveYear, msc.Label,msc.RootMarketSegmentFK, msc.CropSegmentFK, msc.CropFK
FROM MarketSegment  AS ms 
JOIN MarketSegmentsAll  AS msc ON msc.MSID = ms.MarketSegmentFK
where ms.GlobalSegmentFK is null
)
-- Statement that executes the CTE
select msA.MSLevel,
msA.MSVersion, 
msA.MSCode,
msA.MSName,
msA.MSID, 
msA.MarketSegmentFK, 
msA.SegmentCategoryFK, 
msA.GlobalSegmentFK, 
msA.RegionFK, 
msA.CountryCode,
msA.CountryFK,
msA.FirstActiveYear,
msA.LastActiveYear,
msA.Label,
RootMarketSegmentFK =
           CASE
             WHEN msA.MSLevel > 1 THEN msA.RootMarketSegmentFK
             ELSE null
           END,
msa.CropSegmentFK,
msa.CropFK

FROM MarketSegmentsAll msA



GO

Create job in sql server agent using view

$
0
0

Can I populate data to table by executing View in sql server agent using weekly job or is it only possible using stored procedure?

I tried and it gave me error as below:

INSERT INTO Table

SELECT * FROM View

Error:

The OLE DB provider "SQLNCLI10" for linked server "sql10" reported a change in schema version between compile time ("182244063332028") and run time ("182274129276679") for table ""ng"."dbo"."styrstudentyr"".


Index maintenance for a large number of databases

$
0
0

Hi All.

I am just thinking of a workable solution for a SQL instance with a large number of databases, over 4,000 databases with varying sizes.

At the moment, the code uses the Ola hallagren scripts, and it will reindex one database at a time in a serial manner, the script had to be stopped after it ran for the first time for almost 48 hours.

Just thinking, what kind of strategy can one use going forward, since it is not a process that can be easily multi threaded etc.

Thanks in advance.

Preventing duplicate/similar indexes from being created

$
0
0

Hi all,

I have an existing situation of many databases with a lot of doubled/duplicated/similarly indexes, i know how to find & drop them but the main issue is to prevent them to be created after my deep cleanup, how is this possible in MSSQL if any ?

I am using MSSQL 2008/2012/2014 and lately touching a litle bit the 2016 preview...

Thanks a lot !

Victor S.

DBA


בברכה, ויקטור שחר DBA

Why TempDB consumes so much db buffer

$
0
0
1.
DECLARE @total_buffer INT;
SELECT @total_buffer = cntr_value
FROM sys.dm_os_performance_counters
WHERE RTRIM([object_name]) LIKE '%Buffer Manager'
AND counter_name = 'Database Pages';
;WITH src AS
(
SELECT
database_id, db_buffer_pages = COUNT_BIG(*)
FROM sys.dm_os_buffer_descriptors
--WHERE database_id BETWEEN 5 AND 32766
GROUP BY database_id
)

SELECT
[db_name] = CASE [database_id] WHEN 32767
THEN 'Resource DB'
ELSE DB_NAME([database_id]) END,
db_buffer_pages,
db_buffer_MB = db_buffer_pages / 128,
db_buffer_percent = CONVERT(DECIMAL(6,3),
db_buffer_pages * 100.0 / @total_buffer)
FROM src
ORDER BY db_buffer_MB DESC;

Found tempdb consumed 20% of DB buffer

Result:

db_name  db_buffer_pages db_buffer_MB db_buffer_percent 
AutoTestDB  7020182 54845 50.686
tempdb 2656127 20750  19.177 

2.
SELECT
 @@servername as ServerName,
 getdate() as RecordTime,
 DB_NAME(ss.database_id) as DBName,
 su.Session_ID ,
 ss.Login_Name ,
 rq.Command ,
 su.Task_Alloc ,
 su.Task_Dealloc ,
--Find Offending Query Text:
 (SELECT SUBSTRING(text, rq.statement_start_offset/2 + 1,
 (CASE WHEN statement_end_offset = -1
 THEN LEN(CONVERT(nvarchar(max),text)) * 2
 ELSE statement_end_offset
 END - rq.statement_start_offset)/2)
 FROM sys.dm_exec_sql_text(sql_handle)) AS 'sqltext'
 FROM
 (SELECT su.session_id, su.request_id,
 SUM(su.internal_objects_alloc_page_count + su.user_objects_alloc_page_count)*8/1024 AS Task_Alloc,
 SUM(su.internal_objects_dealloc_page_count + su.user_objects_dealloc_page_count)*8/1024 AS Task_Dealloc
 FROM sys.dm_db_task_space_usage AS su
 GROUP BY session_id, request_id) AS su,
 sys.dm_exec_sessions AS ss,
 sys.dm_exec_requests AS rq
 WHERE su.session_id = rq.session_id
 AND(su.request_id = rq.request_id)
 AND (ss.session_id = su.session_id)
 AND su.session_id > 50 --sessions 50 and below are system sessions and should not be killed
 AND su.session_id <> (SELECT @@SPID) --Eliminates current user session from results
 and su.task_alloc >= 0
 ORDER BY su.task_alloc DESC --The largest "Task Allocation/Deallocation" is probably the query that is causing the db growth

Result: (all 0)

DBName Session_ID  Login_Name Command Task_Alloc Task_Dealloc
master 57 sa HADR_AR_MGR_NOTIFICATION_WORKER  0 0
master 62 sa TASK MANAGER 0 0
master 63 NT AUTHORITY\SYSTEM EXECUTE 0 0
master 66 sa HADR_AR_MGR_NOTIFICATION_WORKER  0 0
master 77 sa HADR_AR_MGR_NOTIFICATION_WORKER  0 0
master 80 sa HADR_AR_MGR_NOTIFICATION_WORKER 0 0
master  90 sa HADR_AR_MGR_NOTIFICATION_WORKER 0 0
master 101 sa BRKR EVENT HNDLR  0 0
AutoTestDB_UserTests 113 AutoTestDB SELECT 0 0
master 172 sa BRKR TASK 0 0
master 540 sa BRKR TASK 0 0
master 541 sa BRKR TASK 0 0
master 577 sa XE TIMER 0 0
master 664 sa UNKNOWN TOKEN  0 0
master 1300 sa BRKR TASK 0 0
master 1352 sa UNKNOWN TOKEN  0 0
master 1530 sa UNKNOWN TOKEN 0 0
master 1562 CO\ALZ   SELECT 0 0
master 1930 sa UNKNOWN TOKEN 0 0
master 1972 sa UNKNOWN TOKEN  0 0
master 2048 sa UNKNOWN TOKEN 0 0
master 2087 sa UNKNOWN TOKEN 0 0
master 2111 sa UNKNOWN TOKEN 0 0
master 2122 sa UNKNOWN TOKEN 0 0
master 2158 sa TASK MANAGER 0 0
AutoTesterDB_UserTests  2174 AutoTestDB UPDATE 0 0

No sessions are consuming temodb
3.
TempDB
FileSize               FreeSpace
(DB)15360.00 MB      15237.56 MB (99%)
(LOG)739.50 MB          484.80 MB (65%)

4.
use tempdb
SELECT SUM(unallocated_extent_page_count) AS [free pages],
(SUM(unallocated_extent_page_count)*1.0/128) AS [free space in MB]
FROM sys.dm_db_file_space_usage;
SELECT
(CASE WHEN ([is_modified] = 1) THEN N'Dirty' ELSE N'Clean' END) AS N'Page State',
(CASE WHEN ([database_id] = 32767) THEN N'Resource Database' ELSE DB_NAME ([database_id]) END) AS N'Database Name',
COUNT (*) AS N'Page Count'
FROM sys.dm_os_buffer_descriptors
GROUP BY [database_id], [is_modified]
ORDER BY [database_id], [is_modified];
GO
I ran an checkpoint against TempDB, so the dirty pages are small numbers, but Clean ones are still a lot.

Result:

Page State  Database Name Page Count
Clean master 245
Dirty  master 6
Clean tempdb 2647220
Dirty tempdb 10624


My question is why tempdb consumes such big amount of memory? and even no session is consuming tempdb?

Thanks,
Albert


Very tired of Queries Running Fast and then Slow due to sp_recompile - Want Stability over Performance

$
0
0

Hi,

We have a large SAP system on SQL 2014 SP1-CU3.  About twice a month, we have some query that used to be fast, all of a sudden start running slowly.  We know it is because statistics were auto-updated at 9:30am on a Wednesday during peak hours, and the SQL statement cache was cleared, and the next plan generated was less-than-optimal.  We are notified when our help desk lights up, and then we know the drill.  We fix it temporarily by deleting that statement out of the cache and usually the next version of the plan works just fine.  We fix it permanently by identifying the line of code and having our programmers either add a hint or force a re-compile each time.    The problem is, there is a never ending stream of such queries. We have been at this for years, and it still this happens 1-2 times per month.  Very often, we are modifying SAP's programs which isn't recommended by SAP.

If we are willing to sacrifice, say, up to 20% of overall performance, can we revert back to the old days of SQL 2000 where a plan gets generated each time? Any other ideas of what we can do in favor ofstability, even if we sacrifice some performance. I am primarily an SAP Basis administrator, and a part-time SQL administrator.

We would even be ok if the auto statistics occurred overnight or on a weekend, but it is killing us that it happens randomly at any time during the work day.

Warm Regards, Jordan McHale


Query Store at Database properties level (Sql2k16 CTP 3)

$
0
0

hi there,

What is it for?

https://gyazo.com/71e571b24b6360b5f19b2d1852af99fd

Cannot insert duplicate key row in object 'sys.syscommittab' with unique index 'si_xdes_id'

$
0
0

Hi All,

I have change tracking enabled on a database and the backups for this database are now failing with below error.

"Cannot insert duplicate key row in object 'sys.syscommittab' with unique index 'si_xdes_id'. The duplicate key value is (11969387191). [SQLSTATE 23000] (Error 2601)  Failed to flush the commit table to disk in dbid 6 due to error 2601. Check the errorlog for more information. [SQLSTATE 42000] (Error 3999)  BACKUP DATABASE is terminating abnormally. [SQLSTATE 42000] (Error 3013)  The statement has been terminated. [SQLSTATE 01000] (Error 3621).  NOTE: The step was retried the requested number of times (3) without succeeding.  The step failed."

The I found the fix suggested by microsoft under KB 

https://support.microsoft.com/en-us/kb/3083381

But when I follow the process I am getting error for openrowset 

Msg 102, Level 15, State 36, Line 2
Incorrect syntax near 'TABLE'.

Ih this part of script

insert into dbChangeTrackingMetadata.dbo.t_SYSCOMMITTABLE
SELECT commit_ts, xdes_id, commit_lbn, commit_csn, commit_time
FROM OpenRowset (table SYSCOMMITTABLE, db_id (), 0, 0)

Please help. thank you.


Thanks & Regards,
Manjunath C Bhat,
http://manjunathcbhat.blogspot.com
http://manjunathcbhat.wordpress.com

DATEADD(day,1,GetDate()) from database table

$
0
0

 Hi,

i have a table(name PaymentTable) with a column named 'ValueExpression' that contain value like 'DATEADD(day,1,ReceiveDate)'  and another column ReceiveDate.i want to execute statment like 'Select ValueExpression from PaymentTable'.

it throw error like the following when i try to execute

Msg 241, Level 16, State 1, Line 1
Conversion failed when converting date and/or time from character string.

Please let me know how to execute statement like this.thanks

sabbir


Log shipping error

$
0
0

Hi,

Yesterday my secondary database server rebooted unexpectedly, it was down for around 4 hours. when the server came back  log shipping of one of the database was broken. I have check the transaction log backup files and all files are available on secondary server and .tuf file is also available in the same folder (mydatabase_20160316133026.tuf) but its name is different from the one which is showing in error message below which i am getting in restore job of that database:

*** Error: Could not apply log backup file 'N:\log shipping\mydatabase\mydatabase_20160316134016.trn' to secondary database 'mydatabase'.(Microsoft.SqlServer.Management.LogShipping) ***
*** Error: During startup of warm standby database 'siteshare3appindus' (database ID 6), its standby file ('N:\log shipping\mydatabase\mydatabase_20160316134025.tuf') was inaccessible to the RESTORE statement. The operating system error was '2(The system cannot find the file specified.)'. Diagnose the operating system error, correct the problem, and retry startup.

could someone please let me know why sql server is looking for a different .tuf file.

Viewing all 15889 articles
Browse latest View live


Latest Images

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