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...
>
>

No comments:

Post a Comment