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

Cannot upgrade database

$
0
0

Hi,

I get an error (... version (539) is not supported by this version of sql server...) when attaching an 539 version (mdf file) with SQL Server 2012 (11.0.3000) .

It's clear that this mdf file version is not supported but, is there any way to open the file despite the versions problem?

Thanks in advance.

Regards.


How to avoid shared locks when validating foreign keys?

$
0
0

I have a table with a FK and I want to update a row in that table without being blocked by another transaction which is updating the parent row at the same time. Here is an example:

CREATE TABLE dbo.ParentTable
(
	PARENT_ID int NOT NULL,
	VALUE varchar(128) NULL,
	CONSTRAINT PK_ParentTable PRIMARY KEY (PARENT_ID)
)
GO

CREATE TABLE dbo.ChildTable
(
	CHILD_ID int NOT NULL,
	PARENT_ID INT NULL,
	VALUE varchar(128) NULL,
	CONSTRAINT PK_ChildTable PRIMARY KEY (CHILD_ID),
	CONSTRAINT FK_ChildTable__ParentTable FOREIGN KEY (PARENT_ID)
		REFERENCES dbo.ParentTable (PARENT_ID)
)
GO

INSERT INTO ParentTable(PARENT_ID, VALUE)
VALUES (1, 'Some value');
INSERT INTO ChildTable(CHILD_ID, PARENT_ID, VALUE)
VALUES (1, 1, 'Some value');
GO

Now I have 2 transactions running at the same time:

The first transaction:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

BEGIN TRAN UPDATE ParentTable SET VALUE = 'Test' WHERE PARENT_ID = 1;

The second transaction:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

BEGIN TRAN UPDATE ChildTable SET VALUE = 'Test', PARENT_ID = 1 WHERE CHILD_ID = 1;

If 'UPDATE ParentTable' statement runs a bit earlier, then 'UPDATE ChildTable' statement is blocked untill the first transaction is committed or rollbacked. It happens because SQL Server acquires shared locks when validating foreign keys, even if the transaction is using read uncommitted, read committed snapshot (read committed using row versioning) or snapshot isolation level. I cannot see why change in the ParentTable.VALUE should prevent me from updating ChildTable. Please note that ParentTable.PARENT_ID is not changed by the first transaction, which means that from FK's point of view whatevere is set to the ParentTable.VALUE is never a problem for referential integrity. So, such blocking behavior seems to me not logical. Furthermore, it contradicts to the MSDN:

Transactions running at the READ UNCOMMITTED level do not issue shared locks to prevent other transactions from modifying data read by the current transaction. READ UNCOMMITTED transactions are also not blocked by exclusive locks that would prevent the current transaction from reading rows that have been modified but not committed by other transactions. 

Does anybody know how to workaround the issue? In other words, are there any tricks to avoid shared locks when validating foreign keys? (Disabling FK is not an option.) Thank you.


Alexey

Error' OLE DB provider "SQLNCLI10" for linked server "SOURCE" was unable to begin a distributed transaction'

$
0
0

Hi,

We are getting below error wile run open query to execute the procedure.

example:- 

SELECT * FROM openquery ([PSNSQLN04],'SET FMTONLY OFF;exec [PSNSQLN04]. AltDataHub.dbo
.Report_Attendance_FullTimer_YUM 107,264593,1909,''2015-02-24'',''2015-02-24''')

error:- 

Msg 7357, Level 16, State 1, Line 4
Cannot process the object "SET FMTONLY OFF;exec [PSNSQLN04]. AltDataHub.dbo
.Report_Attendance_FullTimer_YUM 107,264593,1909,'2015-02-24','2015-02-24'". The OLE DB provider 
"SQLNCLI10" for linked server "PSNSQLN04" indicates that either the object has no columns or the current user 
does not have permissions on that object.

SQL detail:- 

Microsoft SQL Server 2008 R2 (RTM) - 10.50.1617.0 (X64) 
Apr 22 2011 19:23:43 
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)

I had tried with re-install MSDTC services and Local DTC Properties , security changes but getting the still same error.

Please help if some can help.

Thanks

Subhash

DBMIRROR_EVENTS_QUEUE wait Type but mirroring is not configured

$
0
0

Hello,

While checking the databases in Activity monitor, i wonder that a database is not configured for mirroring but still its showing DBMIRROR_EVENTS_QUEUE in wait_type.

I also Use DMV sys.dm_os_wait_stats, for Checking wait percentage, There more than 30% DBMIRROR_EVENTS_QUEUE is there and not even for single database mirroring is configure

Change due to migration

$
0
0
Hi,
We currently have DTS running on Sql Server 2005. Since we will soon migrate the existing DB to Sql server 2008 R2, can we still use DTS on SS 2008, or must we use SSIS instead?

Many Thanks & Best Regards, Hua Min

Renaming Sql Server 2008 r2 enterprise edition security roles

$
0
0

Hello All,

We got a requirement to rename existing  SQL SERVER 2008 R2 ENTERPRISE EDITION security roles.

We are unaware of the impact on the existing users with these roles.

Can anybody advise us if we rename the role name manually,

We have to restart the sql server services to reflect the role name change to the users with these roles?

Thanks In Advance 


sp_dropserver Hyper V Image

$
0
0

Hello. Since I do not post unless I have something useful to say, I was wondering if I missed a thread for how to image SQL Server 2012 with Hyper V. I am a sysadmin looking to setup an image of SQL server, use the sp_dropserver procedure to help.

Scenario specifics:

1 server

1 SQL Server, default instance

Any ideas or suggestions would be greatly appreciated and voted upon ;)

What's the difference between IPSec and SQL Encrypt Connection

$
0
0

Good afternoon,

I'm currently struggling to decide the best approach to take with regard to encrypting SQL connections.

I've been looking at Encrypting Connections to SQL Server using SSL and configuring through the SQL COnnection manager.

Our network admins are saying that we could get the same effect by using IPSec and simply encrypt ALL traffic on the network, not just connections to SQL.

Does anybody have any experience with this?  What is the difference between the two technologies?  What are the pros and cons to each?

Sorry for the vagueness and openness of this question.

Regards,

Andy


TIMEFROMPARTS is not a recognized function in 2008 r2 mssql

$
0
0

I have three fields - starttime, duration (in hours), and endtime in mssql 2008 r2. Starttime and duration are entered in a form by endusers and I attempted to define trigger to insert/update endtime (as 1 minute less than the starttime+duration) use TIMEFROMPARTS as below (just querying in Management studio) but failed!!!:

Select (DATEPART,Starttime),Duration, TIMEFROMPARTS(DATEPART(HOUR,starttime) + Duration -1,59,0,0,0) As EndTime from <tablename>

but it failed with the message:

Msg 195, Level 15, State 10, Line 1

'TIMEFROMPARTS' is not a recognized built-in function name.

where as this URL of msdn talks about this function:

https://msdn.microsoft.com/en-us/library/hh213398.aspx?f=255&MSPPError=-2147217396

---

Appreciate if there is a clear reason why the function doesn't work and there is a simple fix (simple means other than upgrading database..etc.) Otherwise, I will have to resort to convert to datetime from time (for starttime) , use DateAdd function to get the new datetime and then get timepart for end time!!!


rmrrdesai

It is actually getting weird..even DATEFROMPARTS did not work either. My attempt to:

DATEFROMPARTS(YEAR(StartDate),DATEPART(hour,starttime)+Duration01,59) As endtime failed as well!!!

Similar error message..'DATEFROMPARTS' is not a recognized buil-in function name.


Dynamic column support in Bulk Load

$
0
0

Hi,

Is there any solution for the following scenario in bulk insert. 

"The csv file which is going to get processed for a particular table will change its column order periodically , and sometimes some columns will be deleted and sometimes some new columns will be added . I need to map corresponding column value from csv to table when the  order changes or values deleted or new values added"

Hope you will get ?

~Selva

Is "lost update" possible in SQL Server?

$
0
0

hi all,

is "lost update" possible in SQL Server? if so, under what isolation level? i am just having difficulty understanding SQL Server would allow lost updates.

is there a way i can produce this issue?

please advise.


Ring Buffers and IndicatorsSystem = 3 meaning?

$
0
0

Im trying to add a step to a admin script that checks various sever and database-level metrics, including any evidence of low memory.  Using the ring buffers I see some results that include values for Process and some for System.

The article I was just reading as well as others never mention a meaning for a System value of 3

http://blogs.msdn.com/b/psssql/archive/2009/09/17/how-it-works-what-are-the-ring-buffer-resource-monitor-telling-me.aspx

I have seen mention for values of 1 , 2 and 4, but not 3

Anyone know what a value of 3 would indicate?

IDX_MEMPHYSICAL_HIGH = 1
IDX_MEMPHYSICAL_LOW = 2
IDX_MEMVIRTUALL_LOW = 4

On some of the results against one of my instances, Im getting a value of 3, others are either 2 or 0

EF6 Code First w/Migrations: Creating localdb Database In User-Defined Location...and User Login Failures

$
0
0

I am running into what I think are two related problems.

I want to create a localdb database for an ASP.NET project in a user-defined location. I do not want the database files put under C:\Users\Mark (for one thing, it's an SSD; for another, I'd never think to look there).

This turns out to be unbelievably, amazingly difficult to do. Which it shouldn't be. Note to MS: it's my computer, >>I<< decide where the files I create go, not you.

I can create databases using migrations and update-database. But they always show up under C:\Users\Mark. If I try to move them where I want them, and specify a full path location in the connection string, I get a "login failed for user Mark". Which is a ridiculously, amazingly unhelpful error message, and the cause of truly astounding amounts of frustration among developers (note to MS: please, someday, make it a priority to include useful error messages in your products).

One other thing: in the course of experimenting, I deleted the database files from an earlier test. That now seems to be keeping me from creating a new database with the same name, even under C:\Users\Mark. I get the same "login failed" message. But if I change the name of the connection string in appconfig to something new (e.g., Council2015 -> Council2015xyz), a database will be created under C:\Users\Mark when I run update-database. It's as if something somewhere is remembering the old databases and refusing to let me use the names over again. How do I clear that out?

It also seems like the >>name<< of the connection string is what's used to name the database, regardless of the connection string also specifying Initial Catalog or AttachDBFile. That doesn't appear to be documented anywhere, but then again, half the stuff MS releases these days isn't documented. So now that I think about it I wouldn't mind a link to a good discussion of just what goes into an EF6 code first connection string and how the parameters get used.

Here's the connection string I'm using in appconfig:

        <add name="Council2015" connectionString="Data Source=(LocalDb)\\v11.0;Integrated Security=True;AttachDbFilename=E:\\Programming\\Council2015\\Council2015\\App_Data\\Council2015.mdf;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient"/>

- Mark

search for 2 different words.

$
0
0

i have small requirement.
In our project we using the search term(for Example based on the word or term, we have give on search tad accordingly i have to search the result)

now my requirement got changed, i have to search based on the two terms
EX: john, barn............. here i have to search for "john"+"barn"
    ganesh,batta.............here i have to search for "ganesh"+"batta"
like this i have to search,

I am using full text search for searching in terms.. 

how can i implement this..

EX:

DECLARE @term nvarchar(1000) = 'raj,sundar' ,
 @personid INT = 0

 declare @one nvarchar(100)
 declare @two nvarchar(100)

Result is like below..

 print @one =-------> raj
 print @two --------> sundar

Auto update stats disabled for a user Database in Sql server

$
0
0

While trying to improve the performance of few queries, we found via execution plan that there were lot of Index/Clustered index seeks. Therefore:

First thing we did, was to check our Re-indexing and update stats job which runs weekly for this user DB ( Around 400 GB in size and is used 24*5). The job was running fine.

Later when we ran SP_Blitz, we came to know that auto-update-stats is disabled for this user DB. We expected this to be a possible cause and change it from false to TRUE(Auto update stats)

Also, per SP_blitz there are user-created statistics for this DB. When ran the query to check how many, we saw around 7K user stats out there.

So my question would be 1) setting the Auto update stats to TRUE would require a reboot or once changed i need to track the performance and 2) Should we consider dropping those user created stats or manually look into them one by one.

How should we proceed on this, please suggest, thanks!


SQLSERVER 2012 LOG SIZE INCREASE EXTENSIVELY

$
0
0

Hi Friends,

I want to inquire, as our sqlserver 2012 in full  recovery mode , I notices whenever we are executing rebuild indexes maintenancejob the logfile grown up extensively every time.  h

thank you.

regards,


asad

Shredding deadlock information from XML data

$
0
0

Hi All.

I have a SQL 2008 R2 isntance, and I am trying to have a system which alerts after a deadlock. The deadlock traceflags are already in place, but this writes to the SQL error log, the purpose of my plan is to alert right after a deadlock so I have decided the best way to do this is using Xevents.

At the moment I have the query below to extract the deadlock information. I would like to shred the XML and retrieve details and save onto a table such as table name, victim, spid, sql statements etc. Any help would be appreciated.

SELECT
       xed.value('@timestamp', 'datetime') as Creation_Date,
       xed.query('.') AS Extend_Event
FROM
(
       SELECT CAST([target_data] AS XML) AS Target_Data
       FROM sys.dm_xe_session_targets AS xt
       INNER JOIN sys.dm_xe_sessions AS xs
       ON xs.address = xt.event_session_address
       WHERE xs.name = N'system_health'
       AND xt.target_name = N'ring_buffer'

) AS XML_Data

The XML looks like this

<event name="xml_deadlock_report" package="sqlserver" id="123" version="1" timestamp="2015-02-18T16:24:30.726Z"><data name="xml_report"><type name="unicode_string" package="package0" /><value>&lt;deadlock&gt;&lt;victim-list&gt;&lt;victimProcess id="process5c1ddc8"/&gt;&lt;/victim-list&gt;&lt;process-list&gt;&lt;process id="process5c1ddc8" taskpriority="0" logused="220" waitresource="KEY: 2:7926335401066364928 (c20918c6e169)" waittime="3800" ownerId="19070357" transactionname="user_transaction" lasttranstarted="2015-02-18T16:24:36.943" XDES="0x1469d9530" lockMode="X" schedulerid="9" kpid="5536" status="suspended" spid="61" sbid="0" ecid="0" priority="0" trancount="2" lastbatchstarted="2015-02-18T16:24:50.497" lastbatchcompleted="2015-02-18T16:24:36.947" clientapp="Microsoft SQL Server Management Studio - Query" hostname="GBVA548376" hostpid="1208" loginname="INTL\A548376" isolationlevel="read committed (2)" xactid="19070357" currentdb="2" lockTimeout="4294967295" clientoption1="671090784" clientoption2="390200"&gt;&lt;executionStack&gt;&lt;frame procname="" line="1" stmtstart="30" sqlhandle="0x020000008407891bbd2cb7a0d4923843c79f4ce2254daada"&gt;&lt;/frame&gt;&lt;frame procname="" line="1" sqlhandle="0x02000000dcc60f0386a6487bf053a44870ed1152ebeb6613"&gt;&lt;/frame&gt;&lt;/executionStack&gt;&lt;inputbuf&gt;
INSERT dbo.Tbl2 (id, col) VALUES (111, 555)&lt;/inputbuf&gt;&lt;/process&gt;&lt;process id="process5c31048" taskpriority="0" logused="3548" waitresource="KEY: 2:7854277806987476992 (61a06abd401c)" waittime="11378" ownerId="19061287" transactionname="user_transaction" lasttranstarted="2015-02-18T16:23:24.980" XDES="0x8695463b0" lockMode="S" schedulerid="11" kpid="14736" status="suspended" spid="57" sbid="0" ecid="0" priority="0" trancount="3" lastbatchstarted="2015-02-18T16:24:42.903" lastbatchcompleted="2015-02-18T16:24:20.723" lastattention="2015-02-18T16:20:51.050" clientapp="Microsoft SQL Server Management Studio - Query" hostname="GBVA548376" hostpid="1208" loginname="INTL\A548376" isolationlevel="read committed (2)" xactid="19061287" currentdb="2" lockTimeout="4294967295" clientoption1="671090784" clientoption2="390200"&gt;&lt;executionStack&gt;&lt;frame procname="" line="2" stmtstart="30" sqlhandle="0x020000008407891bbd2cb7a0d4923843c79f4ce2254daada"&gt;&lt;/frame&gt;&lt;frame procname="" line="2" stmtstart="24" sqlhandle="0x020000008d2ab9030650ebc0eab587b94eebe42bfed9ea40"&gt;&lt;/frame&gt;&lt;/executionStack&gt;&lt;inputbuf&gt;
BEGIN TRAN
INSERT dbo.Tbl2 (id, col) VALUES (111, 2)   &lt;/inputbuf&gt;&lt;/process&gt;&lt;/process-list&gt;&lt;resource-list&gt;&lt;keylock hobtid="7926335401066364928" dbid="2" objectname="" indexname="" id="lock67f7d80" mode="X" associatedObjectId="7926335401066364928"&gt;&lt;owner-list&gt;&lt;owner id="process5c31048" mode="X"/&gt;&lt;/owner-list&gt;&lt;waiter-list&gt;&lt;waiter id="process5c1ddc8" mode="X" requestType="wait"/&gt;&lt;/waiter-list&gt;&lt;/keylock&gt;&lt;keylock hobtid="7854277806987476992" dbid="2" objectname="" indexname="" id="lock69b1100" mode="X" associatedObjectId="7854277806987476992"&gt;&lt;owner-list&gt;&lt;owner id="process5c1ddc8" mode="X"/&gt;&lt;/owner-list&gt;&lt;waiter-list&gt;&lt;waiter id="process5c31048" mode="S" requestType="wait"/&gt;&lt;/waiter-list&gt;&lt;/keylock&gt;&lt;/resource-list&gt;&lt;/deadlock&gt;</value><text /></data></event>

tempdb log file is full

$
0
0

Hi DBA's,

my tempdb log file is 500mb size , auto growth enabled and log file used max.

now I am unable to insert or update and it is allowing only read operations.

what to do in this situation ?

SQL 2012 database stuck in Recovery Pending status

$
0
0

Hey all.  Thanks in advance to anybody that can please help me.  I have a SQL cluster which ran out of disk the other day.  I threw plenty more disk at the SAN.  However, 1 of the databases came back with Recovery Pending and has been over 24 hours.  I have tried to backup the database with no success.  I don't have a clean backup from the day it occured so would have a good amount of work missing.

Running a dbcc check returns the following:

Msg 945, Level 14, State 2, Line 1
Database 'sqldb' cannot be opened due to inaccessible files or insufficient memory or disk space.  See the SQL Server errorlog for details.

I have not tried a dbcc check with REPAIR_ALLOW_DATA_LOSS as there seems to be a high risk of losing whatever was going on.  Does anybody have an idea of how I can get the db back online?

tempdb is full

$
0
0

Hi,

If tempdb is full, what might be the causes to full tempdb.

how can we solve the situations.

And any common issues facing on temp database by DBA.


thanks in advance...
Viewing all 6624 articles
Browse latest View live


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