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 2000 Forums
 Transact-SQL (2000)
 Recordset as SQL Parameter

Author  Topic 

henrikop
Constraint Violating Yak Guru

280 Posts

Posted - 2004-11-14 : 13:49:18
Hiya,

In my application I have textboxes generated depending on records in a database.

However, after an user has filled the textboxes, he/she wants to save the values from these textboxes.

Because the application is not aware of the tables in the database I can make a stored procedure and call this from the application with two parameters: An ID to identify the field, and a value which is the value entered in de texbox.

e.g.

dbo.spSaveDate 26747,'Brown'

the procedure will have something like

INSERT INTO SomeTabel (uid, Title) VALUES (@Uid,@Title)

However. No I have to call this stored procedure as much times as I have textboxes. Is there a some way that I can fire a datatable from the application as a parameter of the stored procedure

Something like:


CREATE PROCEDURE [dbo].[spSaveDate]

@SomeTable AS Recordset

AS

INSERT INTO SomeTable (uid, Title)
SELECT uid, Title FROM @SomeTable






Henri
~~~~
It's taken a long time, but I've just about learned how to quit flapping my arms and float. It's good to float.
-Al Pacino

nr
SQLTeam MVY

12543 Posts

Posted - 2004-11-14 : 13:53:32
Not like that but there are a number of methods:

define a number of parameter (say 50) fill these and if more than 50 updates needed call the sp again.

Use a csv string (max length 8000 so may need multiple calls)

use xml

create a temp table, populate it in the app and access it in the sp.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -