Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Table valued parameters in SqlServer 2005

Posted on 2009-05-12
9
Medium Priority
?
518 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 900 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 600 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

886 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