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

SQL Server 2012 Management Studio: I cannot create a SQL Server Express LocalDB Database manually: Microsoft SQL Server, Error: 5105. Why?

$
0
0

Hi all,

I have SQL Server 2012 Express installed in my "Windows 7" PC that is part of Windows System in our Computer Network System. In the SQL Server 2012 Management Studio (SSMS 2012) of my SQL Server 2012 Express, I have created a SQL Server Express LocalDB (localdb)\v11.0 (SQL Server 11.0.2318 -CENAD\e1enxshc).

I tried to create a new database "BooksAuthorsLibrary" manually in my (localdb)\v11.0 (SQL Server 11.0.2318 - CENAD\e1enxshc) => I typed in "BooksAuthorsLibrary" in Database name, and then I clicked on the "OK" button.  I got the following error: Microsoft SQL Server Management Stiduo     Create failed for Database "BooksAuthorsLibrary".  (Microsoft SQLServer.Smo)   Additional information: A file activation error occurred. The phyical file name "BooksAuthorsLibrary.mdf" may be incorrect.  Diagnose and correct additional errors, and retry the operation. CREATE DATABASE failed.  Some file names listed  could not be created.  Checked related errors. (Microsoft SQL Server, Error: 5105).

Please kindly help, advise and respond.

Thanks,

Scott Chang

 


SQL Server 2012 identity jump to 1000...after restarting Sql server service.

$
0
0

with sql server 2012 where after restarting sql server service identity getting seeded 1000

ID is identity(1,1) , i have instered few rows.

ID     Name

========

1      jigs
2      jigs shah
3      jignesh

after sql server restart identity jump to 1000.

ID     Name

=========

1      jigs

2      jigs shah

3      jignesh

1003 jignesh shah

Adding a Provider for Oracle in SQL Server 2008

$
0
0

I have a feeling this is fairly straightforward, but for some reason am having a hard time finding something clear cut regarding my situation. I have SQL server 2008 developer installed on my machine with several linked servers going out to DB2, other SQL, etc, but am now trying to get out an Oracle database that is new to me. I need to have the Oracle driver available in my list of providers for linked servers, but it isn't there. I can connect using SQL plus and creating and ODBC, but unable to use the driver in SQL server where I really need it. Is there an installer that I need or something that I need to do to get it to show up there? Again, I think it is probably pretty straightforward, but just cant find it in all of my searching. Any help would be greatly appreciated.

Oh, the Oracle database is a bit older, 9.02 so I have those specific drivers installed on my machine.

Thanksin advance!

Dennis G

SQL consistency based I/O error, help needed

$
0
0

Hello everyone.

I'm new to database errors so I'm not really sure what I should do next. I'm using an accounting program running on SQL Server Express 2005 (9.0 SP3) on a Windows Server 2008R2. While working with a database the SQL Server gave out an error -2147467258, which makes no sense, yes. Associated with this error was a SQL consistency based i/o error. I tried running DBCC CHECKDB and it returned with a lot of errors:

Msg 8967, Level 16, State 216, Line 1
An internal error occurred in DBCC that prevented further processing. Contact Customer Support Services.
DBCC results for 'TK0110'.
Msg 8921, Level 16, State 1, Line 1
Check terminated. A failure was detected while collecting facts. Possibly tempdb out of space or a system table is inconsistent. Check previous errors.
Msg 8906, Level 16, State 1, Line 1
Page (1:3588) in database ID 133 is allocated in the SGAM (1:3) and PFS (1:1), but was not allocated in any IAM. PFS flags 'IAM_PG MIXED_EXT ALLOCATED   0_PCT_FULL'.
Msg 8909, Level 16, State 1, Line 1
Table error: Object ID 0, index ID -1, partition ID 0, alloc unit ID 0 (type Unknown), page ID (1:3588) contains an incorrect page ID in its page header. The PageId in the page header = (0:0).
Msg 8909, Level 16, State 1, Line 1
Table error: Object ID 0, index ID -1, partition ID 0, alloc unit ID 0 (type Unknown), page ID (1:3588) contains an incorrect page ID in its page header. The PageId in the page header = (0:0).
Msg 8928, Level 16, State 6, Line 1
Object ID 0, index ID -1, partition ID 0, alloc unit ID 0 (type Unknown): Page (1:3588) could not be processed.  See other errors for details.
Msg 8928, Level 16, State 6, Line 1
Object ID 0, index ID -1, partition ID 0, alloc unit ID 0 (type Unknown): Page (1:3589) could not be processed.  See other errors for details.
Msg 8906, Level 16, State 1, Line 1
Page (1:3589) in database ID 133 is allocated in the SGAM (1:3) and PFS (1:1), but was not allocated in any IAM. PFS flags 'IAM_PG MIXED_EXT ALLOCATED   0_PCT_FULL'.
Msg 8939, Level 16, State 98, Line 1
Table error: Object ID 0, index ID -1, partition ID 0, alloc unit ID 128634064356966400 (type Unknown), page (10275:131098). Test (IS_OFF (BUF_IOERR, pBUF->bstat)) failed. Values are 130156553 and -1.
Msg 8939, Level 16, State 98, Line 1
Table error: Object ID 0, index ID -1, partition ID 0, alloc unit ID 128634064356966400 (type Unknown), page (10275:131098). Test (IS_OFF (BUF_IOERR, pBUF->bstat)) failed. Values are 130156553 and -1.
CHECKDB found 6 allocation errors and 2 consistency errors not associated with any single object.
Msg 8906, Level 16, State 1, Line 1
Page (1:3404) in database ID 133 is allocated in the SGAM (1:3) and PFS (1:1), but was not allocated in any IAM. PFS flags 'MIXED_EXT ALLOCATED   0_PCT_FULL'.
Msg 2575, Level 16, State 1, Line 1
The Index Allocation Map (IAM) page (1:3588) is pointed to by the next pointer of IAM page (0:0) in object ID 846730169, index ID 3, partition ID 72057594098810880, alloc unit ID 72057594102808576 (type In-row data), but it was not detected in the scan.
Msg 7965, Level 16, State 2, Line 1
Table error: Could not check object ID 846730169, index ID 3, partition ID 72057594098810880, alloc unit ID 72057594102808576 (type In-row data) due to invalid allocation (IAM) page(s).
Msg 8906, Level 16, State 1, Line 1
Page (1:3250) in database ID 133 is allocated in the SGAM (1:3) and PFS (1:1), but was not allocated in any IAM. PFS flags 'MIXED_EXT ALLOCATED   0_PCT_FULL'.
Msg 2575, Level 16, State 1, Line 1
The Index Allocation Map (IAM) page (1:3589) is pointed to by the next pointer of IAM page (0:0) in object ID 846730169, index ID 5, partition ID 72057594098941952, alloc unit ID 72057594102939648 (type In-row data), but it was not detected in the scan.
Msg 7965, Level 16, State 2, Line 1
Table error: Could not check object ID 846730169, index ID 5, partition ID 72057594098941952, alloc unit ID 72057594102939648 (type In-row data) due to invalid allocation (IAM) page(s).
CHECKDB found 4 allocation errors and 2 consistency errors in table 'TAP20111220121130P01' (object ID 846730169).
CHECKDB found 10 allocation errors and 4 consistency errors in database 'TK0110'.

I backed up this data a few days ago, and just made a new backup now to be sure, but as I said, not sure what to do next. Should I try the repair options of DBCC or maybe something else?

I also attached a picture of the error, part of it is in Finnish, but never mind that.. 

-Nexenizer

Query On Trigger

$
0
0

Hi guys i am working as a software engineer at bangalore,i have given a task by team-lead .I have two tools (i.e., SQL Server and My SQL) and two databases in different tools the thing is if update any data in table present in SQL Server it should reflect to the table present in My SQL and it should be done using Triggers Concept just by rising a Trigger.

Please anyone help me by giving that kind of Trigger Query to do the task.

Regards

Anil Pomar

Share a database with LocalDB

$
0
0

Hi all,

Reading the "permissions" part of this page I understand that I can share a database with several users even if those users do not use a shared instance.

To do that, I just need to create the database in a folder that is available for the 2 users.

I've tried:

User 1:

  • Connect (LocalDB)\v11.0 (with SQLCMD)
  • create database MyDB on (name='MyDB', filename='c:\ProgramData\MyCompany\MyDB.mdf');
  • Disconnect

User 2:

  • Connect (LocalDB)\v11.0 (with SQLCMD)
  • use MyDB
  • --> Database 'MyDB' does not exist.

I suppose I must "attach" MyDB to the file in the User 2 context but I don't know how to accomplish that.

Regards,

Tetranos

SQL server 2012 -Sys tables

$
0
0

Hi,

In Sql, which sys table contains database name, table name, field name, field type and field size.

I want these all fields in a single Sys table.

If anybody knows about this then please let me know.

Thanks & Regards,

Shital 

DBCC SHRINKFILE not recaliming the free disk space in a datafile but throwing error

$
0
0

Hi,

Despite this is an huge narration, in order to get a solution, I should mention the background of this database file on which DBCC SHRINKFILE is getting failed.

We have a SQL Server database file with the capacity of 270 Gigs& the database name is: "MyDataFile270G

The Logical Name of the Database files are as : MyDataFile.mdf ;MyDataFile_log.ldf

We planned to split this huge Data file (MyDataFile.mdf, 270 Gigs) into 4 Data files (MyDataFile1.mdf, MyDataFile2.ndf, MyDataFile3.ndfand MyDataFile4.ndf to implement multiple data files on separate 4 disk drives.

We decided to use DBCC SHRINKFILE'S EMPTY FILE OPTION and the following are the workouts for this plan.

Step 1)  We changed the Logical Database name ofMyDataFile.mdf from MyDataFile to MyDataFile1, so I used the following command

alter database MyDataFile270G set SINGLE_USER with rollback immediate
go
alter database MyDataFile270G modify file (NAME=N'MyDataFile',NEWNAME=N'MyDataFile1')
GO
alter database MyDataFile270G set MULTI_USER with rollback immediate
go

Step 2) To CREATE A TEMPORARY DATABASE FILE, We used the following Script:

USE [master]
GO
ALTER DATABASE MyDataFile270G ADD FILE (
   NAME = 'MyDataFile_TEMP',
   FILENAME = 'N:\SQLData\MyDataFile_TEMP.ndf',
   SIZE = 270GB,
   FILEGROWTH = 1GB
);
GO

Step 3) Using the following command, We moved the entire data fromMyDataFile1 to MyDataFile_TEMP

USE MyDataFile270G
GO
DBCC SHRINKFILE (N'MyDataFile1' , EMPTYFILE)
GO

It took around 36 hours to complete Step 3 and as we were in a compulsion to bring the database ONLINE, we stopped the plan in this stage and handed over the database with the following capacity details:

MyDataFile1 with 270 Gigs & MyDataFile_TEMP with 270 Gigs. As this is online now, the present Used & Free space details are as follows:

MyDataFile1 : Used - 5 Gigs ; Free - 265 Gigs

MyDataTemp : Used : Almost all the 270 Gigs,

Here we go for the error message that I am facing whilst trying to SHRINK the Data File MyDataFile1 in order to regard 195 Gigs out of 265 Gigs since we planned to have each data file with 70 Gigs.

The Shrink command I am trying to use:

USE MyDataFile270G
GO
DBCC SHRINKFILE (N'MyDataFile1' , 71680)
GO

The following error message is being received for the above mentioned shrink command:

Msg 8985, Level 16, State 1, Line 4
Could not locate file 'MyDataFile1' for database 'MyDataFile270G ' in sys.database_files. The file either does not exist, or was dropped.

Any solution to overcome this issue and regain the disk space from MyDataFile1is very much appreciated.

Thanks in advance.


Many Buffer I/O and network I/O wait

$
0
0

Hi all

when I open the Activity Monitor and I see there are many Buffer I/O and Network I/O wait.

is it healthy ?? and what's the Buffer I/O ?? is it memory?

SP slow from app fast from SSMS. Also plan guides for entire SP?

$
0
0

OK, I see this is a perennial, but now it's hitting me!

It's a winapp, in C#, using connection pooling.

sys.dm_exec_sessions does not show any different settings, and what settings would matter anyway.

There is no blocking going on.

It's SQL Server 2008 R2 Standard on Windows Server 2008 R2 Standard, both 64 bit.

I run profiler and get the textdata from the slow run from the app, paste it into SSMS, and it runs fast against the same server, so it does not seem to be a matter of parameter sniffing.

It is not a matter of buffers, afaik, I can run the query fast from SSMS, then some random time later slow from the app.

The number of logical reads goes up by a factor of 1000 for the bad plan.

I can *see* the bad plan and the good plan, and they are unfortunately complex but I can quickly see in one place the good one uses merge joins instead of several layers of loops - but the question is, WHY ANY DIFFERENCES AT ALL given the same parameters?  It is possible that some of the tables and statistics have changed *slightly* between runs, but nothing that should affect the plans, it's a fairly stable database.

Finally, plan guides - can I freeze an entire complex SP with one guide?  All the examples seem to suggest that a guide only works for a statement or batch at a time.  I guess I can feed it the entire SP as text?

Thanks,

Josh


Stored procedure timeout expired

$
0
0

I have a weird issue with one of my stored procedure. It used to work correctly. But recently it is take to forever to complete. 

I tried to locate where it got stuck by dumping the procedure to a query window and execute them as a sequence of sql statements. But they work fine.

So I am totally confused. What is the difference between those 2 approaches? 

Any input is appreciated.


Best approach to manage large volumes (each table size is around 150 GB) of data

$
0
0

Folks,

I have a requirement to manage the older data by moving from current table to its history table in other database. Can someone advise me what is the best approach to move high volumes of data (each table size is around 150 GB)?

And also the current table should have only the recent 1 month data. If the data becomes one month older, it should automatically move to the history table.

Thanks in advance.


Regards Chenchi MSSQL Server DBA


Sch-M and Sch-S deadlock related to partitioned tables

$
0
0

Hi,

Very anoying scenario... We have large partitioned table and we use staging table loads, and partitions sliding in and out of this table (part of the process is also rebuilding indexes on the staging table that is being slid into large partitioned table). Recently (it doesn't mean it wasn't happening before, it is just that we turned on TF 1222), we noticed deadlocks of partition management process (explained before), and regular reports that run against table that is being altered (either main partitioned table or staging table). Sometimes it is even more ridicilous: we noticed some sql server management studio intellisense feature (!!probably because it is reading metadata) connections getting deadlocked with the process managing partitions.

After analyzing sql error log, we found that it is always Sch-M lock (partitioning management, which is normal becuase of ALTER or CREATE INDEX statements) deadlocking with different SELECT processes (Sch-S), and that it is always (luckily) Sch-S process that gets chosen as a victim. Why would they get deadlocked (unless it is some meta data contention)? Why wouldn't Sch-M wait for Sch-S to complete,or the oposite? Is there any way around this?

We are using sql server 2008r2 with 16 cpus (I read article that there is a bug related to systems with 16+ CPUs and lock partitioning, but I don't think that is the case here). Here is basic info from the log about typical deadlock we are facing... 1st process is ALTER TABLE (switch partition in), 2nd process is select from the main table...

process that survived deadlock:
process id=process9ab51ebc8 taskpriority=0 logused=172 waitresource=OBJECT: 7:52351401:12  waittime=7437 ownerId=141346191 transactionname=user_transaction lasttranstarted=2013-02-27T20:02:25.523 XDES=0xbd476b950 
lockMode=Sch-M schedulerid=1 kpid=8296 status=suspended spid=143 sbid=0 ecid=0 priority=0 trancount=2 lastbatchstarted=2013-02-27T20:01:40.387 lastbatchcompleted=2013-02-27T20:01:40.387 clientapp=prod.cstatSvcDataSetProcessor 
hostname=SRV001 hostpid=10556 loginname=MAD\uprd isolationlevel=read committed (2) xactid=141346191 currentdb=7 lockTimeout=4294967295 clientoption1=673185824 clientoption2=128056
Victim:
process id=process42c212bc8 taskpriority=0 logused=0 waitresource=OBJECT: 7:52351401:5  waittime=4570 ownerId=141346297 transactionname=Lookup lasttranstarted=2013-02-27T20:02:28.410 XDES=0x800dae50 
lockMode=Sch-S schedulerid=13 kpid=8164 status=suspended spid=145 sbid=0 ecid=0 priority=0 trancount=0 lastbatchstarted=2013-02-27T20:02:22.447 lastbatchcompleted=2013-02-27T20:02:22.440 clientapp=IBM Cognos 8 
hostname=CGNS001 hostpid=6736 loginname=BI isolationlevel=read committed (2) xactid=141345879 currentdb=6 lockTimeout=4294967295 clientoption1=671088672 clientoption2=128056

thanks


Pedja

dbcc check repair

$
0
0

Dear Experts,

I would like to know that if we repair some tables with repair command than what could be future impact and how can someone track the repaired tables in future.

please share your experience...

Is doomed transaction inevitable if deadlock occurs in a trigger (SQL Server 2008 R2)?

$
0
0

Hi all,

Below are two scenarios, however, what I am trying to accomplish is to catch deadlock errors and re-try the DML that was chosen as the deadlock victim.  Does anyone know of way to accomplish what I am trying to accomplish without a doomed transaction given the constraints?  I have seen many posts that this appears to be a limitation of the dbengine, but am looking for confirmation.

In both scenarios, I have a SProc - let's called it "X" - that is called mostly from within triggers (that performs some denormalized calculations and cannot be changed at this time) - in which deadlocks are often occurring.

Scenario 1

  • In SProc X, I want to catch any 1205 errors, and re-try the query that receives the 1205 error
  • However, whenever I re-try the query I receive an error that the transaction is "The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction"

Scenario 2

  • In SProc Y, that runs DML statements that will fire triggers that call SProc X, I want to catch any 1205 errors, and re-try the query that receives the 1205 error
  • If SProc Y is called outside any transaction, I can begin a new transaction and rollback if a deadlock occurred and successfully retry the DML
  • However, if SProc Y is called inside a transaction, I need to perform a SAVE TRAN and rolback to the savepoint. Whenever I re-try the query I receive an error that the transaction is "The current transaction cannot be committed and cannot be rolled back to a savepoint. Roll back the entire transaction.". For my logic to work, I cannot rollback the entire transaction, so SProc Y only performs as expected outside a transaction

TIA,

Dave




SQL Browser and SQL VSS writer missing

$
0
0

I have an issue with a SQL 2008 R2 Standard default instance (running on Server 2008 R2 Std.) which appears to be missing parts of its installation.

The SQL Server Browser and SQL VSS writer services are not listed in the Services MMC snap-in, I also do not see the sqlbrowser exe file in the Shared directory.

When I attempt to repair the instance, the repair Wizard detects the instance but only believes that the Full Text Engine is installed. When I attempt to add a feature to the instance, the wizard does not detect the DB engine as installed - it allows me to select that option for new install and proceed through the installation wizard - it asks for auth type., new sa user password, service accounts, etc. as if nothing is installed. I stop short of starting the "install" fearing that this will cause conflicts and issues with the currently functioning databases. I know for certain that the Database engine is installed because there are active databases running at present and the associated applications are functioning normally. I am also able to log into SQL Mgmt Studio and manage the DB instance - nothing there looks off.

I recently removed a SQL 2008 (not sure if it was R2) Express instance  (I chose to leave Shared components in tact) and the timing lines up with when I noticed the aforementioned services missing (Backups stopped working so I started to investigate). The uninstall appeared to work properly but I still see the Reporting Services and Full-text Filter daemon for the Express instance in the Services MMC. Add/Remove programs gives no indication of this instance existing.

Thanks in advance for your assistance.

how to clear the table

$
0
0

i have a temporary table (table1) , after execution i what clear it for waiting for new data

Cannot read SQL Server 2008 database - version increased to 661 from 655

$
0
0
I purchased a new desktop computer that had Windows 7, so I installed Visual Studio Express 2010 from an iso image.  Now the database cannot be read on my laptop.  I then installed VS Express 2010, as well as, SQL Server 2008 R2 on the laptop, but I still get the error message that it is expecting version 655, and cannot read version 661.

Sql server 2008 management studio

$
0
0

Can I install Sql server 2008 management studio into Ubuntu operating system? If not then is there any other option or any other way to use sql database to be open or restore into Ubuntu / Linux???

please kindly reply any one....


jainam

which one is faster? query from Table or View

$
0
0

I have a transaction table where I have around 1 million records. I have created a view for this table with around 50 other tables joined via foreign key.

Now, when I fetched a record using a simple query, which one of the following will be faster? Table or View?

My query is fetching a real field from a Table and where clause includes cluster index.

Select Field1 from Table1 where Sequence = xxx

or

Select Field1 from View1 where Sequence = xxx

I feel that the first query (Table1) will be faster however when I see Query Execution Plan, I dont see any difference. So, I am confused as whether it makes any difference if I use table instead of view? Also, if there are more records, will it make substantial difference?

Awaiting your reply.

Thanks

Rahul

Viewing all 15264 articles
Browse latest View live


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