Showing posts with label returns. Show all posts
Showing posts with label returns. Show all posts

Friday, March 30, 2012

Having problems UPDATING with a stored procedure with a variable

Hi,

I wrote this stored procedure that works, and returns what I want, but now I want to mark the "Active" field to 1 for each of the records returned by this. I have had no luck so far.

ALTER PROCEDURE [dbo].[SelectCurrent_acmdtn]

@.extractNum char(10)

AS

BEGIN

SET NOCOUNT ON;

SELECT id, efctv_from_dt, efctv_to_dt, modify_ts, extractno, Active, acmtdn_RECID

FROM (SELECT dbo.acmdtn.*, row_number() OVER (partition BY id

ORDER BY extractno, efctv_to_dt DESC, efctv_from_dt DESC, modify_ts DESC, acmdtn_RECID DESC) rn

FROM dbo.acmdtn

WHERE extractno > @.extractNum) Rank

WHERE rn = 1

END

I have tried inserting Update between the 2 "WHERE" statements, but it returns an error

"Invalid column name 'rn'."

I have also tried opening the recordset in Access VB, but I am restricted to read-only.

I would prefer to have a stored procedure do this.

I can get it to work if I take out the parameter, but I need that part.

The purpose of this (if you care..) is I have a large amount of historical data (this is one of 42 tables) that I need to run reports on, but I need to have the data "as of a certain date (or extractno)". This is data exported from another application that I only get flat files for, that I have imported into SQL Server tables. So, by running this procedure, I get the latest "id" record as of the extractno (I get a new extract every day, with changes that were made the previous day). I want to mark these latest fields in the "Active" field so when I create reports, I can have them filter on this field.

Any help would be greatly appreciated.

Hi,

I wrote this stored procedure that works, and returns what I want, but now I want to mark the "Active" field to 1 for each of the records returned by this. I have had no luck so far.

ALTER PROCEDURE [dbo].[SelectCurrent_acmdtn]

@.extractNum char(10)

AS

BEGIN

SET NOCOUNT ON;

SELECT id, efctv_from_dt, efctv_to_dt, modify_ts, extractno, Active, acmtdn_RECID

FROM (SELECT dbo.acmdtn.*, row_number() OVER (partition BY id

ORDER BY extractno, efctv_to_dt DESC, efctv_from_dt DESC, modify_ts DESC, acmdtn_RECID DESC) rn

FROM dbo.acmdtn

WHERE extractno > @.extractNum) Rank

WHERE rn = 1

END

I have tried inserting Update between the 2 "WHERE" statements, but it returns an error

"Invalid column name 'rn'."

I have also tried opening the recordset in Access VB , but I am restricted to read-only.

I would prefer to have a stored procedure do this.

I can get it to work if I take out the parameter, but I need that part.

The purpose of this (if you care..) is I have a large amount of historical data (this is one of 42 tables) that I need to run reports on, but I need to have the data "as of a certain date (or extractno)". This is data exported from another application that I only get flat files for, that I have imported into SQL Server tables. So, by running this procedure, I get the each latest "id" record as of the extractno (I get a new extract every day, with changes that were made the previous day). I want to mark these latest fields in the "Active" field so when I create reports, I can have them filter on this field.

Any help would be greatly appreciated.|||

Hi,

I wrote this stored procedure that works, and returns what I want, but now I want to mark the "Active" field to 1 for each of the records returned by this. I have had no luck so far. I am working in SQL server 2005.

ALTER PROCEDURE [dbo].[SelectCurrent_acmdtn]

@.extractNum char(10)

AS

BEGIN

SET NOCOUNT ON;

SELECT id, efctv_from_dt, efctv_to_dt, modify_ts, extractno, Active, acmtdn_RECID

FROM (SELECT dbo.acmdtn.*, row_number() OVER (partition BY id

ORDER BY extractno, efctv_to_dt DESC, efctv_from_dt DESC, modify_ts DESC, acmdtn_RECID DESC) rn

FROM dbo.acmdtn

WHERE extractno > @.extractNum) Rank

WHERE rn = 1

END

I have tried inserting Update between the 2 "WHERE" statements, but it returns an error

"Invalid column name 'rn'."

I have also tried opening the recordset in Access VB , but I am restricted to read-only.

I would prefer to have a stored procedure do this.

I can get it to work if I take out the parameter, but I need that part.

The purpose of this (if you care..) is I have a large amount of historical data (this is one of 42 tables) that I need to run reports on, but I need to have the data "as of a certain date (or extractno)". This is data exported from another application that I only get flat files for, that I have imported into SQL Server tables. So, by running this procedure, I get the latest "id" record as of the extractno (I get a new extract every day, with changes that were made the previous day). I want to mark these latest fields in the "Active" field so when I create reports, I can have them filter on this field.

Any help would be greatly appreciated.|||

You are returning the results of a data manipulation - there may not be a 'match' between the resultset and the actual table.

My 'simple' recommendation is to:

capture the resultset in a @.Table variable, then use the [ID] value from that table variable to UPDATE the data, finally, returning the contents of the table variable with a SELECT.|||

Thanks for the reply. I posted this question a few too many times (was told it was deleted by administrator!).

Anyway, [ID] is not the primary key, [acmdtn_RECID] is. Any changes made to the master database simply add another record, and retain the old record, so historical queries can be run. So there can be dozens of records for each [ID]. What I want is the most recent record, for each [ID], as of a certain date.

I guess I just don't get why I can display the information, but I can't write back to the database based on that displayed information. It's a complex query, but there's no joins, or other tables involved, there can only be a 1:1 relationship between records in the table, and records in the resultset.

Wednesday, March 28, 2012

Having Problem in using JDBC Driver for SQL Server 2000 SP3

I'm using jdk 1.5.0 and SQL Server PE,
when i user the driver, it returns
Socket Establishing Failure ...
anyone can help what's the problem is..Hi
Got the latest SP for JDBC?
http://support.microsoft.com/default.aspx?scid=kb;en-us;883370
--
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Stephen Wang" wrote:
> I'm using jdk 1.5.0 and SQL Server PE,
> when i user the driver, it returns
> Socket Establishing Failure ...
> anyone can help what's the problem is..|||yeah, i got the latest SP3sql

Monday, March 26, 2012

Having a drilldown report "go back" to original report

Hi,

I have a main/summary report which returns a list of records. Each record on this main report contains a link to a detailed report for more information on that particular record. That all works just fine. But on my detailed report, I want to provide a button to allow the user to easily "go back" to the original report.

I noticed that at the top of my detailed report is a toolbar, with icons to print, search, etc., so this seems like the place where it would be nice to have another icon with the back arrow that would be linked to the original report. The user can use the Back button on the browser, but I think it would be much nicer to provide a Back button on the report itself.

Is there any easy way to go about doing this?
Can anyone give me any pointers?

Thanks,
Beth

The new ReportViewer controls in VS 2005 have this functionality. The button is hidden by default in the ReportViewer web control, but you can enable it by setting ReportViewer.ShowBackButton = true.

|||Oh, my fault - I forgot to mention that I am using SQL Server Reporting Service 2000 and VS 2003.

Is there a different mechanism to use for this configuration?

Thanks,
Beth|||There is no way to do this from within RS 2000.|||Ok, thanks for the info.

Beth|||

One thing I have done is to use a text box on the last report and then then put some text in there, like "Back to Original Report -->" and then navigate to the original report. The users don't seem to mind.

SHP

|||

where to add this code to get the backbutton..Please tell me procedure to add back button by this method..

Thanks a lot.

|||

I've done it on a few of my reports. In my case i save my where clause in a parameter called @.Previous and pass it to the drilldown report. Then in my drilldown report i have a textbox which i have set to call my original report with @.Previous parameter. To make i look more like a button i've given the textbox a picture background.

Basically i am running the original report again and passing it its original parameters. Its not quite like adding a button to the toolbar, but it works. Hope this helps.

|||

Thanks dear. But i know it works at the same time it takes me to the original refreshed report with default parameters. I want the button so that the user can go to the exactly previous page. Also if the back button can appear in the VS then it should come in report manager too.

Please somebody let me know the procedure.

|||

Does anyone know how/where to set the ReportViewer.ShowBackButton = True for reportmanager.

|||While Report Manager does use a version of the viewer control internally, it doesn't expose the viewer API to the end user, so there is no way to enable this button through Report Manager. It is only available on the standalone control.|||

Brian,

Is this something that will be included in a Hotfix / SP? Going back to the parent report by using the Browser back button just causes the parent report to sit there and not process. Obviously a usabilty issue ( I can get around for now by using Jump to URL and forcing a new window to pop-up but it would be better not to have to go that route).

|||

I send my report parameters directly from my UI and pass them all into a parameter called @.Criteria in my report (In my reports i pass @.Criteria into the WHERE clause in the query) ). And this is the parameter i pass to my drill-through report to a parameter @.Previous. My back button then calls the original report with exactly the same parameters (@.Previous is passed into the where clause in the original report).

Of course there is a hard way to do it. Pass all the original report parameters to the drill through report to dummy parameters which aren't used and then when you press the back button send all the same parameters back to get your orginal report.

|||

I'm not sure if this is what everyone is after but perhaps this will help. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1327767&SiteID=1

|||

Dear all

Please provide me the steps to create a drilled down report in report server 2005 . I am a begginer in reportserver ..

regards

Polachan

Having a drilldown report "go back" to original report

Hi,

I have a main/summary report which returns a list of records. Each record on this main report contains a link to a detailed report for more information on that particular record. That all works just fine. But on my detailed report, I want to provide a button to allow the user to easily "go back" to the original report.

I noticed that at the top of my detailed report is a toolbar, with icons to print, search, etc., so this seems like the place where it would be nice to have another icon with the back arrow that would be linked to the original report. The user can use the Back button on the browser, but I think it would be much nicer to provide a Back button on the report itself.

Is there any easy way to go about doing this?
Can anyone give me any pointers?

Thanks,
Beth

The new ReportViewer controls in VS 2005 have this functionality. The button is hidden by default in the ReportViewer web control, but you can enable it by setting ReportViewer.ShowBackButton = true.

|||Oh, my fault - I forgot to mention that I am using SQL Server Reporting Service 2000 and VS 2003.

Is there a different mechanism to use for this configuration?

Thanks,
Beth|||There is no way to do this from within RS 2000.|||Ok, thanks for the info.

Beth|||

One thing I have done is to use a text box on the last report and then then put some text in there, like "Back to Original Report -->" and then navigate to the original report. The users don't seem to mind.

SHP

|||

where to add this code to get the backbutton..Please tell me procedure to add back button by this method..

Thanks a lot.

|||

I've done it on a few of my reports. In my case i save my where clause in a parameter called @.Previous and pass it to the drilldown report. Then in my drilldown report i have a textbox which i have set to call my original report with @.Previous parameter. To make i look more like a button i've given the textbox a picture background.

Basically i am running the original report again and passing it its original parameters. Its not quite like adding a button to the toolbar, but it works. Hope this helps.

|||

Thanks dear. But i know it works at the same time it takes me to the original refreshed report with default parameters. I want the button so that the user can go to the exactly previous page. Also if the back button can appear in the VS then it should come in report manager too.

Please somebody let me know the procedure.

|||

Does anyone know how/where to set the ReportViewer.ShowBackButton = True for reportmanager.

|||While Report Manager does use a version of the viewer control internally, it doesn't expose the viewer API to the end user, so there is no way to enable this button through Report Manager. It is only available on the standalone control.|||

Brian,

Is this something that will be included in a Hotfix / SP? Going back to the parent report by using the Browser back button just causes the parent report to sit there and not process. Obviously a usabilty issue ( I can get around for now by using Jump to URL and forcing a new window to pop-up but it would be better not to have to go that route).

|||

I send my report parameters directly from my UI and pass them all into a parameter called @.Criteria in my report (In my reports i pass @.Criteria into the WHERE clause in the query) ). And this is the parameter i pass to my drill-through report to a parameter @.Previous. My back button then calls the original report with exactly the same parameters (@.Previous is passed into the where clause in the original report).

Of course there is a hard way to do it. Pass all the original report parameters to the drill through report to dummy parameters which aren't used and then when you press the back button send all the same parameters back to get your orginal report.

|||

I'm not sure if this is what everyone is after but perhaps this will help. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1327767&SiteID=1

|||

Dear all

Please provide me the steps to create a drilled down report in report server 2005 . I am a begginer in reportserver ..

regards

Polachan

Having a drilldown report "go back" to original report

Hi,

I have a main/summary report which returns a list of records. Each record on this main report contains a link to a detailed report for more information on that particular record. That all works just fine. But on my detailed report, I want to provide a button to allow the user to easily "go back" to the original report.

I noticed that at the top of my detailed report is a toolbar, with icons to print, search, etc., so this seems like the place where it would be nice to have another icon with the back arrow that would be linked to the original report. The user can use the Back button on the browser, but I think it would be much nicer to provide a Back button on the report itself.

Is there any easy way to go about doing this?
Can anyone give me any pointers?

Thanks,
Beth

The new ReportViewer controls in VS 2005 have this functionality. The button is hidden by default in the ReportViewer web control, but you can enable it by setting ReportViewer.ShowBackButton = true.

|||Oh, my fault - I forgot to mention that I am using SQL Server Reporting Service 2000 and VS 2003.

Is there a different mechanism to use for this configuration?

Thanks,
Beth|||There is no way to do this from within RS 2000.|||Ok, thanks for the info.

Beth|||

One thing I have done is to use a text box on the last report and then then put some text in there, like "Back to Original Report -->" and then navigate to the original report. The users don't seem to mind.

SHP

|||

where to add this code to get the backbutton..Please tell me procedure to add back button by this method..

Thanks a lot.

|||

I've done it on a few of my reports. In my case i save my where clause in a parameter called @.Previous and pass it to the drilldown report. Then in my drilldown report i have a textbox which i have set to call my original report with @.Previous parameter. To make i look more like a button i've given the textbox a picture background.

Basically i am running the original report again and passing it its original parameters. Its not quite like adding a button to the toolbar, but it works. Hope this helps.

|||

Thanks dear. But i know it works at the same time it takes me to the original refreshed report with default parameters. I want the button so that the user can go to the exactly previous page. Also if the back button can appear in the VS then it should come in report manager too.

Please somebody let me know the procedure.

|||

Does anyone know how/where to set the ReportViewer.ShowBackButton = True for reportmanager.

|||While Report Manager does use a version of the viewer control internally, it doesn't expose the viewer API to the end user, so there is no way to enable this button through Report Manager. It is only available on the standalone control.|||

Brian,

Is this something that will be included in a Hotfix / SP? Going back to the parent report by using the Browser back button just causes the parent report to sit there and not process. Obviously a usabilty issue ( I can get around for now by using Jump to URL and forcing a new window to pop-up but it would be better not to have to go that route).

|||

I send my report parameters directly from my UI and pass them all into a parameter called @.Criteria in my report (In my reports i pass @.Criteria into the WHERE clause in the query) ). And this is the parameter i pass to my drill-through report to a parameter @.Previous. My back button then calls the original report with exactly the same parameters (@.Previous is passed into the where clause in the original report).

Of course there is a hard way to do it. Pass all the original report parameters to the drill through report to dummy parameters which aren't used and then when you press the back button send all the same parameters back to get your orginal report.

|||

I'm not sure if this is what everyone is after but perhaps this will help. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1327767&SiteID=1

|||

Dear all

Please provide me the steps to create a drilled down report in report server 2005 . I am a begginer in reportserver ..

regards

Polachan

HAVING (COUNT(category) > 1) , not only 1 row

i am using this code :

SELECT MAX(user) AS lastuser, category
FROM journal
GROUP BY category
HAVING (COUNT(category) > 1)

it works but returns 1 line by category >1

i need all the user (all the rows) HAVING (COUNT(category) > 1) , not only 1

if 1 category has only 1 user i must not keep it

i am not shure to be clear :-)

thank you for helpingIf you need all the users fulfilling the requirements, why are you using the "max" argument. By its nature, the max (maximum) will return the largest value. Get rid of max, add user to your group by and try again.|||you mean

SELECT user, category
FROM journal
GROUP BY user,category
HAVING (COUNT(category) > 1)

i dont get it in that way

I dont need the lines : A|B where count(B) = 1
i need only the lines : A|B. C|B, D|B count(B) > 1

with my first code I get D|B (the last one)|||I don't think that your query will work it would return
where a user had the same category more than once
not differeent categories for the same user.

SELECT user
FROM journal
GROUP BY user
HAVING (COUNT(category) > 1)|||i dont get it in that way
i need for exemple 3 lines

john tennis
pierre tennis
paul tennis

3 lines if count(category) > 1|||SSELECT user_name,
category
FROM journal
WHERE category IN (SELECT category
FROM journal
GROUP BY category
HAVING COUNT(*) > 1)|||i'll try

thank you