Solved

Table valued parameters in SqlServer 2005

Posted on 2009-05-12
9
513 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

752 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