Showing posts with label Sql. Show all posts
Showing posts with label Sql. Show all posts
0

Export / Import Tables from one Database to other

Today, I discovered how to export/import a database from one server to another, following are the steps I followed.
Hope this may of help to someone. Please leave your comments and suggestion if any.


1. Connect to a Database engine, where your source database is present.
2. Open Databases
3. Right click on the database. Select Task > Export Data.
An Inport Export wizard should be started, click next
5. Punch in username and password for the server.
6. Select the database from the Database drop down list. ( Select that database whose table you need to copy)
7. Click next
8. Now select your destination server and database, provide username and password.
9. Select the first option. ( No idea what the second option does :P )
10. Select the table you want to copy. You can select all if you want.
11. Click next will show you a window with "Execute Immediately" check box, Click next and finish.
12. All the selected tables will be copied to the destination database along with the data in it.


Cheers!





4

The timeout period elapsed prior to completion of the operation or the server is not responding.

"The timeout period elapsed prior to completion of the operation or the server is not responding."


Reason:
Whenever you try to retrieve huge amount of data from a database, the query execution time increases, if you have a low connection timeout value set, this error is shown.


Solution:
Set ConnectionTimeout property of the SqlConnection Class to a higher value.


Refer:
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx
0

How to do SELECT TOP @Param in a Stored Procedure?

 How to do SELECT TOP @Param in a Stored Procedure? 

Here I have created an integer param which is used later in the SELECT statement.

CREATE PROCEDURE [dbo].[SP_get]
@my_param int   
AS
BEGIN
      SET NOCOUNT ON;

SELECT TOP (@top_param) col1, col2, col3
      FROM TableName 
 

2011 ·Code-Studio by yrus.