Showing posts with label records. Show all posts
Showing posts with label records. Show all posts

Sunday, March 25, 2012

ActiveX to define presidence

I have a DTS package (SQL2000) which uses ActiveX scripts to check for records with certain criteria in a table. If the certain criteria is met, I want to initiate a child package that preforms a data-extraction. Otherwise move onto the next step which check for a different set of criteria. Currently if the criteria is met, I flag the task as success to dictate moving to one set of steps, otherwise failure & moving onto the next check.

The problem I am realizing, is that if I 'Fail' on of the check steps, subsequent steps furthur down the route that I am directing it to go, do not run. These are other ActiveX tasks that send email, and do furthur analysis.

Why is this the case? Can't you perform a logical check, and based upon the check have a decision to run certain steps? I attempted to use the result 'Main = DTSStepScriptResult_DontExecuteTask', but I must not be using it correctly, because it lists the task as returning failure.

Any help would be great.

Kevin Albrecht

DTS is called "SQL Server Integration Services" in the SQL Server 2005 generation. If you re-post your question in the SSIS forums (http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=80&SiteID=1) the DTS experts that hang out over there could likely answer your question.

Thanks,
Steve

|||Moving thread as per the suggestion to keep in SSIS related forums.|||Don't use success/fail as the flag to move to the next step. Set a variable and use an "Expression" precidence constraint to pick which one to move too.

Tuesday, March 6, 2012

Acessing deleted records

Hi

First i'd like to say that i dont really know if it is possible to acess this, but since i've been told that some database system sometimes only "flag" record as deleted to delete them later and that i would need to possibly acess this data for a work im doing, it would be interesting for me if somebody had the asnwer i seek.

Do you know if there is a way under sql server 2000/2005 acess those data?

In SQL Server 2005 you could use OUTPUT clause (http://msdn2.microsoft.com/en-us/library/ms177564.aspx):

Code Snippet

DELETE Sales.ShoppingCartItem
OUTPUT DELETED.* ;

In SQL Server 2000 you could create on delete trigger and use "virtual table" deleted

|||

Ok, i was not very clear in the first post, my bad.

Is it possible to acess deleted data, after it was deleted, and by that i mean : Someguy delete a record, and at the end of the week i want to know how much or what data has been deleted if it has not yet been deleted physically.

And i would prefer not to use trigger since i would have to make one for each and every hundreds table of the same number of databases.

|||

No, data is deleted physically in SQL Server as soon as the statement is committed. You *can* look in the logs to see what has been deleted using a third party tool like http://www.apexsql.com/sql_tools_log.asp, but I would only suggest that as a detective tool, not a common surveilance method, especially since you should be dumping your log fairly often as a method of recovery. It will also not record who delete the row, only that it has been deleted. If you want deletes to be logical and not physical, you would have to prepare this in your design and implement it yourself.

A trigger is really your best option for logging changes. Creating a trigger for all tables is a pain, but you might be able to build them without much trouble by using the information_schema and system views (or system tables in 2000). You can find out the tablename, the columns, etc and build the triggers using a standard template without a tremendous amount of work.

For just what data is different, you could try something like http://www.red-gate.com/products/SQL_Data_Compare/index.htm. It might be too slow for you if you have a lot of data. It also cannot tell you what has been deleted.

|||

For those who would like to know i found the solution to get what i wanted :

The command sp_spaceused give a lot of information about a table or a database including the unused space and row count.

Knowing that i was able to get the number of deleted record by comparing the size taken by undeleted row.

Accumulating Rolling Total

I'm trying to create an accumulating field based on a set of records. I need to fill in daily amount balances that accumulates on a daily basis. But I can't seem to figure out how to create a total for the daily dates and have it add on additional amounts if needed.

Here's some sample data:

5 6 20 1 200.00 5/5/20000
5 6 20 1 -149.00 5/8/2000

5 6 20 1 100.00 5/10/2000

Now I already have a table with the dates created via a stored procedure. I have a set of dates from 5/5/2000 to 5/8/2000. So that results set should look like this:

5 6 20 1 200.00 5/5/2000

5 6 20 1 200.00 5/6/20000
5 6 20 1 200.00 5/7/2000

5 6 20 1 51.00 5/8/2000

5 6 20 1 51.00 5/9/2000

5 6 20 1 151.00 5/10/2000

....

I'm trying to creating a rolling sum that accumulates the amount field for each daily record and if a new amount is listed, then roll that amount into the total. If you have any suggestions about how to perform this rolling total via TSQL or SSIS, I would greatly appreciate it.

Thanks

Greg

Its complicated but (I think) achievable. You'll probably need a list of all contiguous dates to start with. Then join that list to your balances data as shown above. You will need to join on all days from the balances data that are less than or equal to the date in the list of dates. Then do a sum of all balances grouping by all the dates in the list of dates.

Its alot easier to achieve than it is to explain believe me

-Jamie

Oh P.S. I'm not sure you'll be able to do this in SSIS because MERGE JOIN doesn't support non-equi joins. Yet.

Saturday, February 25, 2012

Accidently delete records

Hello All,
I'm need help!
I have accidently deleted all record from a table. I don't have a backup at the time I deleted. Could you all tell me if there's a way to recover those records?
Thanks.
David
You may be able to use your transaction logs to do a point in time restore,
I'm not sure, but there is hope.
"David" <David@.discussions.microsoft.com> wrote in message
news:37E4E743-B412-4BF9-BFE2-69D4AA671891@.microsoft.com...
> Hello All,
> I'm need help!
> I have accidently deleted all record from a table. I don't have a backup
at the time I deleted. Could you all tell me if there's a way to recover
those records?
> Thanks.
> David
|||Lyle,
How do I do that? Could you please share some hint?
"Lyle Spencer" wrote:

> You may be able to use your transaction logs to do a point in time restore,
> I'm not sure, but there is hope.
> "David" <David@.discussions.microsoft.com> wrote in message
> news:37E4E743-B412-4BF9-BFE2-69D4AA671891@.microsoft.com...
> at the time I deleted. Could you all tell me if there's a way to recover
> those records?
>
>
|||YOu will need to take your full backups and apply the
trans logs up to the point in time you deleted the table
and you can then retrieve the records.
Here's an example from BOL
-- Restore the database backup.
RESTORE DATABASE MyNwind
FROM MyNwind_1, MyNwind_2
WITH NORECOVERY
GO
RESTORE LOG MyNwind
FROM MyNwind_log1
WITH RECOVERY, STOPAT = 'Jul 1, 1998 10:00 AM'
GO
RESTORE LOG MyNwind
FROM MyNwind_log2
WITH RECOVERY, STOPAT = 'Jul 1, 1998 10:00 AM'
[vbcol=seagreen]
>--Original Message--
>Lyle,
>How do I do that? Could you please share some hint?
>
>"Lyle Spencer" wrote:
point in time restore,[vbcol=seagreen]
message[vbcol=seagreen]
69D4AA671891@.microsoft.com...[vbcol=seagreen]
don't have a backup[vbcol=seagreen]
there's a way to recover
>.
>
|||Hmmm... My problem is that I've never done a backup for that database.
"anonymous@.discussions.microsoft.com" wrote:

> YOu will need to take your full backups and apply the
> trans logs up to the point in time you deleted the table
> and you can then retrieve the records.
> Here's an example from BOL
> -- Restore the database backup.
> RESTORE DATABASE MyNwind
> FROM MyNwind_1, MyNwind_2
> WITH NORECOVERY
> GO
> RESTORE LOG MyNwind
> FROM MyNwind_log1
> WITH RECOVERY, STOPAT = 'Jul 1, 1998 10:00 AM'
> GO
> RESTORE LOG MyNwind
> FROM MyNwind_log2
> WITH RECOVERY, STOPAT = 'Jul 1, 1998 10:00 AM'
> point in time restore,
> message
> 69D4AA671891@.microsoft.com...
> don't have a backup
> there's a way to recover
>
|||Hi,
This will work only if you have the database in FULL recovery model, must
have a FULL database Backup ,
all the subsequent trasnaction log backup files after the full backup.
I feel that in your case you cant revert back with out a backup.
Note:-
Based on the criticality of data please choose a recovery model and define
necessory backup procedures
for your SQL Server databases.
Thanks
Hari
MCDBA
"David" <David@.discussions.microsoft.com> wrote in message
news:EEEAE0E7-BA74-40BF-BC32-840649B457DA@.microsoft.com...[vbcol=seagreen]
> Hmmm... My problem is that I've never done a backup for that database.
>
> "anonymous@.discussions.microsoft.com" wrote:
|||> Hmmm... My problem is that I've never done a backup for that database.
Then you must not consider the data very important!
http://www.aspfaq.com/2449
|||I've never use Lumigent, but they claim to go through the internal free list
(as well as syslogs) to recover what might never be recoverable otherwise.
"David" <David@.discussions.microsoft.com> wrote in message
news:37E4E743-B412-4BF9-BFE2-69D4AA671891@.microsoft.com...
> Hello All,
> I'm need help!
> I have accidently deleted all record from a table. I don't have a backup
at the time I deleted. Could you all tell me if there's a way to recover
those records?
> Thanks.
> David
|||Hi David,
Saw your reply and try download the Log P.I software and this is realyl good.
The web site is www.logpi.com You can restore the deleted transactions, but make sure you follow the steps they have mentioned.
Regards
RK.
"David" wrote:

> Hello All,
> I'm need help!
> I have accidently deleted all record from a table. I don't have a backup at the time I deleted. Could you all tell me if there's a way to recover those records?
> Thanks.
> David

Accidently delete records

Hello All,
I'm need help!
I have accidently deleted all record from a table. I don't have a backup at
the time I deleted. Could you all tell me if there's a way to recover those
records?
Thanks.
DavidYou may be able to use your transaction logs to do a point in time restore,
I'm not sure, but there is hope.
"David" <David@.discussions.microsoft.com> wrote in message
news:37E4E743-B412-4BF9-BFE2-69D4AA671891@.microsoft.com...
> Hello All,
> I'm need help!
> I have accidently deleted all record from a table. I don't have a backup
at the time I deleted. Could you all tell me if there's a way to recover
those records?
> Thanks.
> David|||Lyle,
How do I do that? Could you please share some hint?
"Lyle Spencer" wrote:

> You may be able to use your transaction logs to do a point in time restore
,
> I'm not sure, but there is hope.
> "David" <David@.discussions.microsoft.com> wrote in message
> news:37E4E743-B412-4BF9-BFE2-69D4AA671891@.microsoft.com...
> at the time I deleted. Could you all tell me if there's a way to recover
> those records?
>
>|||YOu will need to take your full backups and apply the
trans logs up to the point in time you deleted the table
and you can then retrieve the records.
Here's an example from BOL
-- Restore the database backup.
RESTORE DATABASE MyNwind
FROM MyNwind_1, MyNwind_2
WITH NORECOVERY
GO
RESTORE LOG MyNwind
FROM MyNwind_log1
WITH RECOVERY, STOPAT = 'Jul 1, 1998 10:00 AM'
GO
RESTORE LOG MyNwind
FROM MyNwind_log2
WITH RECOVERY, STOPAT = 'Jul 1, 1998 10:00 AM'

>--Original Message--
>Lyle,
>How do I do that? Could you please share some hint?
>
>"Lyle Spencer" wrote:
>
point in time restore,[vbcol=seagreen]
message[vbcol=seagreen]
69D4AA671891@.microsoft.com...[vbcol=seagreen]
don't have a backup[vbcol=seagreen]
there's a way to recover[vbcol=seagreen]
>.
>|||Hmmm... My problem is that I've never done a backup for that database.
"anonymous@.discussions.microsoft.com" wrote:

> YOu will need to take your full backups and apply the
> trans logs up to the point in time you deleted the table
> and you can then retrieve the records.
> Here's an example from BOL
> -- Restore the database backup.
> RESTORE DATABASE MyNwind
> FROM MyNwind_1, MyNwind_2
> WITH NORECOVERY
> GO
> RESTORE LOG MyNwind
> FROM MyNwind_log1
> WITH RECOVERY, STOPAT = 'Jul 1, 1998 10:00 AM'
> GO
> RESTORE LOG MyNwind
> FROM MyNwind_log2
> WITH RECOVERY, STOPAT = 'Jul 1, 1998 10:00 AM'
>
> point in time restore,
> message
> 69D4AA671891@.microsoft.com...
> don't have a backup
> there's a way to recover
>|||Hi,
This will work only if you have the database in FULL recovery model, must
have a FULL database Backup ,
all the subsequent trasnaction log backup files after the full backup.
I feel that in your case you cant revert back with out a backup.
Note:-
Based on the criticality of data please choose a recovery model and define
necessory backup procedures
for your SQL Server databases.
Thanks
Hari
MCDBA
"David" <David@.discussions.microsoft.com> wrote in message
news:EEEAE0E7-BA74-40BF-BC32-840649B457DA@.microsoft.com...[vbcol=seagreen]
> Hmmm... My problem is that I've never done a backup for that database.
>
> "anonymous@.discussions.microsoft.com" wrote:
>|||> Hmmm... My problem is that I've never done a backup for that database.
Then you must not consider the data very important!
http://www.aspfaq.com/2449|||I've never use Lumigent, but they claim to go through the internal free list
(as well as syslogs) to recover what might never be recoverable otherwise.
"David" <David@.discussions.microsoft.com> wrote in message
news:37E4E743-B412-4BF9-BFE2-69D4AA671891@.microsoft.com...
> Hello All,
> I'm need help!
> I have accidently deleted all record from a table. I don't have a backup
at the time I deleted. Could you all tell me if there's a way to recover
those records?
> Thanks.
> David|||Hi David,
Saw your reply and try download the Log P.I software and this is realyl good
.
The web site is www.logpi.com You can restore the deleted transactions, but
make sure you follow the steps they have mentioned.
Regards
RK.
"David" wrote:

> Hello All,
> I'm need help!
> I have accidently deleted all record from a table. I don't have a backup a
t the time I deleted. Could you all tell me if there's a way to recover thos
e records?
> Thanks.
> David

Accidently delete records

Hello All,
I'm need help!
I have accidently deleted all record from a table. I don't have a backup at the time I deleted. Could you all tell me if there's a way to recover those records?
Thanks.
DavidYou may be able to use your transaction logs to do a point in time restore,
I'm not sure, but there is hope.
"David" <David@.discussions.microsoft.com> wrote in message
news:37E4E743-B412-4BF9-BFE2-69D4AA671891@.microsoft.com...
> Hello All,
> I'm need help!
> I have accidently deleted all record from a table. I don't have a backup
at the time I deleted. Could you all tell me if there's a way to recover
those records?
> Thanks.
> David|||Lyle,
How do I do that? Could you please share some hint?
"Lyle Spencer" wrote:
> You may be able to use your transaction logs to do a point in time restore,
> I'm not sure, but there is hope.
> "David" <David@.discussions.microsoft.com> wrote in message
> news:37E4E743-B412-4BF9-BFE2-69D4AA671891@.microsoft.com...
> > Hello All,
> >
> > I'm need help!
> > I have accidently deleted all record from a table. I don't have a backup
> at the time I deleted. Could you all tell me if there's a way to recover
> those records?
> >
> > Thanks.
> > David
>
>|||YOu will need to take your full backups and apply the
trans logs up to the point in time you deleted the table
and you can then retrieve the records.
Here's an example from BOL
-- Restore the database backup.
RESTORE DATABASE MyNwind
FROM MyNwind_1, MyNwind_2
WITH NORECOVERY
GO
RESTORE LOG MyNwind
FROM MyNwind_log1
WITH RECOVERY, STOPAT = 'Jul 1, 1998 10:00 AM'
GO
RESTORE LOG MyNwind
FROM MyNwind_log2
WITH RECOVERY, STOPAT = 'Jul 1, 1998 10:00 AM'
>--Original Message--
>Lyle,
>How do I do that? Could you please share some hint?
>
>"Lyle Spencer" wrote:
>> You may be able to use your transaction logs to do a
point in time restore,
>> I'm not sure, but there is hope.
>> "David" <David@.discussions.microsoft.com> wrote in
message
>> news:37E4E743-B412-4BF9-BFE2-
69D4AA671891@.microsoft.com...
>> > Hello All,
>> >
>> > I'm need help!
>> > I have accidently deleted all record from a table. I
don't have a backup
>> at the time I deleted. Could you all tell me if
there's a way to recover
>> those records?
>> >
>> > Thanks.
>> > David
>>
>.
>|||Hmmm... My problem is that I've never done a backup for that database.
"anonymous@.discussions.microsoft.com" wrote:
> YOu will need to take your full backups and apply the
> trans logs up to the point in time you deleted the table
> and you can then retrieve the records.
> Here's an example from BOL
> -- Restore the database backup.
> RESTORE DATABASE MyNwind
> FROM MyNwind_1, MyNwind_2
> WITH NORECOVERY
> GO
> RESTORE LOG MyNwind
> FROM MyNwind_log1
> WITH RECOVERY, STOPAT = 'Jul 1, 1998 10:00 AM'
> GO
> RESTORE LOG MyNwind
> FROM MyNwind_log2
> WITH RECOVERY, STOPAT = 'Jul 1, 1998 10:00 AM'
> >--Original Message--
> >Lyle,
> >
> >How do I do that? Could you please share some hint?
> >
> >
> >"Lyle Spencer" wrote:
> >
> >> You may be able to use your transaction logs to do a
> point in time restore,
> >> I'm not sure, but there is hope.
> >>
> >> "David" <David@.discussions.microsoft.com> wrote in
> message
> >> news:37E4E743-B412-4BF9-BFE2-
> 69D4AA671891@.microsoft.com...
> >> > Hello All,
> >> >
> >> > I'm need help!
> >> > I have accidently deleted all record from a table. I
> don't have a backup
> >> at the time I deleted. Could you all tell me if
> there's a way to recover
> >> those records?
> >> >
> >> > Thanks.
> >> > David
> >>
> >>
> >>
> >.
> >
>|||Hi,
This will work only if you have the database in FULL recovery model, must
have a FULL database Backup ,
all the subsequent trasnaction log backup files after the full backup.
I feel that in your case you cant revert back with out a backup.
Note:-
Based on the criticality of data please choose a recovery model and define
necessory backup procedures
for your SQL Server databases.
Thanks
Hari
MCDBA
"David" <David@.discussions.microsoft.com> wrote in message
news:EEEAE0E7-BA74-40BF-BC32-840649B457DA@.microsoft.com...
> Hmmm... My problem is that I've never done a backup for that database.
>
> "anonymous@.discussions.microsoft.com" wrote:
> > YOu will need to take your full backups and apply the
> > trans logs up to the point in time you deleted the table
> > and you can then retrieve the records.
> >
> > Here's an example from BOL
> > -- Restore the database backup.
> > RESTORE DATABASE MyNwind
> > FROM MyNwind_1, MyNwind_2
> > WITH NORECOVERY
> > GO
> > RESTORE LOG MyNwind
> > FROM MyNwind_log1
> > WITH RECOVERY, STOPAT = 'Jul 1, 1998 10:00 AM'
> > GO
> > RESTORE LOG MyNwind
> > FROM MyNwind_log2
> > WITH RECOVERY, STOPAT = 'Jul 1, 1998 10:00 AM'
> >
> > >--Original Message--
> > >Lyle,
> > >
> > >How do I do that? Could you please share some hint?
> > >
> > >
> > >"Lyle Spencer" wrote:
> > >
> > >> You may be able to use your transaction logs to do a
> > point in time restore,
> > >> I'm not sure, but there is hope.
> > >>
> > >> "David" <David@.discussions.microsoft.com> wrote in
> > message
> > >> news:37E4E743-B412-4BF9-BFE2-
> > 69D4AA671891@.microsoft.com...
> > >> > Hello All,
> > >> >
> > >> > I'm need help!
> > >> > I have accidently deleted all record from a table. I
> > don't have a backup
> > >> at the time I deleted. Could you all tell me if
> > there's a way to recover
> > >> those records?
> > >> >
> > >> > Thanks.
> > >> > David
> > >>
> > >>
> > >>
> > >.
> > >
> >|||> Hmmm... My problem is that I've never done a backup for that database.
Then you must not consider the data very important!
http://www.aspfaq.com/2449|||I've never use Lumigent, but they claim to go through the internal free list
(as well as syslogs) to recover what might never be recoverable otherwise.
"David" <David@.discussions.microsoft.com> wrote in message
news:37E4E743-B412-4BF9-BFE2-69D4AA671891@.microsoft.com...
> Hello All,
> I'm need help!
> I have accidently deleted all record from a table. I don't have a backup
at the time I deleted. Could you all tell me if there's a way to recover
those records?
> Thanks.
> David

Accidentailly changed too many records -

Hi
This might be a trivial question, bit I'm not that experienced in updating
from a table in another database.
We changed a number of records in a table, and unfortunately we did a
mistake so too many was changed.
I've now restored a backup from last night and wants to update the database
with the data from the table in the backup.
The backup has been restored as a new database on the same server as the
"live" database.
I'm trying to do it with an UPDATE statement where I update the tesxt in one
field with the text from the backup, where the record Id is the same in both
tables. My problem is then, that apparently I can't fiugre out to define
that I want to use data from a different database.
The code I'm trying to run is :
UPDATE findimension
SET beskrivelse = Test629.dbo.findimension.beskrivelse
FROM Test629.dbo.findimension.beskrivelse, beskrivelse
WHERE finfimension.findimensionID =
Test629.dbo.findimension.findimensionID
I'm working on the database I want to update, and I want to update from the
database name 'Test629'. When I run the above statement, it tells me that it
can't find server Test629 in sysservers - which is fair enough, since it
isn't a server but a database...:-).
How do I define this in the right way, so it looks at the "Beskrivelse"
column in the findimension table in the Test629 database.
Hope some of you can help?
Regards
SteenYou referenced the table as Test629.dbo.findimension.beskrivelse - since
there are four parts to the name, the engine assumes that Test629 is a
server name. The last part of the name appears to be a column name - remove
it.
"Steen Persson" <SPE@.REMOVEdatea.dk> wrote in message
news:%23vJ8WZjdEHA.4004@.TK2MSFTNGP10.phx.gbl...
> Hi
> This might be a trivial question, bit I'm not that experienced in updating
> from a table in another database.
> We changed a number of records in a table, and unfortunately we did a
> mistake so too many was changed.
> I've now restored a backup from last night and wants to update the
database
> with the data from the table in the backup.
> The backup has been restored as a new database on the same server as the
> "live" database.
> I'm trying to do it with an UPDATE statement where I update the tesxt in
one
> field with the text from the backup, where the record Id is the same in
both
> tables. My problem is then, that apparently I can't fiugre out to define
> that I want to use data from a different database.
> The code I'm trying to run is :
> UPDATE findimension
> SET beskrivelse = Test629.dbo.findimension.beskrivelse
> FROM Test629.dbo.findimension.beskrivelse, beskrivelse
> WHERE finfimension.findimensionID =
> Test629.dbo.findimension.findimensionID
> I'm working on the database I want to update, and I want to update from
the
> database name 'Test629'. When I run the above statement, it tells me that
it
> can't find server Test629 in sysservers - which is fair enough, since it
> isn't a server but a database...:-).
> How do I define this in the right way, so it looks at the "Beskrivelse"
> column in the findimension table in the Test629 database.
> Hope some of you can help?
> Regards
> Steen
>|||Thanks...that was it...
Regards
Steen
Scott Morris wrote:[vbcol=seagreen]
> You referenced the table as Test629.dbo.findimension.beskrivelse -
> since there are four parts to the name, the engine assumes that
> Test629 is a server name. The last part of the name appears to be a
> column name - remove it.
> "Steen Persson" <SPE@.REMOVEdatea.dk> wrote in message
> news:%23vJ8WZjdEHA.4004@.TK2MSFTNGP10.phx.gbl...

Accidentailly changed too many records -

Hi
This might be a trivial question, bit I'm not that experienced in updating
from a table in another database.
We changed a number of records in a table, and unfortunately we did a
mistake so too many was changed.
I've now restored a backup from last night and wants to update the database
with the data from the table in the backup.
The backup has been restored as a new database on the same server as the
"live" database.
I'm trying to do it with an UPDATE statement where I update the tesxt in one
field with the text from the backup, where the record Id is the same in both
tables. My problem is then, that apparently I can't fiugre out to define
that I want to use data from a different database.
The code I'm trying to run is :
UPDATE findimension
SET beskrivelse = Test629.dbo.findimension.beskrivelse
FROM Test629.dbo.findimension.beskrivelse, beskrivelse
WHERE finfimension.findimensionID =
Test629.dbo.findimension.findimensionID
I'm working on the database I want to update, and I want to update from the
database name 'Test629'. When I run the above statement, it tells me that it
can't find server Test629 in sysservers - which is fair enough, since it
isn't a server but a database...:-).
How do I define this in the right way, so it looks at the "Beskrivelse"
column in the findimension table in the Test629 database.
Hope some of you can help?
Regards
Steen
You referenced the table as Test629.dbo.findimension.beskrivelse - since
there are four parts to the name, the engine assumes that Test629 is a
server name. The last part of the name appears to be a column name - remove
it.
"Steen Persson" <SPE@.REMOVEdatea.dk> wrote in message
news:%23vJ8WZjdEHA.4004@.TK2MSFTNGP10.phx.gbl...
> Hi
> This might be a trivial question, bit I'm not that experienced in updating
> from a table in another database.
> We changed a number of records in a table, and unfortunately we did a
> mistake so too many was changed.
> I've now restored a backup from last night and wants to update the
database
> with the data from the table in the backup.
> The backup has been restored as a new database on the same server as the
> "live" database.
> I'm trying to do it with an UPDATE statement where I update the tesxt in
one
> field with the text from the backup, where the record Id is the same in
both
> tables. My problem is then, that apparently I can't fiugre out to define
> that I want to use data from a different database.
> The code I'm trying to run is :
> UPDATE findimension
> SET beskrivelse = Test629.dbo.findimension.beskrivelse
> FROM Test629.dbo.findimension.beskrivelse, beskrivelse
> WHERE finfimension.findimensionID =
> Test629.dbo.findimension.findimensionID
> I'm working on the database I want to update, and I want to update from
the
> database name 'Test629'. When I run the above statement, it tells me that
it
> can't find server Test629 in sysservers - which is fair enough, since it
> isn't a server but a database...:-).
> How do I define this in the right way, so it looks at the "Beskrivelse"
> column in the findimension table in the Test629 database.
> Hope some of you can help?
> Regards
> Steen
>
|||Thanks...that was it...
Regards
Steen
Scott Morris wrote:[vbcol=seagreen]
> You referenced the table as Test629.dbo.findimension.beskrivelse -
> since there are four parts to the name, the engine assumes that
> Test629 is a server name. The last part of the name appears to be a
> column name - remove it.
> "Steen Persson" <SPE@.REMOVEdatea.dk> wrote in message
> news:%23vJ8WZjdEHA.4004@.TK2MSFTNGP10.phx.gbl...

Accidentailly changed too many records -

Hi
This might be a trivial question, bit I'm not that experienced in updating
from a table in another database.
We changed a number of records in a table, and unfortunately we did a
mistake so too many was changed.
I've now restored a backup from last night and wants to update the database
with the data from the table in the backup.
The backup has been restored as a new database on the same server as the
"live" database.
I'm trying to do it with an UPDATE statement where I update the tesxt in one
field with the text from the backup, where the record Id is the same in both
tables. My problem is then, that apparently I can't fiugre out to define
that I want to use data from a different database.
The code I'm trying to run is :
UPDATE findimension
SET beskrivelse = Test629.dbo.findimension.beskrivelse
FROM Test629.dbo.findimension.beskrivelse, beskrivelse
WHERE finfimension.findimensionID = Test629.dbo.findimension.findimensionID
I'm working on the database I want to update, and I want to update from the
database name 'Test629'. When I run the above statement, it tells me that it
can't find server Test629 in sysservers - which is fair enough, since it
isn't a server but a database...:-).
How do I define this in the right way, so it looks at the "Beskrivelse"
column in the findimension table in the Test629 database.
Hope some of you can help?
Regards
SteenYou referenced the table as Test629.dbo.findimension.beskrivelse - since
there are four parts to the name, the engine assumes that Test629 is a
server name. The last part of the name appears to be a column name - remove
it.
"Steen Persson" <SPE@.REMOVEdatea.dk> wrote in message
news:%23vJ8WZjdEHA.4004@.TK2MSFTNGP10.phx.gbl...
> Hi
> This might be a trivial question, bit I'm not that experienced in updating
> from a table in another database.
> We changed a number of records in a table, and unfortunately we did a
> mistake so too many was changed.
> I've now restored a backup from last night and wants to update the
database
> with the data from the table in the backup.
> The backup has been restored as a new database on the same server as the
> "live" database.
> I'm trying to do it with an UPDATE statement where I update the tesxt in
one
> field with the text from the backup, where the record Id is the same in
both
> tables. My problem is then, that apparently I can't fiugre out to define
> that I want to use data from a different database.
> The code I'm trying to run is :
> UPDATE findimension
> SET beskrivelse = Test629.dbo.findimension.beskrivelse
> FROM Test629.dbo.findimension.beskrivelse, beskrivelse
> WHERE finfimension.findimensionID => Test629.dbo.findimension.findimensionID
> I'm working on the database I want to update, and I want to update from
the
> database name 'Test629'. When I run the above statement, it tells me that
it
> can't find server Test629 in sysservers - which is fair enough, since it
> isn't a server but a database...:-).
> How do I define this in the right way, so it looks at the "Beskrivelse"
> column in the findimension table in the Test629 database.
> Hope some of you can help?
> Regards
> Steen
>|||Thanks...that was it...
Regards
Steen
Scott Morris wrote:
> You referenced the table as Test629.dbo.findimension.beskrivelse -
> since there are four parts to the name, the engine assumes that
> Test629 is a server name. The last part of the name appears to be a
> column name - remove it.
> "Steen Persson" <SPE@.REMOVEdatea.dk> wrote in message
> news:%23vJ8WZjdEHA.4004@.TK2MSFTNGP10.phx.gbl...
>> Hi
>> This might be a trivial question, bit I'm not that experienced in
>> updating from a table in another database.
>> We changed a number of records in a table, and unfortunately we did a
>> mistake so too many was changed.
>> I've now restored a backup from last night and wants to update the
>> database with the data from the table in the backup.
>> The backup has been restored as a new database on the same server as
>> the "live" database.
>> I'm trying to do it with an UPDATE statement where I update the
>> tesxt in one field with the text from the backup, where the record
>> Id is the same in both tables. My problem is then, that apparently I
>> can't fiugre out to define that I want to use data from a different
>> database.
>> The code I'm trying to run is :
>> UPDATE findimension
>> SET beskrivelse = Test629.dbo.findimension.beskrivelse
>> FROM Test629.dbo.findimension.beskrivelse, beskrivelse
>> WHERE finfimension.findimensionID =>> Test629.dbo.findimension.findimensionID
>> I'm working on the database I want to update, and I want to update
>> from the database name 'Test629'. When I run the above statement, it
>> tells me that it can't find server Test629 in sysservers - which is
>> fair enough, since it isn't a server but a database...:-).
>> How do I define this in the right way, so it looks at the
>> "Beskrivelse" column in the findimension table in the Test629
>> database.
>> Hope some of you can help?
>> Regards
>> Steen

Friday, February 24, 2012

Accessing the underlying sql query from the rdl file

Our client uses the report builder to generate reports for collection of employees. We would like to use the employee records in this report to perform some additional processing (such as the list of employees gets assigned to a particular group).

Programmatically, I can retrieve a byte stream from rs.GetReportDefinition( "\myClientEmpReport") and deserialize the stream into Report object (as define by ReportDefinition.xsd).

I can then manually drill down and retrieve the SematicQuery xml from the commandText field.

The problem is how to convert the SemanticQuery format into a T-Sql query that I can run against the view that the report model is based off of.

Is this possible?

Thanks,

Arjay

P.S. Running SQL 2005 Reporting Services, VC# 2005, ASP.Net 2.0.

After attempting to autogenerate serialization classes on the SemanticQuery xml with Xsd and XsdObjectGen, I ended up hand coding some classes that handled recursion. From there, I was able to regenerate the sql query by walking through the filter and grouping sections. While this isn't a generic solution, it works well for my needs because the model I need this for is a single datasource derived from a view.

As a feature request, it sure would be nice to be able get the query string from the reporting engine directly.

Monday, February 13, 2012

Accessing Second Record Within Query

Hello,
I'm attempting to use a query to add up the charges in a record from a
table and two corresponding records in another table and then return a
result if there is a difference between the known total and these
calculations. My query below works fine for adding up charges from a
record in the H_MAIN table and one record from the H_Main_Extra table.
What would I add into this query to access the second corresponding
record in
the H_Main_Extra table?
Thanks in advance for any advice.
Jon
SELECT [TotalSub].Tif, [TotalSub].c1, [TotalSub].c2, [TotalSub].c3,
[TotalSub].c4, [TotalSub].CalcTotal, [TotalSub].ExtractedTotal,
[TotalSub].AmtDiff FROM (SELECT H_MAIN.Tif, H_MAIN.Changes,
IIf(IsNull(H_MAIN.[24f_Charges1]),"0",H_MAIN.[24f_Charges1]) AS c1,
IIf(IsNull(H_MAIN.[24f_Charges2]),"0",H_MAIN.[24f_Charges2]) AS c2,
IIf(IsNull(H_MAIN_Extra.[24f_Charges1]),"0",H_MAIN_Extra.[24f_Charges1])
AS c3,
IIf(IsNull(H_MAIN_Extra.[24f_Charges2]),"0",H_MAIN_Extra.[24f_Charges2])
AS c4,Val([c1])+Val([c2])+Val([c3])+Val([c4
]) AS CalcTotal,
IIf(IsNull(H_MAIN.[28_Total_Charges]),"0",Val(H_MAIN.[28_Total_Charges]))
AS ExtractedTotal, Abs([CalcTotal]-[ExtractedTotal]) AS AmtDiff
FROM H_MAIN LEFT JOIN H_Main_Extra ON H_MAIN.Id =
H_Main_Extra.ParentId) AS TotalSub WHERE ((([TotalSub].[AmtDiff])>0));On 5 Dec 2005 12:12:51 -0800, jon.tjemsland@.gmail.com wrote:

>Hello,
>I'm attempting to use a query to add up the charges in a record from a
>table and two corresponding records in another table and then return a
>result if there is a difference between the known total and these
>calculations. My query below works fine for adding up charges from a
>record in the H_MAIN table and one record from the H_Main_Extra table.
>What would I add into this query to access the second corresponding
>record in
>the H_Main_Extra table?
>Thanks in advance for any advice.
Hi Jon,
The code you posted uses the IIf function. This function does not exist
in SQL Server. I suspect that you're using Access. If I'm right, then
you'll probably get better help in an Access group. (This group is for
SQL Server).
Your question is also not completely clear. You say you want to add a
"second corresponding record", but you don't indicate how I would know
which rows are "corresponding". And if there are more than 2, then how
to determine which are first and seceond?
If the IIf's were an error and this question does concern SQL Server,
then please check www.aspfaq.com/5006 to get more information on the
details you need to include in your post to enable us to help you.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

Sunday, February 12, 2012

accessing records

Hi

Would anyone be able to advise me on the best way in which i am able to display the information from a Search in sqlce database and allow the results be displayed in a specified location.

An example is in my program there is a list of id which the user can search. They search for a record by id so only one record will return. I would like this information to then be displayed in the textboxes which are on the screen.

Any problems understanding what i am trying to do please ask. Any help would be appreciated

Thanks

I'm going to move this thread to a SQLCE forum. You should have better responses there.|||

Most of the .NET Compact Framework controls support data binding to an underlying data source which can be a DataTable populated by a SqlCeDataAdapter. Even simpler, you could query SQL CE/SQL Mobile with the ID the user provides, (ExecuteQuery), and use the SqlCeDataReader to extract the values you wish to display in the textbox. I would recommend you have a look at some of the sample applications available here:

http://msdn.microsoft.com/netframework/programming/netcf/netcfsamples/default.aspx

Darren