Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 alternate of cursor

Author  Topic 

imranabdulaziz
Yak Posting Veteran

83 Posts

Posted - 2010-07-15 : 23:44:18
Dear all,
I am using sql server 2005 with asp.net 2.0 ,C#

I am uploading data from excel file to sql server 2005.
As excel file is large, uploading data each row wise was giving time out error.
So I used bulkcopy option of dotnet feature.

Now I upload data to temp table then from temp table I move the data to original table in its respective format.

Problem is first I need to validate the whole data before moving to main table. For that I am using cursor I need to know is there other solution so that we can validate each row data and performance also not suffer much

Thnak you

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-07-16 : 00:03:37
It depends. Could you explain the validation part? Perhaps show us some sample rows and how they would need to validated or transformed.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-07-16 : 00:05:33
how does your the cursor code looks like ? Can you post it here ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

fagim
Starting Member

9 Posts

Posted - 2010-07-16 : 03:46:47
Never work on EXCEL side and with custom tools to bring data from EXCEL to DB

Use standard import feature. But fill INTERMEDIATE table.

Assume:

U have good myschema.mytable table and maybebad.xls

1) create schema myschema_import
2) use common tool to one-to-one copying Excel file into
myschema_import.maybebad table - no references you must keep, no constraint to check, no trigger that calls...
3) use NATIVE sql features or special tool (if you want) but work on SQL side with intermediate table with relational operations. You can perform many of little steps on whole table and it will be FAR MORE EFFICEIENT RATHER THAN Cursor over JET data
4) when data is prepared copy it into working table
Go to Top of Page
   

- Advertisement -