Showing posts with label proc. Show all posts
Showing posts with label proc. Show all posts

Friday, March 23, 2012

Right click stored procedure - 'properties' option missing

Guys
Bizarre...using SQL Server Management Studio Express...v 9.0.2047
logged in as 'sa'
I right click a stored proc...i see options for...
- New
- Modify
- Execute
- Script
- View dependencies
- Rename
- Delete
- Refresh
...my 'Properties' option is GONE...DISAPPEARED...MISSING...
I want to be able to set permissions etc of the SP...which i can get
around with scripting, but it's a pain in the u know where...
Have searched around and cannot find anythingg that might tell me how
to re-enable etc...
Any ideas folks...!?
My list of dislikes for the new management studio is growing...this is
an example of two tools were better than 1...Gimme back enterprise
manager please!same problem here, did you find the solution ?
cheers
scott|||Scott wrote:
> same problem here, did you find the solution ?
> cheers
> scott
I'm having the same issue. I only noticed because my asp.net app which
is running in debug mode on my laptop is reporting that it can't see
the stored proc at all.
Right-click on the server machine on the sp name doesn't give me a
"properties" menu item...
Si|||Simon James wrote:
> Scott wrote:
> > same problem here, did you find the solution ?
> >
> > cheers
> > scott
> I'm having the same issue. I only noticed because my asp.net app which
> is running in debug mode on my laptop is reporting that it can't see
> the stored proc at all.
> Right-click on the server machine on the sp name doesn't give me a
> "properties" menu item...
> Si
No joy for me, so doing it the manual way, e.g. :
"grant execute on theStoredProcedureName to theUser" from the
management studio.
Si

Right click stored procedure - 'properties' option missing

Guys
Bizarre...using SQL Server Management Studio Express...v 9.0.2047
logged in as 'sa'
I right click a stored proc...i see options for...
- New
- Modify
- Execute
- Script
- View dependencies
- Rename
- Delete
- Refresh
...my 'Properties' option is GONE...DISAPPEARED...MISSING...
I want to be able to set permissions etc of the SP...which i can get
around with scripting, but it's a pain in the u know where...
Have searched around and cannot find anythingg that might tell me how
to re-enable etc...
Any ideas folks...!?
My list of dislikes for the new management studio is growing...this is
an example of two tools were better than 1...Gimme back enterprise
manager please!Scott wrote:
> same problem here, did you find the solution ?
> cheers
> scott
I'm having the same issue. I only noticed because my asp.net app which
is running in debug mode on my laptop is reporting that it can't see
the stored proc at all.
Right-click on the server machine on the sp name doesn't give me a
"properties" menu item...
Si|||Simon James wrote:
> Scott wrote:
> I'm having the same issue. I only noticed because my asp.net app which
> is running in debug mode on my laptop is reporting that it can't see
> the stored proc at all.
> Right-click on the server machine on the sp name doesn't give me a
> "properties" menu item...
> Si
No joy for me, so doing it the manual way, e.g. :
"grant execute on theStoredProcedureName to theUser" from the
management studio.
Si

Friday, March 9, 2012

Reusability & SSIS - issues they do not write in books about

I have a simple requirement:

Each package needs to have Error Handling - which needs to Execute a SQL statement. It's the same Stored Proc - where each package passes in its ID.

Ok - I get that part about creating a custom task and so on for reusabilty.
But - lets say that after deploying this task in 20 packages - I need to change the name of the Stored Proc.

What is going to happen in that case?

Correct me if I'm wrong - but after deploying the new version of the custom task - do I need to go to each package and update the reference to new version?Isn't this the purpose of package configurations?|||Not quite - configuration cannot handle when the processing logic changes. Lets say for instance in addition to ID input of the Stored Proc - the Custom task / Error handler --> you need to change it to accept System variable "PackageName".
--
Update:
Actually - come to think about it - in example mentioned above - Execute SQL task has been set with following expression:
"EXEC [dbo].[us_sp_Insert_STG_FEED_EVENT_LOG] @.FEED_ID= " + (DT_WSTR,10) @.[User::FEED_ID] + ", @.FEED_EVENT_LOG_TYPE_ID = 3, @.STARTED_ON = '"+(DT_WSTR,30)@.[System::StartTime] +"', @.ENDED_ON = NULL, @.message = 'Package failed. ErrorCode: "+(DT_WSTR,12)@.[System::ErrorCode]+" ErrorMsg: "+REPLACE(REPLACE(@.[System::ErrorDescription],"\"",""),"'","")+"', @.FILES_PROCESSED = NULL, @.PKG_EXECUTION_ID = '" + @.[System::ExecutionInstanceGUID] + "'"

So I suppose - when I need to change it - I can put it in Config.

Thanks|||

TheViewMaster wrote:

Not quite - configuration cannot handle when the processing logic changes. Lets say for instance in addition to ID input of the Stored Proc - the Custom task / Error handler --> you need to change it to accept System variable "PackageName".

So what is your question exactly? If you are changing from ID (perhaps a user variable) to a system variable, then yes, you'll have to update all of the packages. Just as you would have to do if you needed to add another column to the data flow. I don't get it, I guess.|||Allrite - another scenario:

We have a common Script to extract data from XML which works with X number of packages (currently x=5).

So how do you make this script reusable in a way that when you need to make a change in script - all the packages which use the old script get automatically updated.|||

TheViewMaster wrote:

Allrite - another scenario:

We have a common Script to extract data from XML which works with X number of packages (currently x=5).

So how do you make this script reusable in a way that when you need to make a change in script - all the packages which use the old script get automatically updated.

As in a script component? You have a vb.net script that you want to make portable?|||

Hi ViewMaster,

You may want to look into extending SSIS.

You could create an object with all items subject to change (stored procedure names, etc.) stored in package variables and manage the variables in package configurations.

There are a couple books out already that describe this and at least one on the way that is solely dedicated to this subject. Another good resource for information about extending SSIS is SQLIS.com.

Hope this helps,
Andy

|||I think for what you want to do you have to save your script in a legitimate VB 2005 class library and register that class library with the CLR so you can reference it from your packages.

But that really just means that there isn't really any simple way to reuse code throughout SSIS packages, other than the dreadedly inefficient cut and paste.

For an OO developer like me that's a really really big frustration.|||

Correct me if I'm wrong - but after deploying the new version of the custom task - do I need to go to each package and update the reference to new version?

It depends if you change the strong name key of the task, the most obvious way of doing that is to change the assembly version. So don't change it and your are fine, and do not need to touch the packages. I use the AssemblyFileVersion attribute to give some visibility of my versions, whilst maintaining complete compatability.

You could also consider logging, and if the standard stuff does not work, write your own log provider, which could call your stored proc. The log provider is referenced in each package, but is obviously external in much the same way as the task code is in an external assembly, and in this case it may make more sense.

(There is a description of how to use assembly versions or not, page 431, para 3, Profession SQL Server 2005 IS, Wrox.)

|||

Jon Limjap wrote:

I think for what you want to do you have to save your script in a legitimate VB 2005 class library and register that class library with the CLR so you can reference it from your packages.

But that really just means that there isn't really any simple way to reuse code throughout SSIS packages, other than the dreadedly inefficient cut and paste.

For an OO developer like me that's a really really big frustration.

Yep exactly what I meant.

After developing with SSIS for awhile - I really try to keep things simple - by basically using only SQL, Script and Data Flow (mostly limited to importing data to sql staging tables) tasks.

Just the last package i wrote had 2 script tasks which were exactly identical - taking in variable and processing the same way. Since I doubt that this exact script will be used in other packages - it doesnt make to go through the hassle of putting it into gac.

I think what I'm asking is same as with DTS - ability to have "Global" functions - which can be created in 1 place of package and reused through out.
And then possibly be able to promote those Global functions to be used in other packages also|||

TheViewMaster wrote:

Jon Limjap wrote:

I think for what you want to do you have to save your script in a legitimate VB 2005 class library and register that class library with the CLR so you can reference it from your packages.

But that really just means that there isn't really any simple way to reuse code throughout SSIS packages, other than the dreadedly inefficient cut and paste.

For an OO developer like me that's a really really big frustration.

Yep exactly what I meant.

After developing with SSIS for awhile - I really try to keep things simple - by basically using only SQL, Script and Data Flow (mostly limited to importing data to sql staging tables) tasks.

Just the last package i wrote had 2 script tasks which were exactly identical - taking in variable and processing the same way. Since I doubt that this exact script will be used in other packages - it doesnt make to go through the hassle of putting it into gac.

If it does not make sense to make it a reusable component then why have you written this thread in the first place? I think you are saying that you want toreuse some custom code that you have written. So OK, make it a custom task. Why is putting it into the GAC such a problem? Where else would you put it? Wherever you put it you still have to go through the rigmarole of putting it SOMEWHERE, so why is putting it in the GAC any more or less of a problem than anywhere else?

TheViewMaster wrote:

I think what I'm asking is same as with DTS - ability to have "Global" functions - which can be created in 1 place of package and reused through out.
And then possibly be able to promote those Global functions to be used in other packages also

What you are describing is the ability to reuse tasks that you have configured yourself without having to write a custom task. So a scenario may be:

"I am using a Web Service Task that calls a web service. I am going to want to call that Web Service from many packages so why should I bother dragging on another web service task and configuring it the same, why not just drag on the old one that I have already built?"

Currently the only way to do this is to build a custom task - you want a way of distributing pre-configured tasks that you can (and this is the key) instantiate in various places. A change to the base task will occur anywhere that that task is instantiated. What we have described is exactly how a rival product, Informatica, works and when I first saw SSIS 3 years ago I was disappointed that it didn't work in the same way. And I said so:

Libraries of tasks and transformations
(http://blogs.conchango.com/jamiethomson/archive/2005/02/05/929.aspx)

Combining multiple components into a single distributable component via the SSIS Designer
(http://blogs.conchango.com/jamiethomson/archive/2005/05/26/SSIS_3A00_-Combining-multiple-components-into-a-single-distributable-component-via-the-SSIS-Designer.aspx)

Don't expect reuse of tasks in Katmai though - it won't happen. Having said that, look forward to something equally as interesting - reuse of components (or groups of components).

-Jamie

|||

Jon Limjap wrote:

I think for what you want to do you have to save your script in a legitimate VB 2005 class library and register that class library with the CLR so you can reference it from your packages.

But that really just means that there isn't really any simple way to reuse code throughout SSIS packages, other than the dreadedly inefficient cut and paste.

Really? It sounds to me like you've just described one.

By the way, in that scenario you are not constrained to writing your assembly in VB. Assemblies are of course object code so it doesn't matter what language you write them in.

-Jamie

|||

Jamie Thomson wrote:

If it does not make sense to make it a reusable component then why have you written this thread in the first place? I think you are saying that you want toreuse some custom code that you have written. So OK, make it a custom task. Why is putting it into the GAC such a problem? Where else would you put it? Wherever you put it you still have to go through the rigmarole of putting it SOMEWHERE, so why is putting it in the GAC any more or less of a problem than anywhere else?

Q: Why is custom task or code in GAC a problem?
A: Manageability - the more custom code & tasks you have - it will be problemsome to upgrade custom components and also - when you need to "move" your solution to another SQL box (which we may have to do when we roll out the new website).

I am already using "Trash Destination" component and Custom Filter Duplicates based on Key Column(s) transform - but I'm a little cautious to add more external components to SSIS. And as stated in the statement - potentially the repeating code will be in the same package - 2 or 3 tasks - in which case copy&paste outweighs of custom task

Jamie Thomson wrote:

What you are describing is the ability to reuse tasks that you have configured yourself without having to write a custom task. So a scenario may be:

"I am using a Web Service Task that calls a web service. I am going to want to call that Web Service from many packages so why should I bother dragging on another web service task and configuring it the same, why not just drag on the old one that I have already built?"

Currently the only way to do this is to build a custom task - you want a way of distributing pre-configured tasks that you can (and this is the key) instantiate in various places. A change to the base task will occur anywhere that that task is instantiated. What we have described is exactly how a rival product, Informatica, works and when I first saw SSIS 3 years ago I was disappointed that it didn't work in the same way. And I said so:

Libraries of tasks and transformations
(http://blogs.conchango.com/jamiethomson/archive/2005/02/05/929.aspx)

Combining multiple components into a single distributable component via the SSIS Designer
(http://blogs.conchango.com/jamiethomson/archive/2005/05/26/SSIS_3A00_-Combining-multiple-components-into-a-single-distributable-component-via-the-SSIS-Designer.aspx)

Don't expect reuse of tasks in Katmai though - it won't happen. Having said that, look forward to something equally as interesting - reuse of components (or groups of components).

-Jamie

Amen brother, good stuff
I do not see where Alaska comes into play with reusing the tasks - but I'll look forward to reuse of components |||

Jamie Thomson wrote:

Jon Limjap wrote:

I think for what you want to do you have to save your script in a legitimate VB 2005 class library and register that class library with the CLR so you can reference it from your packages.

But that really just means that there isn't really any simple way to reuse code throughout SSIS packages, other than the dreadedly inefficient cut and paste.

Really? It sounds to me like you've just described one.

By the way, in that scenario you are not constrained to writing your assembly in VB. Assemblies are of course object code so it doesn't matter what language you write them in.

-Jamie

Well, again its not simple. Once I compile my class library and register it to the GAC, I can't step through its code anymore.

And while cut and paste works sometimes, what if I've peppered my package with a recurring script, and then find a serious flaw with that code much later? I'll have to go back to each and every script task I've pasted the code in -- and repaste, retest, etc.

It's laborious, and inefficient, any way you put it, not to mention that cutting and pasting per se is very, very error prone.|||

Jon Limjap wrote:

Well, again its not simple. Once I compile my class library and register it to the GAC, I can't step through its code anymore.

Have you tried using the Debug features of VS? For simple testing I'd set Debug Start actions to external program, dtexec, and command line arguments to run a package that uses the class in script. Rather like I'd do for custom component or task development. Faster for checing run-time stuff than attaching to a process by hand.

Jon Limjap wrote:

And while cut and paste works sometimes, what if I've peppered my package with a recurring script, and then find a serious flaw with that code much later? I'll have to go back to each and every script task I've pasted the code in -- and repaste, retest, etc.

Sounds like an argument for custom tasks. If you use the same code more than a few times I think it should be a task, for just that sort of reason.

Reusability & SSIS - issues they do not write in books about

I have a simple requirement:

Each package needs to have Error Handling - which needs to Execute a SQL statement. It's the same Stored Proc - where each package passes in its ID.

Ok - I get that part about creating a custom task and so on for reusabilty.
But - lets say that after deploying this task in 20 packages - I need to change the name of the Stored Proc.

What is going to happen in that case?

Correct me if I'm wrong - but after deploying the new version of the custom task - do I need to go to each package and update the reference to new version?Isn't this the purpose of package configurations?|||Not quite - configuration cannot handle when the processing logic changes. Lets say for instance in addition to ID input of the Stored Proc - the Custom task / Error handler --> you need to change it to accept System variable "PackageName".
--
Update:
Actually - come to think about it - in example mentioned above - Execute SQL task has been set with following expression:
"EXEC [dbo].[us_sp_Insert_STG_FEED_EVENT_LOG] @.FEED_ID= " + (DT_WSTR,10) @.[User::FEED_ID] + ", @.FEED_EVENT_LOG_TYPE_ID = 3, @.STARTED_ON = '"+(DT_WSTR,30)@.[System::StartTime] +"', @.ENDED_ON = NULL, @.message = 'Package failed. ErrorCode: "+(DT_WSTR,12)@.[System::ErrorCode]+" ErrorMsg: "+REPLACE(REPLACE(@.[System::ErrorDescription],"\"",""),"'","")+"', @.FILES_PROCESSED = NULL, @.PKG_EXECUTION_ID = '" + @.[System::ExecutionInstanceGUID] + "'"

So I suppose - when I need to change it - I can put it in Config.

Thanks|||

TheViewMaster wrote:

Not quite - configuration cannot handle when the processing logic changes. Lets say for instance in addition to ID input of the Stored Proc - the Custom task / Error handler --> you need to change it to accept System variable "PackageName".

So what is your question exactly? If you are changing from ID (perhaps a user variable) to a system variable, then yes, you'll have to update all of the packages. Just as you would have to do if you needed to add another column to the data flow. I don't get it, I guess.|||Allrite - another scenario:

We have a common Script to extract data from XML which works with X number of packages (currently x=5).

So how do you make this script reusable in a way that when you need to make a change in script - all the packages which use the old script get automatically updated.|||

TheViewMaster wrote:

Allrite - another scenario:

We have a common Script to extract data from XML which works with X number of packages (currently x=5).

So how do you make this script reusable in a way that when you need to make a change in script - all the packages which use the old script get automatically updated.

As in a script component? You have a vb.net script that you want to make portable?|||

Hi ViewMaster,

You may want to look into extending SSIS.

You could create an object with all items subject to change (stored procedure names, etc.) stored in package variables and manage the variables in package configurations.

There are a couple books out already that describe this and at least one on the way that is solely dedicated to this subject. Another good resource for information about extending SSIS is SQLIS.com.

Hope this helps,
Andy

|||I think for what you want to do you have to save your script in a legitimate VB 2005 class library and register that class library with the CLR so you can reference it from your packages.

But that really just means that there isn't really any simple way to reuse code throughout SSIS packages, other than the dreadedly inefficient cut and paste.

For an OO developer like me that's a really really big frustration.|||

Correct me if I'm wrong - but after deploying the new version of the custom task - do I need to go to each package and update the reference to new version?

It depends if you change the strong name key of the task, the most obvious way of doing that is to change the assembly version. So don't change it and your are fine, and do not need to touch the packages. I use the AssemblyFileVersion attribute to give some visibility of my versions, whilst maintaining complete compatability.

You could also consider logging, and if the standard stuff does not work, write your own log provider, which could call your stored proc. The log provider is referenced in each package, but is obviously external in much the same way as the task code is in an external assembly, and in this case it may make more sense.

(There is a description of how to use assembly versions or not, page 431, para 3, Profession SQL Server 2005 IS, Wrox.)

|||

Jon Limjap wrote:

I think for what you want to do you have to save your script in a legitimate VB 2005 class library and register that class library with the CLR so you can reference it from your packages.

But that really just means that there isn't really any simple way to reuse code throughout SSIS packages, other than the dreadedly inefficient cut and paste.

For an OO developer like me that's a really really big frustration.

Yep exactly what I meant.

After developing with SSIS for awhile - I really try to keep things simple - by basically using only SQL, Script and Data Flow (mostly limited to importing data to sql staging tables) tasks.

Just the last package i wrote had 2 script tasks which were exactly identical - taking in variable and processing the same way. Since I doubt that this exact script will be used in other packages - it doesnt make to go through the hassle of putting it into gac.

I think what I'm asking is same as with DTS - ability to have "Global" functions - which can be created in 1 place of package and reused through out.
And then possibly be able to promote those Global functions to be used in other packages also|||

TheViewMaster wrote:

Jon Limjap wrote:

I think for what you want to do you have to save your script in a legitimate VB 2005 class library and register that class library with the CLR so you can reference it from your packages.

But that really just means that there isn't really any simple way to reuse code throughout SSIS packages, other than the dreadedly inefficient cut and paste.

For an OO developer like me that's a really really big frustration.

Yep exactly what I meant.

After developing with SSIS for awhile - I really try to keep things simple - by basically using only SQL, Script and Data Flow (mostly limited to importing data to sql staging tables) tasks.

Just the last package i wrote had 2 script tasks which were exactly identical - taking in variable and processing the same way. Since I doubt that this exact script will be used in other packages - it doesnt make to go through the hassle of putting it into gac.

If it does not make sense to make it a reusable component then why have you written this thread in the first place? I think you are saying that you want toreuse some custom code that you have written. So OK, make it a custom task. Why is putting it into the GAC such a problem? Where else would you put it? Wherever you put it you still have to go through the rigmarole of putting it SOMEWHERE, so why is putting it in the GAC any more or less of a problem than anywhere else?

TheViewMaster wrote:

I think what I'm asking is same as with DTS - ability to have "Global" functions - which can be created in 1 place of package and reused through out.
And then possibly be able to promote those Global functions to be used in other packages also

What you are describing is the ability to reuse tasks that you have configured yourself without having to write a custom task. So a scenario may be:

"I am using a Web Service Task that calls a web service. I am going to want to call that Web Service from many packages so why should I bother dragging on another web service task and configuring it the same, why not just drag on the old one that I have already built?"

Currently the only way to do this is to build a custom task - you want a way of distributing pre-configured tasks that you can (and this is the key) instantiate in various places. A change to the base task will occur anywhere that that task is instantiated. What we have described is exactly how a rival product, Informatica, works and when I first saw SSIS 3 years ago I was disappointed that it didn't work in the same way. And I said so:

Libraries of tasks and transformations
(http://blogs.conchango.com/jamiethomson/archive/2005/02/05/929.aspx)

Combining multiple components into a single distributable component via the SSIS Designer
(http://blogs.conchango.com/jamiethomson/archive/2005/05/26/SSIS_3A00_-Combining-multiple-components-into-a-single-distributable-component-via-the-SSIS-Designer.aspx)

Don't expect reuse of tasks in Katmai though - it won't happen. Having said that, look forward to something equally as interesting - reuse of components (or groups of components).

-Jamie

|||

Jon Limjap wrote:

I think for what you want to do you have to save your script in a legitimate VB 2005 class library and register that class library with the CLR so you can reference it from your packages.

But that really just means that there isn't really any simple way to reuse code throughout SSIS packages, other than the dreadedly inefficient cut and paste.

Really? It sounds to me like you've just described one.

By the way, in that scenario you are not constrained to writing your assembly in VB. Assemblies are of course object code so it doesn't matter what language you write them in.

-Jamie

|||

Jamie Thomson wrote:

If it does not make sense to make it a reusable component then why have you written this thread in the first place? I think you are saying that you want toreuse some custom code that you have written. So OK, make it a custom task. Why is putting it into the GAC such a problem? Where else would you put it? Wherever you put it you still have to go through the rigmarole of putting it SOMEWHERE, so why is putting it in the GAC any more or less of a problem than anywhere else?

Q: Why is custom task or code in GAC a problem?
A: Manageability - the more custom code & tasks you have - it will be problemsome to upgrade custom components and also - when you need to "move" your solution to another SQL box (which we may have to do when we roll out the new website).

I am already using "Trash Destination" component and Custom Filter Duplicates based on Key Column(s) transform - but I'm a little cautious to add more external components to SSIS. And as stated in the statement - potentially the repeating code will be in the same package - 2 or 3 tasks - in which case copy&paste outweighs of custom task

Jamie Thomson wrote:

What you are describing is the ability to reuse tasks that you have configured yourself without having to write a custom task. So a scenario may be:

"I am using a Web Service Task that calls a web service. I am going to want to call that Web Service from many packages so why should I bother dragging on another web service task and configuring it the same, why not just drag on the old one that I have already built?"

Currently the only way to do this is to build a custom task - you want a way of distributing pre-configured tasks that you can (and this is the key) instantiate in various places. A change to the base task will occur anywhere that that task is instantiated. What we have described is exactly how a rival product, Informatica, works and when I first saw SSIS 3 years ago I was disappointed that it didn't work in the same way. And I said so:

Libraries of tasks and transformations
(http://blogs.conchango.com/jamiethomson/archive/2005/02/05/929.aspx)

Combining multiple components into a single distributable component via the SSIS Designer
(http://blogs.conchango.com/jamiethomson/archive/2005/05/26/SSIS_3A00_-Combining-multiple-components-into-a-single-distributable-component-via-the-SSIS-Designer.aspx)

Don't expect reuse of tasks in Katmai though - it won't happen. Having said that, look forward to something equally as interesting - reuse of components (or groups of components).

-Jamie

Amen brother, good stuff
I do not see where Alaska comes into play with reusing the tasks - but I'll look forward to reuse of components |||

Jamie Thomson wrote:

Jon Limjap wrote:

I think for what you want to do you have to save your script in a legitimate VB 2005 class library and register that class library with the CLR so you can reference it from your packages.

But that really just means that there isn't really any simple way to reuse code throughout SSIS packages, other than the dreadedly inefficient cut and paste.

Really? It sounds to me like you've just described one.

By the way, in that scenario you are not constrained to writing your assembly in VB. Assemblies are of course object code so it doesn't matter what language you write them in.

-Jamie

Well, again its not simple. Once I compile my class library and register it to the GAC, I can't step through its code anymore.

And while cut and paste works sometimes, what if I've peppered my package with a recurring script, and then find a serious flaw with that code much later? I'll have to go back to each and every script task I've pasted the code in -- and repaste, retest, etc.

It's laborious, and inefficient, any way you put it, not to mention that cutting and pasting per se is very, very error prone.|||

Jon Limjap wrote:

Well, again its not simple. Once I compile my class library and register it to the GAC, I can't step through its code anymore.

Have you tried using the Debug features of VS? For simple testing I'd set Debug Start actions to external program, dtexec, and command line arguments to run a package that uses the class in script. Rather like I'd do for custom component or task development. Faster for checing run-time stuff than attaching to a process by hand.

Jon Limjap wrote:

And while cut and paste works sometimes, what if I've peppered my package with a recurring script, and then find a serious flaw with that code much later? I'll have to go back to each and every script task I've pasted the code in -- and repaste, retest, etc.

Sounds like an argument for custom tasks. If you use the same code more than a few times I think it should be a task, for just that sort of reason.

Returning/storing a value for use in a stored proc.

Hi:
I have a stored procedure which performs an insert statement. At the
conclusion of the insert, I have SELECT SCOPE_IDENTITY(). Now, I want to be
able to use this value for the next stored procedure (which will then perfor
m
an update on the newly inserted record). Here's an example:
--Step #1:
Execute spCCD @.COMPANY_ID
--which looks like this:
CREATE PROCEDURE [dbo].[spSTMNT_CCDPPD]
@.Company_ID
Declare @.STMNT_ID int
AS
Insert Into STMNT (
COMPANY_ID,
Tran_Fee1,
Tran_Fee2
)
Values (
@.COMPANY_ID,
0.15,
0.25
)
Set @.STMNT_ID = (SELECT SCOPE_IDENTITY())
--Step #2
Execute spVoid @.STMNT_ID
---
So calling the stored procedures will look like this:
Execute spSTMNT_CCDPPD @.COMPANY_ID --this will return @.STMNT_ID
Execute spVoid @.STMNT_IDEric,
Use an output parameter.
CREATE PROCEDURE [dbo].[spSTMNT_CCDPPD]
@.Company_ID,
@.STMNT_ID int output
AS
set nocount on
Insert Into STMNT (
COMPANY_ID,
Tran_Fee1,
Tran_Fee2
)
Values (
@.COMPANY_ID,
0.15,
0.25
)
Set @.STMNT_ID = SCOPE_IDENTITY()
go
declare @.STMNT_ID int
Execute spSTMNT_CCDPPD @.COMPANY_ID, @.STMNT_ID output
Execute spVoid @.STMNT_ID
go
Remember to handle errors.
AMB
"Eric" wrote:

> Hi:
> I have a stored procedure which performs an insert statement. At the
> conclusion of the insert, I have SELECT SCOPE_IDENTITY(). Now, I want to
be
> able to use this value for the next stored procedure (which will then perf
orm
> an update on the newly inserted record). Here's an example:
> --Step #1:
> Execute spCCD @.COMPANY_ID
> --which looks like this:
> CREATE PROCEDURE [dbo].[spSTMNT_CCDPPD]
> @.Company_ID
> Declare @.STMNT_ID int
> AS
> Insert Into STMNT (
> COMPANY_ID,
> Tran_Fee1,
> Tran_Fee2
> )
> Values (
> @.COMPANY_ID,
> 0.15,
> 0.25
> )
> Set @.STMNT_ID = (SELECT SCOPE_IDENTITY())
> --Step #2
> Execute spVoid @.STMNT_ID
> ---
> So calling the stored procedures will look like this:
> Execute spSTMNT_CCDPPD @.COMPANY_ID --this will return @.STMNT_ID
> Execute spVoid @.STMNT_ID
>|||Correction,

> @.Company_ID,
CREATE PROCEDURE [dbo].[spSTMNT_CCDPPD]
@.Company_ID int,
@.STMNT_ID int output
AS
set nocount on
Insert Into STMNT (
COMPANY_ID,
Tran_Fee1,
Tran_Fee2
)
Values (
@.COMPANY_ID,
0.15,
0.25
)
Set @.STMNT_ID = SCOPE_IDENTITY()
go
declare @.COMPANY_ID int
declare @.STMNT_ID int
set @.COMPANY_ID = 123
Execute spSTMNT_CCDPPD @.COMPANY_ID, @.STMNT_ID output
Execute spVoid @.STMNT_ID
go
AMB
"Alejandro Mesa" wrote:
> Eric,
> Use an output parameter.
> CREATE PROCEDURE [dbo].[spSTMNT_CCDPPD]
> @.Company_ID,
> @.STMNT_ID int output
> AS
> set nocount on
> Insert Into STMNT (
> COMPANY_ID,
> Tran_Fee1,
> Tran_Fee2
> )
> Values (
> @.COMPANY_ID,
> 0.15,
> 0.25
> )
> Set @.STMNT_ID = SCOPE_IDENTITY()
> go
> declare @.STMNT_ID int
> Execute spSTMNT_CCDPPD @.COMPANY_ID, @.STMNT_ID output
> Execute spVoid @.STMNT_ID
> go
> Remember to handle errors.
>
> AMB
> "Eric" wrote:
>

Wednesday, March 7, 2012

Returning values from a stored procedure - Help needed!

Hello everyone,
I'm using the following procedure to return the result of a zip code
radius search at my website. As it is, the proc is working fine except
I'm having a problem returning a value for the distance between 2
points. The procedure calculates the distance between the 2 points and
compares it in the following select statement
SELECT @.Result as [Result], bsID, bsFirstName, bsAge, bsIntsection,
bsStartWage, bsStatus FROM tbSitters WHERE bsZipCode in (SELECT ZipCode
FROM tbZip WHERE @.distance > 3959 * ACOS(SIN(@.lat/57.3) *
SIN(Latitude/57.3) + COS(@.lat/57.3) * COS(Latitude/57.3) *
COS((Longitude/57.3) - (@.lng/57.3))) )
end;
BROKEN DOWN
****@.distance is the distance inputed by a user (form post - value up
to 20 miles) and this formula calculates the distance between 2
points*****
>3959 * ACOS(SIN(@.lat/57.3) * SIN(Latitude/57.3) + COS(@.lat/57.3) * COS(Latitude/57.
3) * COS((Longitude/57.3) - (@.lng/57.3)))
****Now what I need to know is how can i return this distance value
through the procedure.
(3959 * ACOS(SIN(@.lat/57.3) * SIN(Latitude/57.3) + COS(@.lat/57.3) *
COS(Latitude/57.3) * COS((Longitude/57.3) - (@.lng/57.3))))
---
Following is the complete proc
---
CREATE PROCEDURE dbo.psFindSitters1
(@.zipcode char(7),
@.distance int
)
AS
SET NOCOUNT ON
Declare @.Result varchar(90)
Declare @.lat decimal(9,6)
Declare @.lng decimal(9,6)
Declare @.lat1 decimal(9,6)
Declare @.lng1 decimal(9,6)
Declare @.Latitude decimal(9,6)
Declare @.Longitude decimal(9,6)
Declare @.count int
Declare @.distance1 int
Declare @.distance2 int
set @.Result = 'err';
--find the parent
if (@.zipcode<>0) begin --find LAT and LNG
select @.lat=[Latitude],@.lng=[Longitude] FROM tbZip WHERE ZipCode =
@.zipcode
end;
if (@.lat<> 0) begin --another query
SELECT @.count=count(*) FROM tbSitters WHERE bsZipCode in (SELECT
ZipCode FROM tbZip WHERE @.distance > 3959 * ACOS(SIN(@.lat/57.3) *
SIN(Latitude/57.3) + COS(@.lat/57.3) * COS(Latitude/57.3) *
COS((Longitude/57.3) - (@.lng/57.3))) )
end;
if (@.count > 0) begin --another query
set @.Result = 'user';
SELECT @.Result as [Result], bsID, bsFirstName, bsAge, bsIntsection,
bsStartWage, bsStatus FROM tbSitters WHERE bsZipCode in (SELECT ZipCode
FROM tbZip WHERE @.distance > 3959 * ACOS(SIN(@.lat/57.3) *
SIN(Latitude/57.3) + COS(@.lat/57.3) * COS(Latitude/57.3) *
COS((Longitude/57.3) - (@.lng/57.3))) )
end;
if (@.lat is null or @.lat=0 or @.count is null or @.count=0) begin
set @.Result = 'nouser';
select @.Result as [Result];
--GoTo hasErr;
end;
GO
Thanks in advance for any help!
RobertIf you want the distance to sitter returned in the (table) result set, join
tbSitters to tbZip
(*untested*)
if (@.count > 0) begin --another query
set @.Result = 'user';
SELECT @.Result as [Result], s.bsID, s.bsFirstName, s.bsAge, s.bsIntsection,
s.bsStartWage, s.bsStatus,
(3959 * ACOS(SIN(@.lat/57.3) * SIN(z.Latitude/57.3) + COS(@.lat/57.3) *
COS(z.Latitude/57.3) * COS((z.Longitude/57.3) - (@.lng/57.3)))) AS "Distance"
FROM tbSitters s INNER JOIN tbZip z ON s.bsZipCode = z.ZipCode
WHERE s.bsZipCode in (SELECT ZipCode
FROM tbZip WHERE @.distance > 3959 * ACOS(SIN(@.lat/57.3) *
SIN(Latitude/57.3) + COS(@.lat/57.3) * COS(Latitude/57.3) *
COS((Longitude/57.3) - (@.lng/57.3))) )
end;
"ROBinBRAMPTON" wrote:

> Hello everyone,
> I'm using the following procedure to return the result of a zip code
> radius search at my website. As it is, the proc is working fine except
> I'm having a problem returning a value for the distance between 2
> points. The procedure calculates the distance between the 2 points and
> compares it in the following select statement
> SELECT @.Result as [Result], bsID, bsFirstName, bsAge, bsIntsection,
> bsStartWage, bsStatus FROM tbSitters WHERE bsZipCode in (SELECT ZipCode
> FROM tbZip WHERE @.distance > 3959 * ACOS(SIN(@.lat/57.3) *
> SIN(Latitude/57.3) + COS(@.lat/57.3) * COS(Latitude/57.3) *
> COS((Longitude/57.3) - (@.lng/57.3))) )
> end;
> BROKEN DOWN
> ****@.distance is the distance inputed by a user (form post - value up
> to 20 miles) and this formula calculates the distance between 2
> points*****
> ****Now what I need to know is how can i return this distance value
> through the procedure.
> (3959 * ACOS(SIN(@.lat/57.3) * SIN(Latitude/57.3) + COS(@.lat/57.3) *
> COS(Latitude/57.3) * COS((Longitude/57.3) - (@.lng/57.3))))
> ---
> Following is the complete proc
> ---
> CREATE PROCEDURE dbo.psFindSitters1
> (@.zipcode char(7),
> @.distance int
> )
> AS
> SET NOCOUNT ON
> Declare @.Result varchar(90)
> Declare @.lat decimal(9,6)
> Declare @.lng decimal(9,6)
> Declare @.lat1 decimal(9,6)
> Declare @.lng1 decimal(9,6)
> Declare @.Latitude decimal(9,6)
> Declare @.Longitude decimal(9,6)
> Declare @.count int
> Declare @.distance1 int
> Declare @.distance2 int
> set @.Result = 'err';
> --find the parent
> if (@.zipcode<>0) begin --find LAT and LNG
> select @.lat=[Latitude],@.lng=[Longitude] FROM tbZip WHERE ZipCode =
> @.zipcode
> end;
> if (@.lat<> 0) begin --another query
> SELECT @.count=count(*) FROM tbSitters WHERE bsZipCode in (SELECT
> ZipCode FROM tbZip WHERE @.distance > 3959 * ACOS(SIN(@.lat/57.3) *
> SIN(Latitude/57.3) + COS(@.lat/57.3) * COS(Latitude/57.3) *
> COS((Longitude/57.3) - (@.lng/57.3))) )
> end;
>
> if (@.count > 0) begin --another query
> set @.Result = 'user';
> SELECT @.Result as [Result], bsID, bsFirstName, bsAge, bsIntsection,
> bsStartWage, bsStatus FROM tbSitters WHERE bsZipCode in (SELECT ZipCode
> FROM tbZip WHERE @.distance > 3959 * ACOS(SIN(@.lat/57.3) *
> SIN(Latitude/57.3) + COS(@.lat/57.3) * COS(Latitude/57.3) *
> COS((Longitude/57.3) - (@.lng/57.3))) )
> end;
> if (@.lat is null or @.lat=0 or @.count is null or @.count=0) begin
> set @.Result = 'nouser';
> select @.Result as [Result];
> --GoTo hasErr;
> end;
>
> GO
> Thanks in advance for any help!
> Robert
>|||It worked perfectly!
Thanks very much Mark
Robert
p.s. If you're a parent in need of a sitter? Open an account then drop
me an email at admin at phone a babysitter dot com, and I'll upgrade it
for you as way way to express my gratitude.|||Also consider a re-write of the procedure using a temporary table
CREATE PROCEDURE dbo.psFindSitters1
(@.zipcode char(7),
@.distance int
)
AS
SET NOCOUNT ON
Declare @.Result varchar(90)
Declare @.lat decimal(9,6)
Declare @.lng decimal(9,6)
Declare @.lat1 decimal(9,6)
Declare @.lng1 decimal(9,6)
Declare @.Latitude decimal(9,6)
Declare @.Longitude decimal(9,6)
Declare @.count int
Declare @.distance1 int
Declare @.distance2 int
set @.Result = 'err';
--find the parent
if (@.zipcode<>0) begin --find LAT and LNG
select @.lat=[Latitude],@.lng=[Longitude] FROM tbZip WHERE ZipCode =
@.zipcode
end;
if (@.lat<> 0) begin --another query
SELECT ZipCode INTO #zipsinrange
FROM tbZip WHERE @.distance > 3959 * ACOS(SIN(@.lat/57.3) *
SIN(Latitude/57.3) + COS(@.lat/57.3) * COS(Latitude/57.3) *
COS((Longitude/57.3) - (@.lng/57.3))) )
set @.count = @.@.ROWCOUNT
end;
if (@.count > 0) begin --another query
set @.Result = 'user';
SELECT @.Result as [Result], s.bsID, s.bsFirstName, s.bsAge, s.bsIntsection,
s.bsStartWage, s.bsStatus,
(3959 * ACOS(SIN(@.lat/57.3) * SIN(z.Latitude/57.3) + COS(@.lat/57.3) *
COS(z.Latitude/57.3) * COS((z.Longitude/57.3) - (@.lng/57.3)))) AS "Distance"
FROM tbSitters s INNER JOIN #zipsinrange r ON s.bsZipCode = r.ZipCode
INNER JOIN tblZip z ON z.ZipCode = r.ZipCode
end;
if (@.lat is null or @.lat=0 or @.count is null or @.count=0) begin
set @.Result = 'nouser';
select @.Result as [Result];
--GoTo hasErr;
end;
GO
"ROBinBRAMPTON" wrote:

> Hello everyone,
> I'm using the following procedure to return the result of a zip code
> radius search at my website. As it is, the proc is working fine except
> I'm having a problem returning a value for the distance between 2
> points. The procedure calculates the distance between the 2 points and
> compares it in the following select statement
> SELECT @.Result as [Result], bsID, bsFirstName, bsAge, bsIntsection,
> bsStartWage, bsStatus FROM tbSitters WHERE bsZipCode in (SELECT ZipCode
> FROM tbZip WHERE @.distance > 3959 * ACOS(SIN(@.lat/57.3) *
> SIN(Latitude/57.3) + COS(@.lat/57.3) * COS(Latitude/57.3) *
> COS((Longitude/57.3) - (@.lng/57.3))) )
> end;
> BROKEN DOWN
> ****@.distance is the distance inputed by a user (form post - value up
> to 20 miles) and this formula calculates the distance between 2
> points*****
> ****Now what I need to know is how can i return this distance value
> through the procedure.
> (3959 * ACOS(SIN(@.lat/57.3) * SIN(Latitude/57.3) + COS(@.lat/57.3) *
> COS(Latitude/57.3) * COS((Longitude/57.3) - (@.lng/57.3))))
> ---
> Following is the complete proc
> ---
> CREATE PROCEDURE dbo.psFindSitters1
> (@.zipcode char(7),
> @.distance int
> )
> AS
> SET NOCOUNT ON
> Declare @.Result varchar(90)
> Declare @.lat decimal(9,6)
> Declare @.lng decimal(9,6)
> Declare @.lat1 decimal(9,6)
> Declare @.lng1 decimal(9,6)
> Declare @.Latitude decimal(9,6)
> Declare @.Longitude decimal(9,6)
> Declare @.count int
> Declare @.distance1 int
> Declare @.distance2 int
> set @.Result = 'err';
> --find the parent
> if (@.zipcode<>0) begin --find LAT and LNG
> select @.lat=[Latitude],@.lng=[Longitude] FROM tbZip WHERE ZipCode =
> @.zipcode
> end;
> if (@.lat<> 0) begin --another query
> SELECT @.count=count(*) FROM tbSitters WHERE bsZipCode in (SELECT
> ZipCode FROM tbZip WHERE @.distance > 3959 * ACOS(SIN(@.lat/57.3) *
> SIN(Latitude/57.3) + COS(@.lat/57.3) * COS(Latitude/57.3) *
> COS((Longitude/57.3) - (@.lng/57.3))) )
> end;
>
> if (@.count > 0) begin --another query
> set @.Result = 'user';
> SELECT @.Result as [Result], bsID, bsFirstName, bsAge, bsIntsection,
> bsStartWage, bsStatus FROM tbSitters WHERE bsZipCode in (SELECT ZipCode
> FROM tbZip WHERE @.distance > 3959 * ACOS(SIN(@.lat/57.3) *
> SIN(Latitude/57.3) + COS(@.lat/57.3) * COS(Latitude/57.3) *
> COS((Longitude/57.3) - (@.lng/57.3))) )
> end;
> if (@.lat is null or @.lat=0 or @.count is null or @.count=0) begin
> set @.Result = 'nouser';
> select @.Result as [Result];
> --GoTo hasErr;
> end;
>
> GO
> Thanks in advance for any help!
> Robert
>

Returning the error message in a stored proc

Hi everyone!
I know how to return an error id in a stored proc with the @.@.ERROR
variable but is it possible to also return the corresponding error
message?
Thanks!
Hi
You don't give the version of SQL Server you are using, SQL Server 2005 has
a ERROR_MESSAGE() function. For SQL 2000 you could try looking up the error
message number in master..sysmessages but you won't get the substituted
values.
John
"grosdug@.hotmail.com" wrote:

> Hi everyone!
> I know how to return an error id in a stored proc with the @.@.ERROR
> variable but is it possible to also return the corresponding error
> message?
> Thanks!
>
|||Hi!
SQL 2000 it is, and I tried to get message from sysmessages and I
realised it doesn't substitute the varaibles as you suggest.
So, is there any way to get the message with substitued values?
Thanks!
|||Hi
Not that I know of, although it is available on the client.
John
"grosdug@.hotmail.com" wrote:

> Hi!
> SQL 2000 it is, and I tried to get message from sysmessages and I
> realised it doesn't substitute the varaibles as you suggest.
> So, is there any way to get the message with substitued values?
> Thanks!
>
|||Allright, thanks a lot!

Returning the error message in a stored proc

Hi everyone!
I know how to return an error id in a stored proc with the @.@.ERROR
variable but is it possible to also return the corresponding error
message?
Thanks!Hi!
SQL 2000 it is, and I tried to get message from sysmessages and I
realised it doesn't substitute the varaibles as you suggest.
So, is there any way to get the message with substitued values?
Thanks!|||Allright, thanks a lot!

Returning the error message in a stored proc

Hi everyone!
I know how to return an error id in a stored proc with the @.@.ERROR
variable but is it possible to also return the corresponding error
message?
Thanks!Hi
You don't give the version of SQL Server you are using, SQL Server 2005 has
a ERROR_MESSAGE() function. For SQL 2000 you could try looking up the error
message number in master..sysmessages but you won't get the substituted
values.
John
"grosdug@.hotmail.com" wrote:

> Hi everyone!
> I know how to return an error id in a stored proc with the @.@.ERROR
> variable but is it possible to also return the corresponding error
> message?
> Thanks!
>|||Hi!
SQL 2000 it is, and I tried to get message from sysmessages and I
realised it doesn't substitute the varaibles as you suggest.
So, is there any way to get the message with substitued values?
Thanks!|||Hi
Not that I know of, although it is available on the client.
John
"grosdug@.hotmail.com" wrote:

> Hi!
> SQL 2000 it is, and I tried to get message from sysmessages and I
> realised it doesn't substitute the varaibles as you suggest.
> So, is there any way to get the message with substitued values?
> Thanks!
>|||Allright, thanks a lot!

Tuesday, February 21, 2012

Returning multiple values in recordset form

Hope you can help.
Classic ASP / SQL Server 2000
I'd like my proc to return a recordset with 3 columns.
The values of these 3 columns are each generated by a very
different SQL statement.
I cannot figure out how to write all this so it returns a
nice recordset...
Here's the code -- any suggestions will be greatly appreciated.
CREATE PROCEDURE proc_GetStats
(
)
AS
SET NOCOUNT ON
BEGIN
DECLARE @.SQLA nvarchar(2500)
DECLARE @.SQLB nvarchar(2500)
DECLARE @.SQLC nvarchar(2500)
DECLARE @.INTA int
DECLARE @.INTB int
DECLARE @.INTC int
--Those are actually 3 really different select statements
SET @.SQLA = 'SELECT from TABLE_A returns integer'
SET @.SQLB = 'SELECT from TABLE_B returns integer'
SET @.SQLC = 'SELECT from TABLE_C returns integer'
exec sp_executesql @.SQLA, N'@.TOTO int output', @.INTA output
exec sp_executesql @.SQLB, N'@.TOTO int output', @.INTB output
exec sp_executesql @.SQLC, N'@.TOTO int output', @.INTC output
--How to return this in a recordset form?
SELECT @.INTA 'INTA', @.INTB 'INTB', @.INTC 'INTC'
procEnd:
END
GO
****** What I currently get from running this *************
13556
0
3
INTA INTB INTC
-- -- --
0 0 0Terry,
What do you mean by "a nice recordset"?
If you want to return scalar values to your client app, it is better to
return them as output parameters instead returning them in a recordset.
ADO Performance Best Practices
http://msdn.microsoft.com/library/d.../>
estprac.asp
Best Practices for Using ADO.NET
http://msdn.microsoft.com/library/d.../>
netbest.asp
AMB
"Terry" wrote:

> Hope you can help.
> Classic ASP / SQL Server 2000
> I'd like my proc to return a recordset with 3 columns.
> The values of these 3 columns are each generated by a very
> different SQL statement.
> I cannot figure out how to write all this so it returns a
> nice recordset...
> Here's the code -- any suggestions will be greatly appreciated.
>
>
> CREATE PROCEDURE proc_GetStats
> (
> )
> AS
> SET NOCOUNT ON
> BEGIN
> DECLARE @.SQLA nvarchar(2500)
> DECLARE @.SQLB nvarchar(2500)
> DECLARE @.SQLC nvarchar(2500)
> DECLARE @.INTA int
> DECLARE @.INTB int
> DECLARE @.INTC int
>
> --Those are actually 3 really different select statements
> SET @.SQLA = 'SELECT from TABLE_A returns integer'
> SET @.SQLB = 'SELECT from TABLE_B returns integer'
> SET @.SQLC = 'SELECT from TABLE_C returns integer'
> exec sp_executesql @.SQLA, N'@.TOTO int output', @.INTA output
> exec sp_executesql @.SQLB, N'@.TOTO int output', @.INTB output
> exec sp_executesql @.SQLC, N'@.TOTO int output', @.INTC output
> --How to return this in a recordset form?
> SELECT @.INTA 'INTA', @.INTB 'INTB', @.INTC 'INTC'
>
> procEnd:
> END
> GO
>
> ****** What I currently get from running this *************
>
> --
> 13556
>
> --
> 0
>
> --
> 3
> INTA INTB INTC
> -- -- --
> 0 0 0
>|||Your SELECT statements need to assign the scalar result. Otherwise, the
results are returned to the client. For example:
SET @.SQLA = 'SELECT @.INTA = MyColumn FROM TABLE_A'
SET @.SQLB = 'SELECT @.INTB = MyColumn FROM TABLE_B'
SET @.SQLC = 'SELECT @.INTC = MyColumn FROM TABLE_C'
Hope this helps.
Dan Guzman
SQL Server MVP
"Terry" <a165287@.yahoo-youknow.com> wrote in message
news:SjBZd.645$yD.3435@.newscontent-01.sprint.ca...
> Hope you can help.
> Classic ASP / SQL Server 2000
> I'd like my proc to return a recordset with 3 columns.
> The values of these 3 columns are each generated by a very
> different SQL statement.
> I cannot figure out how to write all this so it returns a
> nice recordset...
> Here's the code -- any suggestions will be greatly appreciated.
>
>
> CREATE PROCEDURE proc_GetStats
> ( )
> AS
> SET NOCOUNT ON
> BEGIN
> DECLARE @.SQLA nvarchar(2500)
> DECLARE @.SQLB nvarchar(2500)
> DECLARE @.SQLC nvarchar(2500)
> DECLARE @.INTA int
> DECLARE @.INTB int
> DECLARE @.INTC int
>
> --Those are actually 3 really different select statements
> SET @.SQLA = 'SELECT from TABLE_A returns integer'
> SET @.SQLB = 'SELECT from TABLE_B returns integer'
> SET @.SQLC = 'SELECT from TABLE_C returns integer'
> exec sp_executesql @.SQLA, N'@.TOTO int output', @.INTA output
> exec sp_executesql @.SQLB, N'@.TOTO int output', @.INTB output
> exec sp_executesql @.SQLC, N'@.TOTO int output', @.INTC output
> --How to return this in a recordset form?
> SELECT @.INTA 'INTA', @.INTB 'INTB', @.INTC 'INTC'
>
> procEnd:
> END
> GO
>
> ****** What I currently get from running this *************
>
> --
> 13556
>
> --
> 0
>
> --
> 3
> INTA INTB INTC
> -- -- --
> 0 0 0
>|||Thanks Dan, I had already tried that and it returns errors:
Must declare the variable '@.INTA'
Must declare the variable '@.INTB'
Must declare the variable '@.INTC'
which makes sense since in the context of the string, the
variable is not declared.
Any other ideas will be appreciated. BTW, the reason I'd
like this returned in recordset form is for compatibility
with existing code. Thanks for your understanding.
Original :: Dan Guzman :: 2005-03-15 08:58

> Your SELECT statements need to assign the scalar result. Otherwise, the
> results are returned to the client. For example:
> SET @.SQLA = 'SELECT @.INTA = MyColumn FROM TABLE_A'
> SET @.SQLB = 'SELECT @.INTB = MyColumn FROM TABLE_B'
> SET @.SQLC = 'SELECT @.INTC = MyColumn FROM TABLE_C'
>|||Is there any way you can type the select statements directly and not use
sp_executesql?
If you use a statement like
SELECT @.INTA=column FROM TableA
It doesn't return a result set and therefore won't be sent back to the ASP
page as a recordset. The very simple queries you gave in your example
certainly don't need to be executed as dynamic SQL.
If you can't, you can use the NextRecordset method of the Recordset object.
WARNING - this is undesirable if you can do ANYTHING AT ALL to avoid it.
Recordset objects are expensive to create.
Ex:
...snip...
Set myRS = myCommand.Execute() 'Opens the recordset created from retrieving
IntA
Set myRS = myRS.NextRecordset() 'Moves to the recordset created from
retrieving IntB
Set myRS = myRS.NextRecordset() 'Moves to the recordset created from
retrieving IntC
Set myRS = myRS.NextRecordset() 'Here you are!
"Terry" <a165287@.yahoo-youknow.com> wrote in message
news:SjBZd.645$yD.3435@.newscontent-01.sprint.ca...
> Hope you can help.
> Classic ASP / SQL Server 2000
> I'd like my proc to return a recordset with 3 columns.
> The values of these 3 columns are each generated by a very
> different SQL statement.
> I cannot figure out how to write all this so it returns a
> nice recordset...
> Here's the code -- any suggestions will be greatly appreciated.
>
>
> CREATE PROCEDURE proc_GetStats
> (
> )
> AS
> SET NOCOUNT ON
> BEGIN
> DECLARE @.SQLA nvarchar(2500)
> DECLARE @.SQLB nvarchar(2500)
> DECLARE @.SQLC nvarchar(2500)
> DECLARE @.INTA int
> DECLARE @.INTB int
> DECLARE @.INTC int
>
> --Those are actually 3 really different select statements
> SET @.SQLA = 'SELECT from TABLE_A returns integer'
> SET @.SQLB = 'SELECT from TABLE_B returns integer'
> SET @.SQLC = 'SELECT from TABLE_C returns integer'
> exec sp_executesql @.SQLA, N'@.TOTO int output', @.INTA output
> exec sp_executesql @.SQLB, N'@.TOTO int output', @.INTB output
> exec sp_executesql @.SQLC, N'@.TOTO int output', @.INTC output
> --How to return this in a recordset form?
> SELECT @.INTA 'INTA', @.INTB 'INTB', @.INTC 'INTC'
>
> procEnd:
> END
> GO
>
> ****** What I currently get from running this *************
>
> --
> 13556
>
> --
> 0
>
> --
> 3
> INTA INTB INTC
> -- -- --
> 0 0 0
>|||Thanks! That did the trick :)
Original :: CMBergin :: 2005-03-16 08:54

> Is there any way you can type the select statements directly and not use
> sp_executesql?
> If you use a statement like
> SELECT @.INTA=column FROM TableA
> It doesn't return a result set and therefore won't be sent back to the ASP
> page as a recordset. The very simple queries you gave in your example
> certainly don't need to be executed as dynamic SQL.
> If you can't, you can use the NextRecordset method of the Recordset object
.
> WARNING - this is undesirable if you can do ANYTHING AT ALL to avoid it.
> Recordset objects are expensive to create.
> Ex:
> ...snip...
> Set myRS = myCommand.Execute() 'Opens the recordset created from retrievin
g
> IntA
> Set myRS = myRS.NextRecordset() 'Moves to the recordset created from
> retrieving IntB
> Set myRS = myRS.NextRecordset() 'Moves to the recordset created from
> retrieving IntC
> Set myRS = myRS.NextRecordset() 'Here you are!
> "Terry" <a165287@.yahoo-youknow.com> wrote in message
> news:SjBZd.645$yD.3435@.newscontent-01.sprint.ca...
>

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