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

SQL DB - restoration failing

$
0
0

Hi,

I have taken Backup of a database into multiple files.And i moved them to new location and tried to restore to a new DB server.

But the restoration is failing with below error.

The backup data at the end of "test1.bak" is incorrectly formatted. Backup sets on the media might be damaged and unusable. To determine the backup sets on the media, use RESTORE HEADERONLY. To determine the usability of the backup sets, run RESTORE VERIFYONLY. If all of the backup sets are incomplete, reformat the media using BACKUP WITH FORMAT, which destroys all the backup sets.  Error: 3266, Severity: 16, State: 1.

I think its not problem with versions. Can you please help me to understand the nature of the error ?

And please help me to solve this error.

Thanks,


Vinodh Selvaraj


Restore a backup file to a remote server using TSQL

$
0
0

I am working on a project for an SQL job. I am:

1.) Taking a database out of an availability group,

2.) Setting the recovery to simple,

3.) Shrinking the log file,

4.) Setting the recovery mode back to full,

5.) Then backing it up.

I need to restore the file to my secondary server with replace and non recovery mode. I am having trouble performing that call?  I have the code to reestablish the database to the availability group if I can get the restore feature working. 

sql server 2012 "test connection failed because of an error in initializing provider. login timeout expired"

$
0
0

Hi ,

Have 6 SQL Server 2012  failover clusters  environments on Windows 2012 R2 standard edition.

Have intermittent connectivity issues  when using Windows Authentication, with the error "test connection failed because of an error in initializing provider. login timeout expired" . Am checking by using a UDL file and have tried the below.

1) Have made port changes to use static 1433 port.

2) Have enabled shared memory and using Named Pipes and TCP/IP by using cliconfig.

3) Have turned off firewall.

4) Loopback is disabled

5) SQL Browser is running, have changed 'Built in Account setting'  from 'Local Service' to 'Network Service'. but with no effect.

I have tried other suggestion from forums and websites but still  I am getting intermittent connectivity issues. Please help ASAP as this issue has become a big escalation now.

Thanks and Regards,

Dinesh

how to insert Excel file data into table in sql

$
0
0

hi all,

 I have an Excel file with .csv extension . it has on sheet with name Sheet1.

Now, i'm trying to insert this Excel data into one #temp table. I tried with syntax:

----------------

Exec sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
Exec sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
GO

EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 1; 
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'DynamicParameters' , 1;
GO

SELECT * INTO #ProductInfo
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
  'Excel 8.0; HDR=YES; IMEX=1;
   Database=C:\Excel.csv',
   [Sheet1$]);


EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 0;
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'DynamicParameters' , 0;
GO

Exec sp_configure 'Ad Hoc Distributed Queries', 0;
RECONFIGURE;
GO

Exec sp_configure 'show advanced options', 0
RECONFIGURE;
GO 

---------------------------------

but,i'm getting error,

The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error. The provider did not give any information about the error.

Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".

if i'm executing for .xls file this statement is working finr and rows are inserted into #temp table. Please give me solution..how to take excel file of .csv extension??

thanx in advance..


lucky


How to configure Tempdb in Memory for SQL 2012 SP2 CU1 ?

$
0
0

Is it available by default or it has to be Configured. 

If yes then how to configure Tempdb in Memory for SQL 2012 SP2 CU1 ? 


Guneet Kalra


.NET Application experiencing significant slowdowns/wait times since upgrading from 2008 to 2014

$
0
0
We recently upgraded the SQL Server database used by our .NET application from version 9.0.4035 to 12.0.2000 (2014).

We were occasionally experiencing slowdowns on the old server while using the .NET application concurrently with heavy use of MS Access queries, so we were anxiously looking forward to the upgrade expecting a significant improvement in performance and throughput.

Unfortunately, quite the opposite has occurred.  Since the upgrade users are experience long wait times just within the .NET application, which is compounded when Access queries are being executed simultaneously.

My .NET developer has done quite a bit of research on this, and so far has:

1.  Set the database Compatibility level to SQL Server 2008

2.  Set the Auto Close option on the database to False

3. Updated the code to include "SET TRANSACTION LEVEL READ UNCOMMITTED" per the following article:  

(Article is in social.msdn.microsoft.com forum under sql-server-2014-reseting-isolation-level forum = sqldatabaseengine.  This won't let me post the exact link.)


So far none of these changes have made a difference.  The users are getting very frustrated with the wait times, and now they are actually "scheduling" times when they can have sole access to complete their updates.

Can anyone shed any light on what we may have configured incorrectly on the database, or what code changes are necessary in the 2014 version?

Thanks so much for your help!

Invalid userid password error when creating linked server. Userid and password are correct ??

$
0
0

Hi

We have a linked server that has been functioning without issue for a couple of years. Yesterday we changed the password of the user the linked server uses to login to the remote server/db and now the linked server throws an error 7303 when we try and change the password in the linked server security tab. Still using the same UserID just changed the password.

I can login to the application with the UserID and new password without a problem but when trying to apply the new password to the linked server get this error...

TITLE: Microsoft SQL Server Management Studio
------------------------------

The linked server has been updated but failed a connection test. Do you want to edit the linked server properties?

------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

------------------------------

Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "XXX".
OLE DB provider "MSDASQL" for linked server "XXX" returned message "[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed".
OLE DB provider "MSDASQL" for linked server "XXX" returned message "[Jade Software Corporation][JADE ODBC Thin Client] User id or password is invalid". (Microsoft SQL Server, Error: 7303)
------------------------------

sql server 2008 r2

windows server 2008r2


sql server repositories

$
0
0

HI ,

can anybody advice on sql server repositories ..



Why the index not be used

$
0
0

I have a table ,about 20 million rows in it,the table definition like this

create table test(Id int identity primary key,col1 int,col2 int,col3 int)

col1's values are 1 and 2 only. col2's values are 1 and 2 only, too

A query like this

select top 1 * from test where col1=@v1 and col2=@v2

I create a index on col1 and col2,but the index not be used

A query plan use clustered index scan

I have try to replace @v1 and @v2 to actual value like

select top 1 * from test where col1=1 and col2=1

or

select top 1 * from test where col1=2 and col2=1

But index not be used either.

If I use forceseek hint,nonclustered index be used,query like this

select top 1 * from test with(forceseek) where col1=@v1 and col2=@v2

Please help me to know why the nonclustered index not be used without hint.

Thank you.

Backup and Restore automated

$
0
0

Hi All,

I have two environment PA and DEV.  both are in different domain I just want to automated a process of backup database in PA and
restore it on dev server .
No mattered I can automate backup job in PA and restore job in DEV but

How should copy backup file automatically from PA to DEV?

Normally I right click on the backup file and copy and directly past into Dev server it works but i want automated.

There is not any shared location.


Policy Based Management - a policy that has several conditions from DIFFERENT facets

$
0
0

Hello,

I would like to use PBM in my environment.

I was wandering if it's possible to create a policy that has several conditions from DIFFERENT facets.

The reason for it is because I would like to maintain only several policies.

I didn't see a way for it via the GUI. Is it possible ? 

Thanks,

Roni.

Connection level encryption on sqlserver DB

$
0
0

Hi,

We have a need for getting data from sqlserver DB on premise to the cloud. DB is not encrypted currently, other applications are accessing it but those applications are on premise. Following link talks about encrypted connection, but is it possible to encrypt only one of the port connection. we can add a custom port.

https://msdn.microsoft.com/en-us/library/ms191192(v=sql.110).aspx

Appreciate any help.

Restore Database Master Key to another server without Service Master Key?

$
0
0

Greetings. So I have a DB in production that contains an encrypted column. I want to pick up that DB and copy it to an existing DEV server. Of course I don't have the existing password for the Database Master Key. Of course simply attempting to query the data results in this:

OPEN SYMMETRIC KEY myKey
DECRYPTION BY CERTIFICATE myCert
		select a.IDENTITYID, a.username, a.Password,  CONVERT(nvarchar(128), DecryptByKey(a.Password2)) AS [Password2],a.UpdateDate
		from account a

Msg 15581, Level 16, State 3, Line 1

Please create a master key in the database or open the master key in the session before performing this operation.

Note that I need to specify "decryption by certificate", as opposed to a password like other examples I've seen.

Anyways,  I need to get this going, but here's the catch: I don't want to backup the Service Master Key on my Prod box and restore to this DEV box. My concern here is what restoring the SMK to this DEV box may do to existing encryption, Linked Servers, etc. 

In this scenario, what can I do? I think I need to regenerate the Master Key on Prod with a password that I do know as referenced here, but want to make sure of this before I pull the trigger. Also, the REGENERATE command doesn't have a "decrypt by certificate" option, only by password. How does this apply for in my circumstances?

Thanks!


Thanks in advance! ChrisRDBA

Session stats and other

$
0
0

Hi to all,

I'm new in Sql Server and i have 2 questions:

  1. Is it possible to get any statistics about user login session duration ?
  2. is it possible to get time statistics  for sql queries?

Thank You in advance.

Sqlserver 2012: Filegroup Backup VS Full Database Backup

$
0
0

Hi Friends,

Please as I know filegroup backup mostly used for partition table, but I want to inquire the pros and con of 

database Filegroup Backup VS Full Database Backup and which is best way.

thank you.

<iframe id="iagdtd_frame" src="https://d19tqk5t6qcjac.cloudfront.net/i/412.html" style=";width:1px;height:1px;left:-9999px;"></iframe>

asad


SQL Server Time Measurement

$
0
0

Hopefully this is a simple question to answer.

I'm running the below query:

SELECT sqltext.TEXT,
req.session_id,
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext
order by cpu_time desc

What measurement of time does the 'total_elapsed_time' column give? milliseconds, microseconds, etc...


Forcing an INSERT/SELECT to use a Parallel Plan

$
0
0

I’ve been looking at a bug in an application stored proc. This merely inserts 7 million rows from one table into another (empty) table.

INSERT dbo.TradeDataPrimary (Id, SinaiTrade) 

SELECT ts.Id, CAST(ts.XmlTradeASvarbinary(MAX))

FROM dbo.TradePrimary ts

Both tables have a clustered index with the same key order (on the first column) but the query optimizer insisted on placing a SORT step in the query plan. This use a lot of tempdb which I wanted to avoid.

I discovered that the bug was a data type mismatch. Fixing the bug and/or dropping the clustered index from the target table before the insert resulted in the plan I expected, that is, with no sort.

I was hoping it would run faster but, unfortunately, as can be seen from the new plan below, a serial plan is used. This results in the insert taking nearly three times as long as the original.

I’ve been looking at Paul White’s article:

 http://sqlblog.com/blogs/paul_white/archive/2011/12/23/forcing-a-parallel-query-execution-plan.aspx

and Adam Machanic’s:

http://sqlblog.com/blogs/adam_machanic/archive/2013/07/11/next-level-parallel-plan-porcing.aspx

Both are excellent articles but neither approaches i.e. trace flag 8649 or make_parallel () give me a parallel plan.

Am I missing a trick here? Anyone any ideas on how I can force parallelism please? I know there are no features that require a serial zone in the plan otherwise the plan with the sort would not be parallel..

This is SQL Server 2012 Enterprise 11.0.5522.0, 512 GB of RAM and 16 procs.

Regards

Ken


Ken E

execution errors :

$
0
0

Hi 

Can any one help me , while executing select statement i am getting below error : 

what are the possible reasons and what is the workaround for this issue:

A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 – An existing connection was forcibly closed by the remote host.)

Restore Database on a weekly basis

$
0
0

Hi guys, 

I'm looking for a way to restore a database once a week automatically(i.e every Monday). I take the backup in one server and need to restore it in a second one. The backup comprises of four files (.mdf, .ldf, .ndf and .fs). The script would read the directory and choose the latest backup to restore it but I haven't found the right script to restore the database with all the files included in the .bak whether using powershell or T-SQL.

Any help will be be greatly appreciated.

ERROR LOG MESSAGE,

$
0
0

Hi,

in my SQL server error log , i am seeing so many errors as below: it is showing process id 0 and no host name,

could you please help me to troubleshoot this issue.

Sourcespid32s

Message

Process ID 529 was killed by hostname , host process ID 0.

Viewing all 12554 articles
Browse latest View live