Tuesday, 1 August 2017

Msg 7308, level 16, state 1, line 1

Inserting Excel sheet values into a table of SQL server.
------------------------------------------------------------

1.initially we need to install MS office of 2010 64 bit version


2.and after that  we need to install Microsoft OLEDB 12.0 64 bit software.


3.the next thing is we need to enable adhoc query option with the help of sp_configure.


4.we need to provide for the user  windows admin rights beacuase when insert is happen temp directory will get create.
and on particular datab ase user should have db_owner permission.


5.exact insert query should be like this.
SELECT * INTO [dbo.TEVA_Prescription] FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
                         'Excel 12.0;Database=D:\Projects\Teva CPMP\Prescription\my_tev_2.xlsx;HDR=YES',
                         'SELECT * FROM [report1$]')


6.the error is something like this


Msg 7308, level 16, state 1, line 1
OLEDB provider 'Microsoft.ACE.OLEDB.12.0' cannot be used for distributed queries because the
provider is configured to run in single-threaded apartment mode.

Thursday, 27 July 2017

SQL Server: Brief explanation on Locking, Blocking, Deadlock


SQL Server: Brief explanation on Locking, Blocking, Deadlock

 

Like ever, today’s article of Pinal Dave was interesting and informative. After, our mutual discussion between our DBAs and Developers on Pinal Dave topic of Concurrency and Isolation. I felt that most of us are intermingling three equally sounding words. Those are LOCKING, BLOCKING and DEAD LOCKING.

Lets try to revisit these concepts with some simple analogies.

LOCKING occurs when connection needs access to a piece of data in database and it’s necessary for SQL Server when managing multiple connections. Just assume an example of your garage, when you park your car in garage, basically you are locking the place of garage.

 

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi52XL82WMq7CEXLnb666i_LEjXVVz5n3C9Al-qZC897QkNN7k9goNvhgEZUqxJG-wwKGLnF86CjBITfFYMF6Ot5RoGLJmG9UAcuk-YtM802kCUbwDwJ9hh-BTcRj3F92NcSCb75mi-Vc25/s1600/locking.jpg

BLOCKING occurs when two connections need access to same piece of data concurrently and one connection is blocked because at a particular time, only one connection can have access. Just like, you stop (block) your car on a traffic signal because some other car or cars are using the crossing area.

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVOX2JIU-4oRNFrIoOVgygOPnrdctxZQMgQTH3pndYdJ1GzJmODGvLV4C4OfzC6wj2ZBJJatNz7DgWo6hu1P6dZn-35LbzAbNVP9IRqeG8B6MaydcbtJw3la_xOjLpA6tFR8rqV7pLgnbW/s320/blocking.jpg

DEAD LOCK occurs when one connection is blocked and waiting for a second to complete his work, but on other side, second connection is also waiting for first connection to release the lock. Just like, you need to cross the signal area but same time someone else from opposite side also want to cross the signal. Now, you need a way which other is holding and other need way where your car is.

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiSIvf6kB0dDKzHGMYKsdMRCBpzyINuUh2vNA6ZIum_7U9IuqDzxT8ZZ5VSsokQ1Nt9eA6CQCxhyphenhyphen_DYuKXeUdI5DNL7faBCyAabh-XcrmjsnXVa3EL1iGRzM2t9jmjLEuw0dM7Fl3z3yAE/s1600/Deadlocking.gif

That is why, one should be clear that locking is integral part of SQL Server to handle concurrency, blocking is bad when one connection/transaction is waiting unnecessary for a long time, and deadlocking is a phenomenon which should never occur.

 

SQL server Stop and Start methods

Ways to Stop and Start for SQL server
-----------------------------------------------


1)
 Step1. Just go to the run and type : services.msc





And choose the sql server instance from the list and  right click -->Stop or Restart.





2. Go to the Start button --> All Programs-->Microsoft SQL server 2008R2-->Configuration Tools--> SQL server configuration manager






3. NET START MSSQLSERVER


 This command will be get executed only through command prompt. So you have go to the run and type cmd then write a above command in order to restart or stop sql server







4. Connect to SQL server VIA SSMS , then right click on the instance and do it(Restart or Stop)






Msg 7308, level 16, state 1, line 1

Inserting Excel sheet values into a table of SQL server. ------------------------------------------------------------ 1.initially we need ...