Quantcast
Channel: SQL Server Database Engine forum
Viewing all 12963 articles
Browse latest View live

What does it mean when the usecounts of Parse Tree for a view is incrementing when a select query is issued against the view?

$
0
0

I'm using SQL Server 2008 R2 (10.50.4033) and I'm troubleshooting an issue that a select query against a specific view is taking more than 30 seconds consistently.   The issue just starts happening this week and there is no mass changes in data.  

The problem only occur if the query is issued from an IIS application but not from SSMS.  One thing I noticed is that sys.dm_exec_cached_plans is returning 2 Parse Tree rows for the view -  one created when the select query is issued 1st time from the IIS application and another one created when the same select query is issued 1st time from SSMS.   The usecounts of the Parse Tree row for the view (the IIS one) is increasing whenever the select query is issued.  The usecounts of the Parse Tree row for the view (the SSMS one) does not increase when the select query is issued again. 

There seems to be a correlation between the slowness of the query and the increasing of the usecounts of the Parse Tree row for the view.  

I don't know why there is 2 Parse Tree rows for the view.  There is also 2 Compiled Plan rows for the select query.  

What does the Parse Tree row mean especially the usecounts column?


index internals

$
0
0

Hi guys,

It is strange I never saw many information regarding this, maybe it's just stupid, but... Lets say I execute and rebuild all the indexes of 5 of my tables...

Will it be done in paralel? or is sql server rebuilding one index at a time... 

I mean, is at any point sql server capable of rebuildling 2 indexes (on different tables), at the same time??

Thanks! I checked everywhere and never found such answer!


checkdb running constatly

$
0
0

I am running SQL Server 2005 SP1 (9.0.2047).  There are about 55 databases on the server.  I noticed recently in the SQL Server Logs that CHECKDB was running almost constantly all day, against all of the databases.  I run DBCC CHECKDB in a batch job daily at 1:00 A.M., but can't explain why it is running throughout the day.  Needless to say, this is effecting database performance.  I have looked everywhere I know, and see nothing that leads me to why this is occuring.  What could be causing this to happen?

 

Thanks,

Terry

ANSI_WARNINGS is always set on new connections, despite the defaults

$
0
0

Hi, we need ANSI_WARNINGS off in order to truncate string columns.

The problem is that the ANSI_WARNINGS is always set on new connections. I checked that it is disabled in sys.configurations "user options" (value is 0). I double checked in SSMS DB properties and server connection properties.

Every time we create a new connection (even restarting SSMS and/or sql server) the ANSI_WARNING is ON again. We checked by running SELECT 8&@@OPTION and DBCC USEROPTIONS

-- This works, but I can't do it on every connection!

SET ANSI_WARNINGS OFF

Sql Server info:

Enterprise Edition 64-Bit

Product Version 11.0.5058.0 SP2

Using multiple lines of query in sqlcmd using -q switch

$
0
0

Hello

I am trying to use sqlcmd to run a set of sql statements. If I use -i switch and input a file with sql statements, it is working fine, but I am trying to use the sql statements using -q to avoid the creation of the input file. But I am not having luck with -q, can someone let me know if putting multiple lines of code is possible in -q switch like below?

A simple restore command like below. If I use the whole restore command in single line it works fine like below:

sqlcmd -E -S servername -d master -Q "restore database bestst_test from disk='E:\Backup\test\bestst\bestst_20101222.bak' with move 'BESMgmt415_data' to 'E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\bestst_test.mdf',move 'BESMgmt415_log' to 'E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\bestst_test_log.ldf'"

but if I split the restore command into 3 lines like below, it fails, can someone let me know how to use the multiple line feature in sqlcmd -q switch?

sqlcmd -E -S servername -d master -Q "restore database bestst_test from disk='E:\Backup\test\bestst\bestst_20101222.bak'
with move 'BESMgmt415_data' to 'E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\bestst_test.mdf',
move 'BESMgmt415_log' to 'E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\bestst_test_log.ldf'
"

Switch partition fails with Clustered Columnstore Index

$
0
0

hi ,

I am trying to switch partition between un-partitioned table table_src and partitioned table table_trg. Both the table tables have Clustered Columnstore Index on these. Does this work? 

ALTER TABLE [dbo].[table_src] SWITCH  TO [dbo].[table_trg] PARTITION 2; 

The error seems to mislead, the partition 2 on target table is empty...

I am using Microsoft SQL Server 2014 - 12.0.2000.8 (X64)

Msg 4982, Level 16, State 1, Line 65

ALTER TABLE SWITCH statement failed. Check constraints of source table 'table_src' allow values that are not allowed by range defined by partition 2 on target table 'table_trg'.


Suman

Migrating to new server subscriptions are missing

$
0
0

Hello,

I have an instance of SQL Server 2008R2 running on Windows Server 2008.  It is setup to be a reporting server.  There are many subscriptions that are scheduled and run on this server.  We are wanting to move to Windows Server 2012 and SQL Server 2012.  So, we have built out a new VM and I have exported from the current server the ReportServer and ReportServerTempDB and have imported them to the new server.  I have resolved the one Orphaned user that happened and went to look for the subscriptions so that I could disable them so they wouldn't run.  I could not find any.

select * from msdb.dbo.sysjobs where enabled = 1 and category_id = 100.

no rows...

I had read from other posts to let it sit for a few days and they will appear.  I have waited 2 weeks.

So, what am I missing?  I would prefer to do a clean install and migrate the data over rather than upgrading the OS and SQL.

Thanks



MS SQL server 2008 - Bulk copy from XML to DB table throws bcp_init error

$
0
0

I have MS SQL server 2008 installed ,

Windows version - Windows 7 Professional with SP1

Doing a bulk copy process using the SQL library function bcp_init function in c++ throws xml error and its not inserting the data into the tables.

Error received ,

XML Datatransfer error: XML data or another error occurred while reading file 'd:\temp\scripts\dbtoolscripts\table_data.xml':

But this works in others machines with the same windows version and SQL version.



Communication Link Failure in SELECT statement | From Middleware Application to SQL Server 2008/R2

$
0
0

Hi

We are connecting to an SQL Server 2008/R2 on a windows 7 machine from a middle ware message broker application on RHEL. We are using FreeTDS 7.0 to establish this connection.

We have seperate Program modules connecting to the same database and same table in SQL. Sometimes , we start getting a "Communication Link Failure" error in the SELECT statement. In each program module , we are connecting to the databse and then doing a SELECT , the connection statement is executing successfully , and the SELECt throws this exception.

In odbc log file , we are getting the below entries : 

Please let know in case any other information is required.

We are trying to find out the rrot cause of this error.

Thanks in advance for the help

[ODBC][1197][SQLAllocHandle.c][345]
                Entry:
                        Handle Type = 2
                        Input Handle = 0x8c21a18
[ODBC][1197][SQLAllocHandle.c][463]
                Exit:[SQL_SUCCESS]
                        Output Handle = 0x137084e0
[ODBC][1197][SQLSetConnectOption.c][262]
                Entry:
                        Connection = 0x137084e0
                        Option = SQL_ATTR_QUIET_MODE
                        Value = 0
[ODBC][1197][SQLSetConnectOption.c][405]
                Exit:[SQL_SUCCESS]
[ODBC][1197][SQLConnect.c][3549]
                Entry:
                        Connection = 0x137084e0
                        Server Name = [XIBSQLDSNR2][length = 11 (SQL_NTS)]
                        User Name = [user_r2][length = 7 (SQL_NTS)]
                        Authentication = [*************][length = 13 (SQL_NTS)]
                UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'

[ODBC][1197][SQLConnect.c][4123]
                Exit:[SQL_SUCCESS]
[ODBC][1197][SQLSetConnectOption.c][262]
                Entry:
                        Connection = 0x137084e0
                        Option = SQL_ATTR_AUTOCOMMIT
                        Value = 0
[ODBC][1197][SQLSetConnectOption.c][525]
                Exit:[SQL_SUCCESS]
[ODBC][1197][SQLGetInfo.c][214]
                Entry:
                        Connection = 0x137084e0
                        Info Type = SQL_CURSOR_COMMIT_BEHAVIOR (23)
                        Info Value = 0x136d56c4
                        Buffer Length = 2
                        StrLen = (nil)
[ODBC][1197][SQLGetInfo.c][528]
                Exit:[SQL_SUCCESS]
[ODBC][1197][SQLGetInfo.c][214]
                Entry:
                        Connection = 0x137084e0
                        Info Type = SQL_CURSOR_ROLLBACK_BEHAVIOR (24)
                        Info Value = 0x136d56c6
                        Buffer Length = 2
                        StrLen = (nil)
[ODBC][1197][SQLGetInfo.c][528]
                Exit:[SQL_SUCCESS]
[ODBC][1197][SQLAllocHandle.c][510]
                Entry:
                        Handle Type = 3
                        Input Handle = 0x8c21fa8
[ODBC][1197][SQLAllocHandle.c][872]
                Exit:[SQL_SUCCESS]
                        Output Handle = 0x1371a130
[ODBC][1197][SQLPrepare.c][189]
                Entry:
                        Statement = 0x1371a130
                        SQL = [SELECT DISTINCT MSTID FROM MESSUTIL,RP_PIVSRTCLT01 WHERE MSTDATER IS NULL AND MSTETAT IS NULL AND MSTNOMTABLE LIKE ? AND MSTID =...][length = 174 (SQL_NTS)] [ODBC][1197][SQLPrepare.c][364]
                Exit:[SQL_SUCCESS]
[ODBC][1197][SQLBindParameter.c][193]
                Entry:
                        Statement = 0x1371a130
                        Param Number = 1
                        Param Type = 1
                        C Type = 1 SQL_C_CHAR
                        SQL Type = 1 SQL_CHAR
                        Col Def = 14
                        Scale = 0
                        Rgb Value = 0xf336c910
                        Value Max = 14
                        StrLen Or Ind = 0x8c54088
[ODBC][1197][SQLBindParameter.c][339]
                Exit:[SQL_SUCCESS]
[ODBC][1197][SQLBindParameter.c][193]
                Entry:
                        Statement = 0x1371a130
                        Param Number = 2
                        Param Type = 1
                        C Type = 1 SQL_C_CHAR
                        SQL Type = 1 SQL_CHAR
                        Col Def = 8
                        Scale = 0
                        Rgb Value = 0xf390d290
                        Value Max = 8
                        StrLen Or Ind = 0x8c5409c
[ODBC][1197][SQLBindParameter.c][339]
                Exit:[SQL_SUCCESS]
[ODBC][1197][SQLExecute.c][183]
                Entry:
                        Statement = 0x1371a130
[ODBC][1197][SQLExecute.c][344]
                Exit:[SQL_ERROR]
                DIAG [08S01] [FreeTDS][SQL Server]Communication link failure

[ODBC][1197][SQLError.c][342]
                Entry:
                        Statement = 0x1371a130
                        SQLState = 0xffa5bee0
                        Native = 0xffa5bed8
                        Message Text = 0x8c1f7b8
                        Buffer Length = 511
                        Text Len Ptr = 0xffa5bede
[ODBC][1197][SQLError.c][379]
                Exit:[SQL_SUCCESS]
                        SQLState = 08S01
                        Native = 0xffa5bed8 -> 0
                        Message Text = [[unixODBC][FreeTDS][SQL Server]Communication link failure] [ODBC][1197][SQLFreeStmt.c][140]
                Entry:
                        Statement = 0x1371a130
                        Option = 1
[ODBC][1197][SQLFreeHandle.c][365]
                Entry:
                        Handle Type = 3
                        Input Handle = 0x1371a130
[ODBC][1197][SQLFreeHandle.c][462]
                Exit:[SQL_SUCCESS]

Impact of creating a non-clusterd index on a huge transaction table?

$
0
0

Hello Everyone,

We have a transaction table containing 10 million records and everyday a million records will be inserted. We don’t have any clustered index on this table as this is a transaction table (more than 10 columns to uniquely identify a row). We do have some SPs which in turn some reports getting generated using this table. In order to improve the performance of an SP, we created a non-clustered index on this table and we found a huge performance gain. Here comes my question - will this (creation of non-clustered index) impacts my table data load performance or other reports generation?Any suggestions will be appreciated.

Many Thanks!


Rajasekhar.

Database In Recovery with No Error Messages

$
0
0

We created a new domain win account that was local admin and then added it as sysadmin.  I then added this new account, which was in a different domain by the way, to the sql services and started them up.

The oddest thing happened and this is SQL Server 2012 by the way:

SQL Server started up but one database was in recovery.  It just sat there and sat there and sat there in recovery.  No error message that it could not open a drive.  No nothing.  Furthermore, it never gave the percentages of the database recovering.

I restarted the services again and the same thing.  That database would not come up.

Again, no explanation in the event logs, the sql server error logs and trace files.

So after waiting awhile with absolutely nothing happening, I then switched it back to the original login.  Boom! The instance came up completely cleanly including the database that would not come up previously.

Any idea what would cause the database to hang in recovery with absolutely no error messages or expalantion why?



SQL SERVER PHYSICAL MEMORY USAGE HIGH

$
0
0

HI Teams,

i am  going threw one of my production high physical memory usage in SQL Server. It always around 90%.When i reboot the server, it will initially good but end of the day it will around 95 to 98% physical memory usage.

please give the valid solutions..,

Regards,

DBA 

why statistics profile, statistics xml, statistics io, statistics time can't reuse the execution context.

$
0
0

Based on the article below, "Not reused. A fresh execution context is  generated, used, and not cached" when setting statistics profile, statistics xml, statistics io, statistics time  can't reuse the execution context.

My question is why cannot reused?

https://technet.microsoft.com/en-us/library/ee343986(v=sql.100).aspx



Please click the Mark as Answer button if a post solves your problem!

Where is the physical device name of a backup stored in SQL?

$
0
0

Hi, 

If I look at the backup/restore report in SQL2008R2 I can see the backup file a database was backed up to and/or a device id if it was taken by VM tools.  Can anyone tell me where this physical device name is stored in SQL? 

Thanks 

e.g. 

T-SQL USE : Reference Database in Different Server

$
0
0

I'm fairly new to SQL so perhaps I am missing something but what I am trying to do is have a script I wrote select a certain database depending on @@ServerName.  This script will be run by the testing department and needs to work regardless of connection.

IF @@SERVERNAME IN ('X')
    USE DataBaseA
ELSE IF @@SERVERNAME IN ('Y')
    USE DataBaseB
ELSE
    USE DataBaseC

What happens is DataBaseB does not exist on server X so I receive the error of "no database exists".  As well, DataBaseC lacks certain columns in tables that DataBaseA has (DataBaseC will later get these columns but are not there right now).  Is there a different way to force the code to properly use the right database and not throw errors?


SQL Server 2014 Clustered Column Store Rebuild Conditions

$
0
0

Hi

I would like to enquire when I should rebuild Clustered Column Indexes. When is the index seen as fragmented ?

Thanks,

differential backup and tlog backup

$
0
0

Hi,

What is the advantage of doing a differential backup along with transactional log backup? For instance, if I'm planning on doing a weekly full backup and daily transactional log backups what does doing an differential backup get me? Does it make restoring faster? Is it better to have that differential in case one of the transactional log backups are corrupt? 

Please advise.

Thanks,

Phil

Agent jobs stuck everyday and need to restart the SQL services to fix

$
0
0

Hi Everyone,

Few jobs in our servers stuck sometimes and stopping the job, killing the sessions are not helping at all. Only thing we can do is restarting the SQL services. Even restarting the SQL agent would not fix the issue. Is there any work around other than mentioned tasks.

As everyone know restarting the SQL services is not possible every time for the job. I was observing the session statuses, killed the dependent sessions but job status still showing as executed in the job history and I cannot even stop it.

Most of these jobs are getting data from Oracle using open query.

Thanks,

Swapna Joseph.


Swapna


Problem with auto-increment of Identity column value after rollback

$
0
0
Hi,

I'm currently debugging a database app, with the client running in VB on the 2008 framework, and the database running in MSSQL Server 2005
At the moment, I'm writing the Save routine, for the final stage of a single user interaction, and I've noticed something odd.
The first table I'm adding a record to has an Identity column, which is being used to generate the company's ID number for the record, and which needs to be done first so that I can associate all the other components of the record with that ID number.

The Insert on that table goes fine, but a later stage is currently failing, meaning that the Insert is rolled back.
What I'm then seeing, though, is that the Identity is still being incremented, and so if I have a failed Save for Identity 15, which then needs rolling back, the next record will go in at Identity 16, leaving a gap in the ID numbers, which I can't really have.

I've verified that this happens even with an explicit call to transaction.Rollback() for my transaction chain; even if I call Rollback() directly after a successful insert to this table, without any errors, the record gets deleted, but the Identity column's value is still incremented.


What's the solution, here? I can't really have the application roll the Identity back by itself on a bad save, that seems too risky to me, but no alternative springs to mind. Presumably I'm missing something obvious, but it seems very strange to me that the Identity column isn't being rolled back along with the rest of the transaction.

Can anyone advise me as to how best to get the behaviour I want, i.e. that no matter the circumstances of exit or error, I have an unbroken, sequential series of ID numbers to use as references?

Cheers,

KFrost

Remote connection SQL

$
0
0

Hallo 

Hope all are well.

I got problem connecting from remote computer to SQL server, Connecting via SQL Manangement studio on local machine where server is installed no problem.

If I disable the Windows firewall on the server I can create remote connection. But when disabling it doesn' work.

I enabled the following inbound rules on the server still no connection, any idea's?

Ports Created for inbound rules:

1433,1444,2383,1434,2382,4022,135

Still only way to connect to server is to disable the firewall.

SQL Server I made sure the TCP port is enabled and set to any.

Any idea's or suggestions will be much appreciated.

Best Regards,

Jacques.


labjac

Viewing all 12963 articles
Browse latest View live


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