|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
passing a table from one sp to another spWHAT ARE THE OPTIONS do i have to pass a table from from one sp to
another? write the data into a table and then use it from the other won't do the job for me. thanks ken SQL Ken wrote:
> WHAT ARE THE OPTIONS do i have to pass a table from from one sp to Without writing the table into either a #temp table or work table, you> another? > > write the data into a table and then use it from the other won't do the > job for me. have no options. You asked for options:
1. Combine the sprocs so you don't have to pass anything 2. Rewrite your queries so that trying to pass a table is unnecessary. 3. Create a Table Valued Function (TVF) that is used by both sprocs. 4. Declare 23,999 variables and pass them as parameters (choose your own number...) 5. Write the data out to a file and then read the file back in or. 6. Create and use a #Temp table With SQL Server 2005, you could create a xml datatype variable, and then pass that as a ntext parameter, converting back to xml. See Ward's article, the 'sidebar' at the bottom: http://www.microsoft.com/technet/technetmag/issues/2005/05/SQLXML/default.aspx -- Show quoteArnie Rowland, Ph.D. Westwood Consulting, Inc Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous "SQL Ken" <SQL***@gmail.com> wrote in message news:1158281375.217094.273850@i42g2000cwa.googlegroups.com... > WHAT ARE THE OPTIONS do i have to pass a table from from one sp to > another? > > write the data into a table and then use it from the other won't do the > job for me. > > > thanks > > ken > "Arnie Rowland" <ar***@1568.com> wrote in message ntext is deprecated and "will be removed in a future version of SQL Server" news:%23KaoBQG2GHA.1256@TK2MSFTNGP02.phx.gbl... > With SQL Server 2005, you could create a xml datatype variable, and then > pass that as a ntext parameter, converting back to xml. according to BOL. Maybe nvarchar(max)? I think you're right about using varchar(max) instead.
-- Show quoteArnie Rowland, Ph.D. Westwood Consulting, Inc Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous "Mike C#" <x**@xyz.com> wrote in message news:qmoOg.347$%W2.231@newsfe10.lga... > > "Arnie Rowland" <ar***@1568.com> wrote in message > news:%23KaoBQG2GHA.1256@TK2MSFTNGP02.phx.gbl... >> With SQL Server 2005, you could create a xml datatype variable, and then >> pass that as a ntext parameter, converting back to xml. > > ntext is deprecated and "will be removed in a future version of SQL > Server" according to BOL. Maybe nvarchar(max)? > "Arnie Rowland" <ar***@1568.com> wrote in message You can also declare parameters to your SP's as xml data type without news:OSXab1H2GHA.3588@TK2MSFTNGP06.phx.gbl... >I think you're right about using varchar(max) instead. casting to a character type Arnie,
Thought of all your suggested but didn't work. Can't use a Temp table because it get detroyed after the sp is executed. can't pass a table into a function. can't write data into a table and read it in from another becuase, multiple users can execute the sp's at once. Can't combine the sp's becuae they are in two diffent servers and I conect to the remotely. can't use open query, becaue i can't pass in the parameters. I am not familiar with XML datatype but will look into that as an option. However, my srver is 2000. Your input is highly appreciated Ken. > can't write data into a table and read it in from another because, You could add a column or two and include the spid, or system_user(), both > multiple users can execute the sp's at once. of which are unique to the user, and known to any sproc. -- Arnie Rowland, Ph.D. Westwood Consulting, Inc Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous SQL Ken wrote:
> Can't use a Temp table because it get detroyed after the sp is If you create the temp table in the calling procedure, then it will be> executed. available to the called procedure(s) and still exist afterwards (until you drop it or the calling procedure exits). e.g. Proc1: CREATE TABLE #temp1(...) INSERT #temp1.... EXEC Proc2 SELECT * FROM #temp1 Proc2: UPDATE #temp1..... etc Chris Thanks,
I will try this Ken Chris Lim wrote: Show quote > SQL Ken wrote: > > Can't use a Temp table because it get detroyed after the sp is > > executed. > > If you create the temp table in the calling procedure, then it will be > available to the called procedure(s) and still exist afterwards (until > you drop it or the calling procedure exits). > > e.g. > > Proc1: > > CREATE TABLE #temp1(...) > > INSERT #temp1.... > > EXEC Proc2 > > SELECT * FROM #temp1 > > > Proc2: > > UPDATE #temp1..... > etc > > Chris
Other interesting topics
|
|||||||||||||||||||||||