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.
| Author |
Topic |
|
raysefo
Constraint Violating Yak Guru
260 Posts |
Posted - 2006-07-04 : 11:16:06
|
| hi,i created a stored procedure and below is the code segment of it;create Procedure test1 @price as varchar(50) output, @table as varchar(50) = ''ASDeclare @SQL_INS VarChar(1000)SELECT @SQL_INS = 'select ['+@price+'] from ['+@table+']'Exec (@SQL_INS)Procedure gets 2 parameters, one of them is just INPUT parameter and the other one is both OUTPUT and INPUT. What i wanna do is to get the result set of this procedure to use in my application. |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-07-04 : 11:30:24
|
| Would u mind having more than 2 parameters (to reduce complications) ?What is ur input of @price ? is it a field name ?What do u want as output @price ? the data ?Give Sample data and expected resultsSrinika |
 |
|
|
raysefo
Constraint Violating Yak Guru
260 Posts |
Posted - 2006-07-04 : 11:34:05
|
| hi,@price = colum1@table = table1select column1 from table1sample result set is ,1.231.111.34... |
 |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2006-07-04 : 11:56:13
|
I don't think you want any output parameters. Output parameters can not be result sets - only single values. Instead, what you have is roughly right (if you remove the output keyword)...create table tbltest (column1 money, column2 money)insert tbltest select 1.23, 2.34union all select 1.11, 2.22union all select 1.34, 2.56gocreate procedure test1 @price as sysname, @table as sysname = '' ASdeclare @SQL_INS varchar(1000)set @SQL_INS = 'select ['+@price+'] from ['+@table+']'exec (@SQL_INS)goexec test1 'column1', 'tbltest'exec test1 'column2', 'tbltest'godrop table tbltestdrop proc test1go You should be able to call the sproc from your app and get the result set.Ryan Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2006-07-05 : 12:04:04
|
Dude, what's with all the dynamic SQL? Do you even have a purpose for all this?Here...be done with it...you will only need one sprocUSE NorthwindGOCREATE PROC mySproc99 @sql varchar(8000)AS EXEC(@sql)GOEXEC mySproc99 'SELECT * FROM Orders'GODROP PROC mySproc99GO Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
|
|
|
|
|