Hi- I am sending several queries simultaneously to SS; I declare a variable,
and do several conditional selects to set the value of the variable. At the
end, I select the value of the variable as the return value of the complete
transaction. But, the query ends up returning multiple recordsets, because I
am doing multiple selects (although these selects only set the value of my
declared variable). After I get the recordsets back, I have to iterate
through all just to find my return value. Is there an easier way to isolate
the return value, or return just the return value in one recordset?
ThanksTry SET NOCOUNT ON in the beginning of your proc code.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"boney" <boney@.discussions.microsoft.com> wrote in message
news:7148B087-86E9-4838-A985-774418731886@.microsoft.com...
> Hi- I am sending several queries simultaneously to SS; I declare a variabl
e,
> and do several conditional selects to set the value of the variable. At th
e
> end, I select the value of the variable as the return value of the complet
e
> transaction. But, the query ends up returning multiple recordsets, because
I
> am doing multiple selects (although these selects only set the value of my
> declared variable). After I get the recordsets back, I have to iterate
> through all just to find my return value. Is there an easier way to isolat
e
> the return value, or return just the return value in one recordset?
> Thanks|||boney
Can you call a SP with an OUTPUT parameter?
For more details pls refer to the BOL.
"boney" <boney@.discussions.microsoft.com> wrote in message
news:7148B087-86E9-4838-A985-774418731886@.microsoft.com...
> Hi- I am sending several queries simultaneously to SS; I declare a
> variable,
> and do several conditional selects to set the value of the variable. At
> the
> end, I select the value of the variable as the return value of the
> complete
> transaction. But, the query ends up returning multiple recordsets, because
> I
> am doing multiple selects (although these selects only set the value of my
> declared variable). After I get the recordsets back, I have to iterate
> through all just to find my return value. Is there an easier way to
> isolate
> the return value, or return just the return value in one recordset?
> Thanks
Showing posts with label declare. Show all posts
Showing posts with label declare. Show all posts
Saturday, February 25, 2012
Tuesday, February 21, 2012
Returning fields from proc using dyn. SQL
doesnt work.
This i a testquestion to look att the behaviour:
CREATE PROCEDURE sp_testingReportsDeleteThis (@.arg1 varchar(100))
AS
declare @.sqlString varchar(800)
set @.sqlString = "select firstname from tbl_personalData where firstname
like '" +@.arg1 +"'"
execute (@.sqlString )
GO
Hoping for this proc to return "firstname" when executing this as a proc
with the command type set to Stored Proc...
The report designer asks me for the @.arg1 no problem, the result of testing
this syntax in "dataview" is exactly as expected. getting one col. full of
names like the name inserted in @.arg1 with the name "firstname". But the
fieldscolumn doesn't update.
I succeded once to get the fields-area updated, I don't know what I did, but
havent succeded since.
Whats missing, is this a "feature", or should I read the manuals one more
time'
PLS help me!!
regards
Kjell Brandes
PS.
I have to have this query dynamic, the above code is a sample to describe
the problem, not the actual productioncode...In this case you have the option of manually putting the field list in
(right mouse click where the fields should be listed, add field).
"Kjell Brandes" wrote:
> doesnt work.
> This i a testquestion to look att the behaviour:
> CREATE PROCEDURE sp_testingReportsDeleteThis (@.arg1 varchar(100))
> AS
> declare @.sqlString varchar(800)
> set @.sqlString = "select firstname from tbl_personalData where firstname
> like '" +@.arg1 +"'"
> execute (@.sqlString )
> GO
> Hoping for this proc to return "firstname" when executing this as a proc
> with the command type set to Stored Proc...
> The report designer asks me for the @.arg1 no problem, the result of testing
> this syntax in "dataview" is exactly as expected. getting one col. full of
> names like the name inserted in @.arg1 with the name "firstname". But the
> fieldscolumn doesn't update.
> I succeded once to get the fields-area updated, I don't know what I did, but
> havent succeded since.
> Whats missing, is this a "feature", or should I read the manuals one more
> time'
> PLS help me!!
> regards
> Kjell Brandes
> PS.
> I have to have this query dynamic, the above code is a sample to describe
> the problem, not the actual productioncode...
>
>|||I do not know if this will help... but a suggestion onthe SP... try
something like this..It's simpler and doesn't make a second batch
CREATE PROCEDURE sp_testingReportsDeleteThis (@.arg1 varchar(100))
AS
select firstname from tbl_personalData where firstname like @.arg1
GO
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Kjell Brandes" <kjell@.brandes.tv> wrote in message
news:ekT0VBnwEHA.2016@.TK2MSFTNGP15.phx.gbl...
> doesnt work.
> This i a testquestion to look att the behaviour:
> CREATE PROCEDURE sp_testingReportsDeleteThis (@.arg1 varchar(100))
> AS
> declare @.sqlString varchar(800)
> set @.sqlString = "select firstname from tbl_personalData where firstname
> like '" +@.arg1 +"'"
> execute (@.sqlString )
> GO
> Hoping for this proc to return "firstname" when executing this as a proc
> with the command type set to Stored Proc...
> The report designer asks me for the @.arg1 no problem, the result of
testing
> this syntax in "dataview" is exactly as expected. getting one col. full of
> names like the name inserted in @.arg1 with the name "firstname". But the
> fieldscolumn doesn't update.
> I succeded once to get the fields-area updated, I don't know what I did,
but
> havent succeded since.
> Whats missing, is this a "feature", or should I read the manuals one more
> time'
> PLS help me!!
> regards
> Kjell Brandes
> PS.
> I have to have this query dynamic, the above code is a sample to describe
> the problem, not the actual productioncode...
>
>
This i a testquestion to look att the behaviour:
CREATE PROCEDURE sp_testingReportsDeleteThis (@.arg1 varchar(100))
AS
declare @.sqlString varchar(800)
set @.sqlString = "select firstname from tbl_personalData where firstname
like '" +@.arg1 +"'"
execute (@.sqlString )
GO
Hoping for this proc to return "firstname" when executing this as a proc
with the command type set to Stored Proc...
The report designer asks me for the @.arg1 no problem, the result of testing
this syntax in "dataview" is exactly as expected. getting one col. full of
names like the name inserted in @.arg1 with the name "firstname". But the
fieldscolumn doesn't update.
I succeded once to get the fields-area updated, I don't know what I did, but
havent succeded since.
Whats missing, is this a "feature", or should I read the manuals one more
time'
PLS help me!!
regards
Kjell Brandes
PS.
I have to have this query dynamic, the above code is a sample to describe
the problem, not the actual productioncode...In this case you have the option of manually putting the field list in
(right mouse click where the fields should be listed, add field).
"Kjell Brandes" wrote:
> doesnt work.
> This i a testquestion to look att the behaviour:
> CREATE PROCEDURE sp_testingReportsDeleteThis (@.arg1 varchar(100))
> AS
> declare @.sqlString varchar(800)
> set @.sqlString = "select firstname from tbl_personalData where firstname
> like '" +@.arg1 +"'"
> execute (@.sqlString )
> GO
> Hoping for this proc to return "firstname" when executing this as a proc
> with the command type set to Stored Proc...
> The report designer asks me for the @.arg1 no problem, the result of testing
> this syntax in "dataview" is exactly as expected. getting one col. full of
> names like the name inserted in @.arg1 with the name "firstname". But the
> fieldscolumn doesn't update.
> I succeded once to get the fields-area updated, I don't know what I did, but
> havent succeded since.
> Whats missing, is this a "feature", or should I read the manuals one more
> time'
> PLS help me!!
> regards
> Kjell Brandes
> PS.
> I have to have this query dynamic, the above code is a sample to describe
> the problem, not the actual productioncode...
>
>|||I do not know if this will help... but a suggestion onthe SP... try
something like this..It's simpler and doesn't make a second batch
CREATE PROCEDURE sp_testingReportsDeleteThis (@.arg1 varchar(100))
AS
select firstname from tbl_personalData where firstname like @.arg1
GO
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Kjell Brandes" <kjell@.brandes.tv> wrote in message
news:ekT0VBnwEHA.2016@.TK2MSFTNGP15.phx.gbl...
> doesnt work.
> This i a testquestion to look att the behaviour:
> CREATE PROCEDURE sp_testingReportsDeleteThis (@.arg1 varchar(100))
> AS
> declare @.sqlString varchar(800)
> set @.sqlString = "select firstname from tbl_personalData where firstname
> like '" +@.arg1 +"'"
> execute (@.sqlString )
> GO
> Hoping for this proc to return "firstname" when executing this as a proc
> with the command type set to Stored Proc...
> The report designer asks me for the @.arg1 no problem, the result of
testing
> this syntax in "dataview" is exactly as expected. getting one col. full of
> names like the name inserted in @.arg1 with the name "firstname". But the
> fieldscolumn doesn't update.
> I succeded once to get the fields-area updated, I don't know what I did,
but
> havent succeded since.
> Whats missing, is this a "feature", or should I read the manuals one more
> time'
> PLS help me!!
> regards
> Kjell Brandes
> PS.
> I have to have this query dynamic, the above code is a sample to describe
> the problem, not the actual productioncode...
>
>
Subscribe to:
Posts (Atom)