Showing posts with label row. Show all posts
Showing posts with label row. Show all posts

Friday, March 30, 2012

How to remove rows where only part of the row is duplicated

Hi,

I've got a db table containing 5 columns(excluding id) consisting of
1.) First Half of a UK postcode
2.) Town name to which postcode belongs
3.) Latitude of Postcode
4.) Longitude of Postcode
5.) Second Part of the Postcode

I want to select columns 1,2,3 and 4, but once only. There are often
several entries where 1 and 2 are the same but 3 and 4 are different
i.e.
WA1Bewsey and Whitecross53.386492-2.596847
WA1Bewsey and Whitecross53.388203-2.590961
WA1Bewsey and Whitecross53.388875-2.598504
WA1Fairfield and Howley53.388455-2.581701
WA1Fairfield and Howley53.396117-2.571789

My current query is
SELECT DISTINCT Postcode, Town, latitude, longitude
FROM Postcode
WHERE Postcode.Postcode = 'wa1'
ORDER BY Postcode, Town

However as latitude and longitude differ on each line DISTINCT does
not do what I'm looking for.
Can anybody suggest a way changing the query to just give the first
instance of each Postcode/Town combo?
I.E.
WA1Bewsey and Whitecross53.386492-2.596847
WA1Fairfield and Howley53.388455-2.581701

Many thanks!
DrewThere isn't really any 'first' instance unless you
define your own ordering. However, assuming you have a unique ID
column
this should work

SELECT a.Postcode, a.Town, a.latitude, a.longitude
FROM Postcode a
WHERE NOT EXISTS (SELECT * FROM Postcode b
WHERE b.Postcode=a.Postcode
AND b.Town=a.Town
AND b.ID>a.ID)
ORDER BY a.Postcode, a.Town|||(andylole@.gmail.com) writes:

Quote:

Originally Posted by

I've got a db table containing 5 columns(excluding id) consisting of
1.) First Half of a UK postcode
2.) Town name to which postcode belongs
3.) Latitude of Postcode
4.) Longitude of Postcode
5.) Second Part of the Postcode
>
I want to select columns 1,2,3 and 4, but once only. There are often
several entries where 1 and 2 are the same but 3 and 4 are different
i.e.
WA1 Bewsey and Whitecross 53.386492 -2.596847
WA1 Bewsey and Whitecross 53.388203 -2.590961
WA1 Bewsey and Whitecross 53.388875 -2.598504
WA1 Fairfield and Howley 53.388455 -2.581701
WA1 Fairfield and Howley 53.396117 -2.571789
>
My current query is
SELECT DISTINCT Postcode, Town, latitude, longitude
FROM Postcode
WHERE Postcode.Postcode = 'wa1'
ORDER BY Postcode, Town
>
However as latitude and longitude differ on each line DISTINCT does
not do what I'm looking for.
Can anybody suggest a way changing the query to just give the first
instance of each Postcode/Town combo?


A simple way out would be:

SELECT Postcode, Town, AVG(latitude), AVG(longitude)
FROM Postcode
GROUP BY Postcode, Town

Of course, this yield data that is not in the table at all, but it's a
reasonable assumption that the different lat/long values are in the same
proximity. And if they are not, you have a much bigger problem anyway.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Erland,

Your solution is perfect!
Many thanks to all for helping.
Cheers,
Andy.

Monday, March 26, 2012

How to remove {CR}{LF} and Tab {t} characters from source data?

I have built a SSIS package that reads in data from a SQL Server 2005 source database into a flat file destination. The Row Delimiter is {CR}{LF}. The Column Delimiter is Tab {t}.

The data being read from the SQL Server database contains both {CR}{LF} and Tab {t} characters in various fields on several rows.

How can I process the input data from the SQL Server to remove these characters before passing it to the destination output file?

Sorry if this is obvious to all, but I am only just starting with SSIS...

Many thanks

Adrian

If you have the data in a DT_STR ro DT_WSTR column, you can use the Derived Column transform with a REPLACE() function to replace those characters with empty strings.

Otherwise, you might want to use a Script component.

Thanks
Mark

Friday, March 9, 2012

How to Read SQL Transaction Log ...

Good day All
I am trying to read & Understand SQL Transaction Log.
For Online Log, I use DBCC LOG...but how to understand what Row Data means.
Also How to read BackedUp (Offline) Log File?
Any help would be much appreciated.
Ramanuj Brahmachary
Database Administrator
[ MCDBA, MCSE, MCSD ]
Hi,
Try using the 3rd party tool Logexplorer from Lumigent
www.lumigent.com
Thanks
Hari
SQL Server MVP
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> Good day All
> I am trying to read & Understand SQL Transaction Log.
> For Online Log, I use DBCC LOG...but how to understand what Row Data
> means.
> Also How to read BackedUp (Offline) Log File?
> Any help would be much appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]
|||This is undocumented. There are third party tools that help you interpret
the log, such as Lumigent.
Wei Xiao [MSFT]
SQL Server Storage Engine Development
http://blogs.msdn.com/weix
This posting is provided "AS IS" with no warranties, and confers no rights.
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> Good day All
> I am trying to read & Understand SQL Transaction Log.
> For Online Log, I use DBCC LOG...but how to understand what Row Data
> means.
> Also How to read BackedUp (Offline) Log File?
> Any help would be much appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]
|||I have some 3:rd party tools listed on my links page:
http://www.karaszi.com/SQLServer/links.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> Good day All
> I am trying to read & Understand SQL Transaction Log.
> For Online Log, I use DBCC LOG...but how to understand what Row Data means.
> Also How to read BackedUp (Offline) Log File?
> Any help would be much appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]
|||There are a number of tools available
http://aspfaq.com/show.asp?id=2449
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> Good day All
> I am trying to read & Understand SQL Transaction Log.
> For Online Log, I use DBCC LOG...but how to understand what Row Data
> means.
> Also How to read BackedUp (Offline) Log File?
> Any help would be much appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]
|||Thanks very much for the overwhelming response.
My apologies, I havent mentioned that I tried some 3rd party Log Readers &
what I understand is they do very similar but are able to interprete the Row
Data field output of DBCC LOG. I was trying to find out if I can also
interprete the value in Row Data.
Any help in interpreting the field [Row Data] of DBCC LOG is much
appreciated.
Ramanuj Brahmachary
Database Administrator, Bangalore
[ MCDBA, MCSE, MCSD ]
"Jasper Smith" wrote:

> There are a number of tools available
> http://aspfaq.com/show.asp?id=2449
> --
> HTH
> Jasper Smith (SQL Server MVP)
> http://www.sqldbatips.com
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
> "Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
> news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
>
>
|||Also how to read BackedUp transaction LOG from file on disk.
Ramanuj Brahmachary
Database Administrator
[ MCDBA, MCSE, MCSD ]
"Ramanuj" wrote:
[vbcol=seagreen]
> Thanks very much for the overwhelming response.
> My apologies, I havent mentioned that I tried some 3rd party Log Readers &
> what I understand is they do very similar but are able to interprete the Row
> Data field output of DBCC LOG. I was trying to find out if I can also
> interprete the value in Row Data.
> Any help in interpreting the field [Row Data] of DBCC LOG is much
> appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator, Bangalore
> [ MCDBA, MCSE, MCSD ]
>
> "Jasper Smith" wrote:
|||There is no documentation for interpreting the active log or a log backup. I have not seen any
scripts or anything to help with this.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:162E993E-BBA0-4AD0-858B-672E8D6C0198@.microsoft.com...[vbcol=seagreen]
> Also how to read BackedUp transaction LOG from file on disk.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]
>
> "Ramanuj" wrote:
|||wandering how 3rd party vendors interpreting it....
Ramanuj Brahmachary
Database Administrator
[ MCDBA, MCSE, MCSD ]
"Tibor Karaszi" wrote:

> There is no documentation for interpreting the active log or a log backup. I have not seen any
> scripts or anything to help with this.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
> news:162E993E-BBA0-4AD0-858B-672E8D6C0198@.microsoft.com...
>
>
|||Thanks
Ramanuj Brahmachary
Database Administrator
[ MCDBA, MCSE, MCSD ]
"Tibor Karaszi" wrote:

> I have some 3:rd party tools listed on my links page:
> http://www.karaszi.com/SQLServer/links.asp
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
> news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
>
>

How to Read SQL Transaction Log ...

Good day All
I am trying to read & Understand SQL Transaction Log.
For Online Log, I use DBCC LOG...but how to understand what Row Data means.
Also How to read BackedUp (Offline) Log File?
Any help would be much appreciated.
--
Ramanuj Brahmachary
Database Administrator
[ MCDBA, MCSE, MCSD ]Hi,
Try using the 3rd party tool Logexplorer from Lumigent
www.lumigent.com
Thanks
Hari
SQL Server MVP
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> Good day All
> I am trying to read & Understand SQL Transaction Log.
> For Online Log, I use DBCC LOG...but how to understand what Row Data
> means.
> Also How to read BackedUp (Offline) Log File?
> Any help would be much appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]|||This is undocumented. There are third party tools that help you interpret
the log, such as Lumigent.
--
Wei Xiao [MSFT]
SQL Server Storage Engine Development
http://blogs.msdn.com/weix
This posting is provided "AS IS" with no warranties, and confers no rights.
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> Good day All
> I am trying to read & Understand SQL Transaction Log.
> For Online Log, I use DBCC LOG...but how to understand what Row Data
> means.
> Also How to read BackedUp (Offline) Log File?
> Any help would be much appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]|||I have some 3:rd party tools listed on my links page:
http://www.karaszi.com/SQLServer/links.asp
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> Good day All
> I am trying to read & Understand SQL Transaction Log.
> For Online Log, I use DBCC LOG...but how to understand what Row Data means.
> Also How to read BackedUp (Offline) Log File?
> Any help would be much appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]|||There are a number of tools available
http://aspfaq.com/show.asp?id=2449
--
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> Good day All
> I am trying to read & Understand SQL Transaction Log.
> For Online Log, I use DBCC LOG...but how to understand what Row Data
> means.
> Also How to read BackedUp (Offline) Log File?
> Any help would be much appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]|||Thanks very much for the overwhelming response.
My apologies, I havent mentioned that I tried some 3rd party Log Readers &
what I understand is they do very similar but are able to interprete the Row
Data field output of DBCC LOG. I was trying to find out if I can also
interprete the value in Row Data.
Any help in interpreting the field [Row Data] of DBCC LOG is much
appreciated.
--
Ramanuj Brahmachary
Database Administrator, Bangalore
[ MCDBA, MCSE, MCSD ]
"Jasper Smith" wrote:
> There are a number of tools available
> http://aspfaq.com/show.asp?id=2449
> --
> HTH
> Jasper Smith (SQL Server MVP)
> http://www.sqldbatips.com
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
> "Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
> news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> > Good day All
> > I am trying to read & Understand SQL Transaction Log.
> > For Online Log, I use DBCC LOG...but how to understand what Row Data
> > means.
> > Also How to read BackedUp (Offline) Log File?
> >
> > Any help would be much appreciated.
> > --
> > Ramanuj Brahmachary
> > Database Administrator
> > [ MCDBA, MCSE, MCSD ]
>
>|||Also how to read BackedUp transaction LOG from file on disk.
--
Ramanuj Brahmachary
Database Administrator
[ MCDBA, MCSE, MCSD ]
"Ramanuj" wrote:
> Thanks very much for the overwhelming response.
> My apologies, I havent mentioned that I tried some 3rd party Log Readers &
> what I understand is they do very similar but are able to interprete the Row
> Data field output of DBCC LOG. I was trying to find out if I can also
> interprete the value in Row Data.
> Any help in interpreting the field [Row Data] of DBCC LOG is much
> appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator, Bangalore
> [ MCDBA, MCSE, MCSD ]
>
> "Jasper Smith" wrote:
> > There are a number of tools available
> > http://aspfaq.com/show.asp?id=2449
> >
> > --
> > HTH
> >
> > Jasper Smith (SQL Server MVP)
> > http://www.sqldbatips.com
> > I support PASS - the definitive, global
> > community for SQL Server professionals -
> > http://www.sqlpass.org
> >
> > "Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
> > news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> > > Good day All
> > > I am trying to read & Understand SQL Transaction Log.
> > > For Online Log, I use DBCC LOG...but how to understand what Row Data
> > > means.
> > > Also How to read BackedUp (Offline) Log File?
> > >
> > > Any help would be much appreciated.
> > > --
> > > Ramanuj Brahmachary
> > > Database Administrator
> > > [ MCDBA, MCSE, MCSD ]
> >
> >
> >|||There is no documentation for interpreting the active log or a log backup. I have not seen any
scripts or anything to help with this.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:162E993E-BBA0-4AD0-858B-672E8D6C0198@.microsoft.com...
> Also how to read BackedUp transaction LOG from file on disk.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]
>
> "Ramanuj" wrote:
>> Thanks very much for the overwhelming response.
>> My apologies, I havent mentioned that I tried some 3rd party Log Readers &
>> what I understand is they do very similar but are able to interprete the Row
>> Data field output of DBCC LOG. I was trying to find out if I can also
>> interprete the value in Row Data.
>> Any help in interpreting the field [Row Data] of DBCC LOG is much
>> appreciated.
>> --
>> Ramanuj Brahmachary
>> Database Administrator, Bangalore
>> [ MCDBA, MCSE, MCSD ]
>>
>> "Jasper Smith" wrote:
>> > There are a number of tools available
>> > http://aspfaq.com/show.asp?id=2449
>> >
>> > --
>> > HTH
>> >
>> > Jasper Smith (SQL Server MVP)
>> > http://www.sqldbatips.com
>> > I support PASS - the definitive, global
>> > community for SQL Server professionals -
>> > http://www.sqlpass.org
>> >
>> > "Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
>> > news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
>> > > Good day All
>> > > I am trying to read & Understand SQL Transaction Log.
>> > > For Online Log, I use DBCC LOG...but how to understand what Row Data
>> > > means.
>> > > Also How to read BackedUp (Offline) Log File?
>> > >
>> > > Any help would be much appreciated.
>> > > --
>> > > Ramanuj Brahmachary
>> > > Database Administrator
>> > > [ MCDBA, MCSE, MCSD ]
>> >
>> >
>> >|||wandering how 3rd party vendors interpreting it....
--
Ramanuj Brahmachary
Database Administrator
[ MCDBA, MCSE, MCSD ]
"Tibor Karaszi" wrote:
> There is no documentation for interpreting the active log or a log backup. I have not seen any
> scripts or anything to help with this.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
> news:162E993E-BBA0-4AD0-858B-672E8D6C0198@.microsoft.com...
> > Also how to read BackedUp transaction LOG from file on disk.
> > --
> > Ramanuj Brahmachary
> > Database Administrator
> > [ MCDBA, MCSE, MCSD ]
> >
> >
> > "Ramanuj" wrote:
> >
> >> Thanks very much for the overwhelming response.
> >>
> >> My apologies, I havent mentioned that I tried some 3rd party Log Readers &
> >> what I understand is they do very similar but are able to interprete the Row
> >> Data field output of DBCC LOG. I was trying to find out if I can also
> >> interprete the value in Row Data.
> >> Any help in interpreting the field [Row Data] of DBCC LOG is much
> >> appreciated.
> >> --
> >> Ramanuj Brahmachary
> >> Database Administrator, Bangalore
> >> [ MCDBA, MCSE, MCSD ]
> >>
> >>
> >> "Jasper Smith" wrote:
> >>
> >> > There are a number of tools available
> >> > http://aspfaq.com/show.asp?id=2449
> >> >
> >> > --
> >> > HTH
> >> >
> >> > Jasper Smith (SQL Server MVP)
> >> > http://www.sqldbatips.com
> >> > I support PASS - the definitive, global
> >> > community for SQL Server professionals -
> >> > http://www.sqlpass.org
> >> >
> >> > "Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
> >> > news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> >> > > Good day All
> >> > > I am trying to read & Understand SQL Transaction Log.
> >> > > For Online Log, I use DBCC LOG...but how to understand what Row Data
> >> > > means.
> >> > > Also How to read BackedUp (Offline) Log File?
> >> > >
> >> > > Any help would be much appreciated.
> >> > > --
> >> > > Ramanuj Brahmachary
> >> > > Database Administrator
> >> > > [ MCDBA, MCSE, MCSD ]
> >> >
> >> >
> >> >
>
>|||Thanks
--
Ramanuj Brahmachary
Database Administrator
[ MCDBA, MCSE, MCSD ]
"Tibor Karaszi" wrote:
> I have some 3:rd party tools listed on my links page:
> http://www.karaszi.com/SQLServer/links.asp
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
> news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> > Good day All
> > I am trying to read & Understand SQL Transaction Log.
> > For Online Log, I use DBCC LOG...but how to understand what Row Data means.
> > Also How to read BackedUp (Offline) Log File?
> >
> > Any help would be much appreciated.
> > --
> > Ramanuj Brahmachary
> > Database Administrator
> > [ MCDBA, MCSE, MCSD ]
>
>|||Thanks
--
Ramanuj Brahmachary
Database Administrator
[ MCDBA, MCSE, MCSD ]
"Hari Prasad" wrote:
> Hi,
> Try using the 3rd party tool Logexplorer from Lumigent
> www.lumigent.com
> Thanks
> Hari
> SQL Server MVP
> "Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
> news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> > Good day All
> > I am trying to read & Understand SQL Transaction Log.
> > For Online Log, I use DBCC LOG...but how to understand what Row Data
> > means.
> > Also How to read BackedUp (Offline) Log File?
> >
> > Any help would be much appreciated.
> > --
> > Ramanuj Brahmachary
> > Database Administrator
> > [ MCDBA, MCSE, MCSD ]
>
>

How to Read SQL Transaction Log ...

Good day All
I am trying to read & Understand SQL Transaction Log.
For Online Log, I use DBCC LOG...but how to understand what Row Data means.
Also How to read BackedUp (Offline) Log File?
Any help would be much appreciated.
--
Ramanuj Brahmachary
Database Administrator
[ MCDBA, MCSE, MCSD ]Hi,
Try using the 3rd party tool Logexplorer from Lumigent
www.lumigent.com
Thanks
Hari
SQL Server MVP
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> Good day All
> I am trying to read & Understand SQL Transaction Log.
> For Online Log, I use DBCC LOG...but how to understand what Row Data
> means.
> Also How to read BackedUp (Offline) Log File?
> Any help would be much appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]|||This is undocumented. There are third party tools that help you interpret
the log, such as Lumigent.
Wei Xiao [MSFT]
SQL Server Storage Engine Development
http://blogs.msdn.com/weix
This posting is provided "AS IS" with no warranties, and confers no rights.
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> Good day All
> I am trying to read & Understand SQL Transaction Log.
> For Online Log, I use DBCC LOG...but how to understand what Row Data
> means.
> Also How to read BackedUp (Offline) Log File?
> Any help would be much appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]|||I have some 3:rd party tools listed on my links page:
http://www.karaszi.com/SQLServer/links.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> Good day All
> I am trying to read & Understand SQL Transaction Log.
> For Online Log, I use DBCC LOG...but how to understand what Row Data mean
s.
> Also How to read BackedUp (Offline) Log File?
> Any help would be much appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]|||There are a number of tools available
http://aspfaq.com/show.asp?id=2449
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
> Good day All
> I am trying to read & Understand SQL Transaction Log.
> For Online Log, I use DBCC LOG...but how to understand what Row Data
> means.
> Also How to read BackedUp (Offline) Log File?
> Any help would be much appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]|||Thanks very much for the overwhelming response.
My apologies, I havent mentioned that I tried some 3rd party Log Readers &
what I understand is they do very similar but are able to interprete the Row
Data field output of DBCC LOG. I was trying to find out if I can also
interprete the value in Row Data.
Any help in interpreting the field [Row Data] of DBCC LOG is much
appreciated.
--
Ramanuj Brahmachary
Database Administrator, Bangalore
[ MCDBA, MCSE, MCSD ]
"Jasper Smith" wrote:

> There are a number of tools available
> http://aspfaq.com/show.asp?id=2449
> --
> HTH
> Jasper Smith (SQL Server MVP)
> http://www.sqldbatips.com
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
> "Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
> news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
>
>|||Also how to read BackedUp transaction LOG from file on disk.
--
Ramanuj Brahmachary
Database Administrator
[ MCDBA, MCSE, MCSD ]
"Ramanuj" wrote:
[vbcol=seagreen]
> Thanks very much for the overwhelming response.
> My apologies, I havent mentioned that I tried some 3rd party Log Readers &
> what I understand is they do very similar but are able to interprete the R
ow
> Data field output of DBCC LOG. I was trying to find out if I can also
> interprete the value in Row Data.
> Any help in interpreting the field [Row Data] of DBCC LOG is much
> appreciated.
> --
> Ramanuj Brahmachary
> Database Administrator, Bangalore
> [ MCDBA, MCSE, MCSD ]
>
> "Jasper Smith" wrote:
>|||There is no documentation for interpreting the active log or a log backup. I
have not seen any
scripts or anything to help with this.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
news:162E993E-BBA0-4AD0-858B-672E8D6C0198@.microsoft.com...[vbcol=seagreen]
> Also how to read BackedUp transaction LOG from file on disk.
> --
> Ramanuj Brahmachary
> Database Administrator
> [ MCDBA, MCSE, MCSD ]
>
> "Ramanuj" wrote:
>|||wandering how 3rd party vendors interpreting it....
--
Ramanuj Brahmachary
Database Administrator
[ MCDBA, MCSE, MCSD ]
"Tibor Karaszi" wrote:

> There is no documentation for interpreting the active log or a log backup.
I have not seen any
> scripts or anything to help with this.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
> news:162E993E-BBA0-4AD0-858B-672E8D6C0198@.microsoft.com...
>
>|||Thanks
--
Ramanuj Brahmachary
Database Administrator
[ MCDBA, MCSE, MCSD ]
"Tibor Karaszi" wrote:

> I have some 3:rd party tools listed on my links page:
> http://www.karaszi.com/SQLServer/links.asp
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Ramanuj" <Ramanuj@.discussions.microsoft.com> wrote in message
> news:68B9091E-649C-45C9-8B5B-4F9606FCC876@.microsoft.com...
>
>

How to read just inserted auto incremented primary key to use it as parameter?

Hi. After inserting data (new row) by using DetailsView control, how to read auto incremented primary key (identity) of this new row from sql database to use it as parameter passed to stored procedure?

Or in other way. I need to insert new row (let's call them parent row) in one table by using DetailsView control. This is quite easy. But after inserting I need to read primary key of this new row to insert new child row in other table. Both tables are in relation. How to do this? Any suggestions? Pawel.

Hi Pawelek,

Since the ID (primary key) is configured as an auto incremented field, the last row inserted will always have the maximum number.

You could write a stored procedure which selects the maximum ID number ( SELECT max(ID) from ParentRowsTable ) and returns it.
Then in your code you can execute the SP after you insert a row and you get the max. ID of the parent rows.

Greets,

Wim

|||Hi. I'm afraid that this is a risky business. What if in the same time some other people will insert new row which becomes row with maximum number? Is it possible such situation? Regards. Pawel.|||

Hi. you can return the@.@.IDENTITY

INSERT INTO [dbo].[table] (name, phone)VALUES ("test", "tttt")Return@.@.IDENTITY
|||I would recommend using SCOPE_IDENTITY() instead of @.@.IDENTITY. The former maintains the scope. Check out BOL for more info.

Wednesday, March 7, 2012

How to read a single row in a strongly types dataset?

I'm using strongly typed datasets in my first ASP.NET 2.0 web application. I come from ASP Classic, not an earlier version of .NET, and feel like I'm in another world. I'm slowly getting my head around datasets, but one thing I can't find any information on is how to read the data in a single record?

I'm not talking about for next loops, or accessing row information as a repeater or other control is filled. I'm talking about reading the data returned by a method that returns a table containing a single record. This is what I have:

Dim BookAdapter As New BooksTableAdapters.BooksBBTableAdapter
Dim organizations As Books.BooksBBDataTable
Dim organization As Books.BooksBBRow

organizations = BookAdapter.GetDataByOneBook(sBookID)

Dim sDropOff As String
Dim sOrganization As String
Dim sContact
For Each organization In organizations
If organization.DropOff = 1 Then
sDropOff = "True"
Else
sDropOff = "False"
End If
sOrganization = organization.Organization
sContact = organization.ContactName
Next

sBody = "Books Listing" & Chr(10) & Chr(10)
sBody = sBody & "Organization: " & sOrganization & Chr(10)
sBody = sBody & "Contact Name: " & sContact & Chr(10)
sBody = sBody & "Email: " & organization.Email & Chr(10)
sBody = sBody & "Phone Number: " & organization.Phone & Chr(10)

I'm using the FOR NEXT, but this is silly since I only have one record. GetDataByOneBook(sBookID) does exactly what is says, it returns a single book with a specific bookID.

Not only is this silly, it doesn't work. Using sContact as an example, it's Dim'd as a string. In the FOR NEXT loop, organization.ContactName has the right value, and it appears to be assigned to sContact correctly, but when I try to use sContact in sBody, I get an error saying that sContact has been used before it is assigned a value. Maybe the variables lose their scope outside the loop? Maybe I could get around this by building sBody inside the loop, but there has to be a better way!

Diane

I believe you want to do something like the following with your code:

1Dim BookAdapterAs New BooksTableAdapters.BooksBBTableAdapter2Dim organizationsAs Books.BooksBBDataTable3Dim organizationAs Books.BooksBBRow45 organizations = BookAdapter.GetDataByOneBook(sBookID)67If (organizations.Count > 0)Then89 sBody ="Books Listing" & Chr(10) & Chr(10)10 sBody = sBody &"Organization: " & organizations[0].Organization & Chr(10)11 sBody = sBody &"Contact Name: " & organizations[0].ContactName & Chr(10)12 sBody = sBody &"Email: " & organizations[0].Email & Chr(10)13 sBody = sBody &"Phone Number: " & organizations[0].Phone & Chr(10)1415End If
I do not have your XSD, so I can not test this.
|||

Thank you!

Diane

Friday, February 24, 2012

How to query xml data in column type xml

How can I query xml data in column type xml using an xml schema from the same table row in the xmlschema column and return values(not xml) to insert into a seperate table

XML Data Table

C1 =RecordID (int)

C2 =XMLData (xml)

C3 = XMLSchema(xml)

How can I query the XML data using the xmlshema column

and return values(not xml) to insert into table 2

Table 2

C1 = RecordID

C2 = User

C3 = date

thanks

I think you are looking for the XQuery "nodes()" function if I understand you correctly. It sounds like you want to reach into the column that is storing the schema, extract scalar values from that schema and store it in a relational table. If this is what you are trying to do, then the nodes() function should work for you.

Here is an example using the nodes() function on the xml data type.

http://msdn2.microsoft.com/en-us/ms188282.aspx

Once you get the data into relational form, you can CURSOR over it and call your INSERT statement with parameters, use INSERT INTO ... SELECT, or generate dynamic SQL.