Feeds:
Posts
Comments

Archive for June, 2008

In your Visual Studio IDE go to the projects (at the top) -> add references -> com (tab) -> add the Microsoft Excel library installed.

 

Or you can use the project explorer.

Right click on the references-> add references -> com (tab) -> add the library.

 

Please refer to the image below.

 ExcelReference


Then simply what you need to do is Import the Excel.

Imports Microsoft.Office.Interop.Excel for VB

using Microsoft.Office.Interop;              for C#

 

The “Microsoft Excel X Object Library” where X will depend on whatever version of Excel you have in the computer.
So the X depends on which version of Excel is installed on your machine.

Read Full Post »

A lot of you might have come across this problem just like me.

 

Firstly we create a temporary table.

create table #temp1

(

            id Int Identity(1,1),

            invoice varchar (20)

)

insert into #temp1 values (‘CR’)

insert into #temp1 values (‘CR ‘)

insert into #temp1 values (‘ CR ‘)

insert into #temp1 values (‘ CR’)

 

Select *  From #temp1

            where DATALENGTH(invoice) <> len(invoice)

 

The len function in SQL gives you the length of the characters including the spaces white DataLength excludes the trailing not preceding spaces.

 

Here if you don’t have the column defined as varchar rather you have an nvarchar field then you simply convert then to varchar before calling the respective functions like this.

 

Select *  From #temp1

            where DATALENGTH(convert(varchar(20),invoice)) <> len(convert(varchar(20),invoice))

 

 

Happy searching trailing spaces in your db, please share with us if you have better options.

Read Full Post »

Server: Msg 8180, Level 16

Server: Msg 102, Level 15

Server: Msg 1018, Level 15, State 1, Procedure SendReview, Line 12

Incorrect syntax near ‘FASTFIRSTROW’. If this is intended as a part of a table hint, A WITH keyword and parenthesis are now required. See SQL Server Books Online for proper syntax.

Remote tables are not updatable. Updatable keyset-driven cursors on remote tables require a transaction with the REPEATABLE_READ or SERIALIZABLE isolation level spanning the cursor.

 

We were getting this error from the SQL server job that was running a store procedure inside which we were calling a table that was on a linked server running SQL Server 2005, while the major database was running on SQL Server 2000. We had the linked server setup and it was running fine. We could run queries to this table on the 2005 server without any difficulties.

One thing that I came to find out was the changes in the cursor. Please find details from the following link http://msdn.microsoft.com/en-us/library/ms143359.aspx.

 

Solution:

            1: Either you can have a temp table created out side the cursor to get all the values from across the linked server and then create the cursor over this table.

2: Secondly you can replace the Cursor with a simple loop.

3: Thirdly if possible and you can simply create the Cursor as “FOR Read Only”.

 

Hope this helps you people to migrate your databases happilyJ.

Well I found the solution from this URL:
http://www.eggheadcafe.com/software/aspnet/31278881/cannot-declare-a-cursor-t.aspx

Thought I should share it with everyone.

Read Full Post »