|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Returning a "Table" type from a stored procedureparameters. The output is a set of rows from a table and is to be populated into the dataset. I'm not sure if the following is correct. Create Procedure ProcName @inputA varchar(50), @ds TABLE OUTPUT As SELECT * FROM Table1 WHERE Table1.inputA = @inputA RETURN @ds _________________________________ Should I declare the column definitions for the output parameter as what the compiler had prompted. If yes, is the following correct ? Create Procedure ProcName @inputA varchar(50), @ds TABLE OUTPUT As DECLARE @ds (title varchar(50), Language varchar(50)) SELECT * FROM Table1 WHERE Table1.inputA = @inputA RETURN ds ___________________________________ "Language" is a column in the table but VS.NET treats it as being used by the Microsoft Scripting Language for transformation (not sure what it's for). There are also other columns in the table with names like "File Size" and I'm getting the same highlights as the "Language" property. How should they be declared ? "Kim" <K**@discussions.microsoft.com> wrote in message You don't need an output parameter to return rows from a SQL Server stored news:2C37339A-A7BE-422A-9B49-CEE6F5589F88@microsoft.com... >I am trying to create a stored procedure that has both input and output > parameters. The output is a set of rows from a table and is to be > populated > into the dataset. I'm not sure if the following is correct. > > Create Procedure ProcName @inputA varchar(50), @ds TABLE OUTPUT > As > SELECT * FROM Table1 > WHERE Table1.inputA = @inputA > RETURN @ds > ___________ procedure. Just run a SELECT in the body of the procedure and the rows will be returned to the cliene. Create Procedure ProcName @inputA varchar(50) As SELECT * FROM Table1 WHERE Table1.inputA = @inputA David Just curious. What is a "cursor" type ? According to the MSDN library
definition, it's a reference to a cursor. Show quote "David Browne" wrote: > > "Kim" <K**@discussions.microsoft.com> wrote in message > news:2C37339A-A7BE-422A-9B49-CEE6F5589F88@microsoft.com... > >I am trying to create a stored procedure that has both input and output > > parameters. The output is a set of rows from a table and is to be > > populated > > into the dataset. I'm not sure if the following is correct. > > > > Create Procedure ProcName @inputA varchar(50), @ds TABLE OUTPUT > > As > > SELECT * FROM Table1 > > WHERE Table1.inputA = @inputA > > RETURN @ds > > ___________ > > You don't need an output parameter to return rows from a SQL Server stored > procedure. Just run a SELECT in the body of the procedure and the rows will > be returned to the cliene. > > > > Create Procedure ProcName @inputA varchar(50) > As > SELECT * FROM Table1 > WHERE Table1.inputA = @inputA > > David > > > "Kim" <K**@discussions.microsoft.com> wrote in message You can pass a cursor from one stored procedure to another, but not back to news:B32ECA31-165C-4B96-A0F5-D4D9011819C5@microsoft.com... > Just curious. What is a "cursor" type ? According to the MSDN library > definition, it's a reference to a cursor. > the client. David All rows are returned instead of those that are specified by the condition.
Is there anything wrong with my sql statements ? Show quote "David Browne" wrote: > > "Kim" <K**@discussions.microsoft.com> wrote in message > news:2C37339A-A7BE-422A-9B49-CEE6F5589F88@microsoft.com... > >I am trying to create a stored procedure that has both input and output > > parameters. The output is a set of rows from a table and is to be > > populated > > into the dataset. I'm not sure if the following is correct. > > > > Create Procedure ProcName @inputA varchar(50), @ds TABLE OUTPUT > > As > > SELECT * FROM Table1 > > WHERE Table1.inputA = @inputA > > RETURN @ds > > ___________ > > You don't need an output parameter to return rows from a SQL Server stored > procedure. Just run a SELECT in the body of the procedure and the rows will > be returned to the cliene. > > > > Create Procedure ProcName @inputA varchar(50) > As > SELECT * FROM Table1 > WHERE Table1.inputA = @inputA > > David > > > Things just do not work this way.
1. Table variables are designed to be returned from a table valued function, not to be used as a parameter. 2. Return type for a stored procedure is always integer 3. There is no sense to return output parameter via RETURN 4. Table @ds does not have column definition 5. Table @ds is not a part of any select statement in your code Kim wrote: Show quote > All rows are returned instead of those that are specified by the condition. > Is there anything wrong with my sql statements ? > > "David Browne" wrote: > >> "Kim" <K**@discussions.microsoft.com> wrote in message >> news:2C37339A-A7BE-422A-9B49-CEE6F5589F88@microsoft.com... >>> I am trying to create a stored procedure that has both input and output >>> parameters. The output is a set of rows from a table and is to be >>> populated >>> into the dataset. I'm not sure if the following is correct. >>> >>> Create Procedure ProcName @inputA varchar(50), @ds TABLE OUTPUT >>> As >>> SELECT * FROM Table1 >>> WHERE Table1.inputA = @inputA >>> RETURN @ds >>> ___________ >> You don't need an output parameter to return rows from a SQL Server stored >> procedure. Just run a SELECT in the body of the procedure and the rows will >> be returned to the cliene. >> >> >> >> Create Procedure ProcName @inputA varchar(50) >> As >> SELECT * FROM Table1 >> WHERE Table1.inputA = @inputA >> >> David >> >> >> |
|||||||||||||||||||||||