Solved

Table valued parameters in SqlServer 2005

Posted on 2009-05-12
9
509 Views
Last Modified: 2012-05-06
Hi,
I want to use table type parameter for procedure because i need insert to to many rows(300000) quicly. This problem was solved in sqlserver 2008. I need like this code;

create proc(@tbl table(a int, b nvarchar(10))
as
begin
      insert into mytable(a,b)
      select a,b from @tbl
end

or

i change this row like to:
create proc(@tbl myTableType)
as
...
...

How can i insert to many rows in a one transaction.

I'm use ado.net 1.1(asp.net) and sqlserver 2005.

Best Regards.
0
Comment
Question by:OmerFarukZ
  • 4
  • 2
9 Comments
 
LVL 3

Author Comment

by:OmerFarukZ
Comment Utility
And which sqldbtype must used?(ado.net not contain sqldbtype.structed)
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 300 total points
Comment Utility
sql 2005 does not have this feature.
so, you must do this differently.

one possibility would be passing the data as XML, but with 30000 records to be inserted, depending on the "row size" with the xml overhead, this might get a lot of data to pass to the procedure at once...
0
 
LVL 3

Author Comment

by:OmerFarukZ
Comment Utility
Click for more information the structed dbtype in .net: http://msdn.microsoft.com/en-us/library/bb675163.aspx. xml idea is very logical, i try and reply to you.

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Author Comment

by:OmerFarukZ
Comment Utility
Does xml type kind of support more than 8000 characters?
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
>Does xml type kind of support more than 8000 characters?
in sql 2005, yes. up to 2GB
0
 
LVL 51

Assisted Solution

by:Mark Wills
Mark Wills earned 200 total points
Comment Utility
300,000 rows of data will be a big XML document, but as angelIII points out the XML datatype can take 2gb

Insert 300,000 rows from where ?
What is the source data that needs to be inserted ?
Is it going straight into "live" tables or using a "staging" table first ?

Might be able to use bulk insert, and a few other possible methods...
0
 
LVL 3

Author Comment

by:OmerFarukZ
Comment Utility
okay I'll try
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to shrink a transaction log file down to a reasonable size.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now