Vinay's profileVinay Thakur - Sql Serve...PhotosBlogLists Tools Help

Blog


    October 23

    Tricks and issues Part 1

    Today was browsing the Blog http://blog.sqlauthority.com/ Pinal Dave expert on Sql server and great Blog writer. Got surprise to see the comments on his Blog. Great job and thank you Pinal for having such a wonderful site and sharing valuable information.

    Found following information helpful to me today (*as I was having some issue related to this)

    Bulk insert CSV and xls:

    With this script we can import the CSV data into sql server table.
    http://blog.sqlauthority.com/2008/02/06/sql-server-import-csv-file-into-sql-server-using-bulk-insert-load-comma-delimited-file-into-sql-server/

    http://www.sqlteam.com/article/using-bulk-insert-to-load-a-text-file

    Following script helped me to import excel file

    SELECT
    * FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
    'Data Source=D:\excelsourcefile.xls;Extended Properties=Excel 8.0')...[Sheet1$]

    I used sql server 2000 and sheet 1$ data

    http://msdn.microsoft.com/en-us/library/ms179856.aspx

    and if we want to export into xls we can use the below query but we have to give heading Name on excelTargetfile.xls file before running this query:

    INSERT INTO
    OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
    'Data Source=e:\excelTargetfile.xls;Extended Properties=Excel 8.0;')...[Sheet1$]
    SELECT name FROM master.dbo.sysdatabases
    GO

    we can use the same with OPENROWSET

    http://www.mssqltips.com/tip.asp?tip=1202

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

    Job server name change (Instance name). Error 14274:

     

    While working on msdb database I restore msdb of other server/instance to different instance. found Pinal’s Blog helped me to solve my issue. by changing the server name in sysjobs table on sql server 2000.

    http://blog.sqlauthority.com/2006/12/20/sql-server-fix-error-14274-cannot-add-update-or-delete-a-job-or-its-steps-or-schedules-that-originated-from-an-msx-server-the-job-was-not-saved/

    We get the same error when server name changes for that we may have to follow Microsoft KB link as follows

    http://support.microsoft.com/kb/281642

    Insert multiple records with single insert

    Before sql server 2008 to insert multiple records with single query was very difficult, got the very good Blog by Pinal where he shows a trick to insert multiple records with single insert statement as follows link:

    http://blog.sqlauthority.com/2007/06/08/sql-server-insert-multiple-records-using-one-insert-statement-use-of-union-all/

    As Microsoft introduce new feature in insert statement were we can insert multiple records with single insert statement simply by a comma separated with multiple records value as follows:
    http://msdn.microsoft.com/en-us/library/dd776381.aspx

    Sending mail from sql server

    using SMTP :

    Following is a great KB articles by Microsoft, which explains everything and gives a sample script for the same.

    http://support.microsoft.com/kb/312839

    We can use sqlmail and database mail for sending mail via sql server.

    http://support.microsoft.com/kb/311231

    http://msdn.microsoft.com/en-us/library/ms186358.aspx

    Writing this blog to keep things as a reference to me.

     

    Thanx

    Vinay

    Twitter @thakurvinay

    Reference:

    http://blog.sqlauthority.com/

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://vinay-thakur.spaces.live.com/blog/cns!645E3FC14D5130F2!591.trak
    Weblogs that reference this entry
    • None