Solved

Table valued parameters in SqlServer 2005

Posted on 2009-05-12
9
512 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
ID: 24366202
And which sqldbtype must used?(ado.net not contain sqldbtype.structed)
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 300 total points
ID: 24367871
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
ID: 24377418
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 3

Author Comment

by:OmerFarukZ
ID: 24377494
Does xml type kind of support more than 8000 characters?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24400379
>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
ID: 24403589
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
ID: 24406926
okay I'll try
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

789 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