I have a database with 8 files. 1 mdf, 1 ldf and 6 ndf files. One of the
ndf file has a torn page. It's a file the contains only indexes. I want to
attach to this db, excluding the bad ndf file. Any way to do that?
using sp_attach_db give me an error that there's an I/O torn page problem
and gives me the ndf file name.
Any way around this?I neglected to say that I really only needed read access to this db.
I managed to find a solution.
I renamed the 8 files (prefixing them with an A_)
I created a new DB with the name I wanted with 8 files named exactly like
the originals that I renamed.
Stopped Sql Server.
Deleted the 8 new DB files.
Renamed the original 8 files back to their original names
re-started sql server.
The DB came up suspect, as I would expect it to. I set the
sysdatabases.status = 32768 for the suspect DB, which put the DB in
emergency mode. I now have read access to the DB.
"Steve" <ss@.Mailinator.com> wrote in message
news:uhqM6ACrGHA.2464@.TK2MSFTNGP03.phx.gbl...
>I have a database with 8 files. 1 mdf, 1 ldf and 6 ndf files. One of the
>ndf file has a torn page. It's a file the contains only indexes. I want to
>attach to this db, excluding the bad ndf file. Any way to do that?
> using sp_attach_db give me an error that there's an I/O torn page problem
> and gives me the ndf file name.
> Any way around this?
>
Showing posts with label contains. Show all posts
Showing posts with label contains. Show all posts
Sunday, March 11, 2012
Database attach corrupt ndf file
I have a database with 8 files. 1 mdf, 1 ldf and 6 ndf files. One of the
ndf file has a torn page. It's a file the contains only indexes. I want to
attach to this db, excluding the bad ndf file. Any way to do that?
using sp_attach_db give me an error that there's an I/O torn page problem
and gives me the ndf file name.
Any way around this?I neglected to say that I really only needed read access to this db.
I managed to find a solution.
I renamed the 8 files (prefixing them with an A_)
I created a new DB with the name I wanted with 8 files named exactly like
the originals that I renamed.
Stopped Sql Server.
Deleted the 8 new DB files.
Renamed the original 8 files back to their original names
re-started sql server.
The DB came up suspect, as I would expect it to. I set the
sysdatabases.status = 32768 for the suspect DB, which put the DB in
emergency mode. I now have read access to the DB.
"Steve" <ss@.Mailinator.com> wrote in message
news:uhqM6ACrGHA.2464@.TK2MSFTNGP03.phx.gbl...
>I have a database with 8 files. 1 mdf, 1 ldf and 6 ndf files. One of the
>ndf file has a torn page. It's a file the contains only indexes. I want to
>attach to this db, excluding the bad ndf file. Any way to do that?
> using sp_attach_db give me an error that there's an I/O torn page problem
> and gives me the ndf file name.
> Any way around this?
>
ndf file has a torn page. It's a file the contains only indexes. I want to
attach to this db, excluding the bad ndf file. Any way to do that?
using sp_attach_db give me an error that there's an I/O torn page problem
and gives me the ndf file name.
Any way around this?I neglected to say that I really only needed read access to this db.
I managed to find a solution.
I renamed the 8 files (prefixing them with an A_)
I created a new DB with the name I wanted with 8 files named exactly like
the originals that I renamed.
Stopped Sql Server.
Deleted the 8 new DB files.
Renamed the original 8 files back to their original names
re-started sql server.
The DB came up suspect, as I would expect it to. I set the
sysdatabases.status = 32768 for the suspect DB, which put the DB in
emergency mode. I now have read access to the DB.
"Steve" <ss@.Mailinator.com> wrote in message
news:uhqM6ACrGHA.2464@.TK2MSFTNGP03.phx.gbl...
>I have a database with 8 files. 1 mdf, 1 ldf and 6 ndf files. One of the
>ndf file has a torn page. It's a file the contains only indexes. I want to
>attach to this db, excluding the bad ndf file. Any way to do that?
> using sp_attach_db give me an error that there's an I/O torn page problem
> and gives me the ndf file name.
> Any way around this?
>
Saturday, February 25, 2012
DataAdapter - SELECT Statement - items in last 30 days
I'm using DataList to return vales stored in an SQL database, of which one of the fields contains the date the record was added.
I am trying to fill the dataset with items only from the last 30 days.
I've tried a few different ways, but all the database rows are returned.
What is the WHERE clause I sholud use to do this??
ThanksTry with the following SQL statement, i belive it should work.
select * from <tablename> where datediff(day, <columnname>, getdate()) < 30
Hope it solves your issue.|||Thanks very much, it worked a treat
Friday, February 24, 2012
Data types
I need to export the name of certain user tables along with the names of their columns and which type the column contains ie. varchar / integer and so on. I can figure out the table and column names - but how do i retrieve information about the data-types in each column ?
My query so far:
--------
select obj.Name as Tbl,Col.Name as Col
from sysobjects obj, syscolumns col
where obj.xtype='U' and obj.Name like 'netop%' and obj.id=col.id
--------
Thx. in advanceSELECT A.TABLE_NAME, B.COLUMN_NAME, DATA_TYPE
FROM INFORMATION_SCHEMA.TABLES AS A
INNER JOIN INFORMATION_SCHEMA.COLUMNS AS B
ON A.TABLE_NAME = B.TABLE_NAME
WHERE A.TABLE_NAME = 'yourTable'
Very useful views and I strongly recommend that your read more about them on BOL.|||WOW - that was fast - thanks a lot|||Beware of objects with the same name and different owners! Include a join on TABLE_SCHEMA to be safe:
SELECT A.*, A.TABLE_NAME, B.COLUMN_NAME, DATA_TYPE
FROM INFORMATION_SCHEMA.TABLES AS A
INNER JOIN INFORMATION_SCHEMA.COLUMNS AS B
ON A.TABLE_NAME = B.TABLE_NAME
AND A.TABLE_SCHEMA = B.TABLE_SCHEMA
blindman|||Good point and well spotted.
My query so far:
--------
select obj.Name as Tbl,Col.Name as Col
from sysobjects obj, syscolumns col
where obj.xtype='U' and obj.Name like 'netop%' and obj.id=col.id
--------
Thx. in advanceSELECT A.TABLE_NAME, B.COLUMN_NAME, DATA_TYPE
FROM INFORMATION_SCHEMA.TABLES AS A
INNER JOIN INFORMATION_SCHEMA.COLUMNS AS B
ON A.TABLE_NAME = B.TABLE_NAME
WHERE A.TABLE_NAME = 'yourTable'
Very useful views and I strongly recommend that your read more about them on BOL.|||WOW - that was fast - thanks a lot|||Beware of objects with the same name and different owners! Include a join on TABLE_SCHEMA to be safe:
SELECT A.*, A.TABLE_NAME, B.COLUMN_NAME, DATA_TYPE
FROM INFORMATION_SCHEMA.TABLES AS A
INNER JOIN INFORMATION_SCHEMA.COLUMNS AS B
ON A.TABLE_NAME = B.TABLE_NAME
AND A.TABLE_SCHEMA = B.TABLE_SCHEMA
blindman|||Good point and well spotted.
Friday, February 17, 2012
Data type conversion
I have one column which contains numbers [but the column is in char format]
What will be the proper SQL query to sort that column ? If i use order by
clause, the records are sorted in characted method, i.e 40,50 not 40,41Arsalan,
Try:
ORDER BY LTRIM(RTRIM(column))
HTH
Jerry
"Arsalan" <arsalan_aslam@.hotmail.com> wrote in message
news:%23o3VP5czFHA.3836@.TK2MSFTNGP10.phx.gbl...
>I have one column which contains numbers [but the column is in char format]
> What will be the proper SQL query to sort that column ? If i use order by
> clause, the records are sorted in characted method, i.e 40,50 not 40,41
>|||Doesnt work.
LTRIM and RTRIM will remove the space, but doesnt sort properly.
MY records are like this
40
41
42
.
..
..
50
when i use order by clause, its sorts like this --> 40,50 [bec if character
field]. How do I sort the numeric part of the character field properly?
"Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
news:%23G6I3%23czFHA.3832@.TK2MSFTNGP10.phx.gbl...
> Arsalan,
> Try:
>
> ORDER BY LTRIM(RTRIM(column))
> HTH
> Jerry
> "Arsalan" <arsalan_aslam@.hotmail.com> wrote in message
> news:%23o3VP5czFHA.3836@.TK2MSFTNGP10.phx.gbl...
>|||create table #t(s char(4))
insert into #t(s) values('5')
insert into #t(s) values('50')
insert into #t(s) values('40')
insert into #t(s) values('41')
select s
from #t
order by s
select cast(s as int) p
from #t
order by p
drop table #t
Payson
Arsalan wrote:
> Doesnt work.
> LTRIM and RTRIM will remove the space, but doesnt sort properly.
> MY records are like this
> 40
> 41
> 42
> .
> ..
> ..
> 50
> when i use order by clause, its sorts like this --> 40,50 [bec if characte
r
> field]. How do I sort the numeric part of the character field properly?
>
> "Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
> news:%23G6I3%23czFHA.3832@.TK2MSFTNGP10.phx.gbl...|||order by cast(ltrim(rtrim(column as int)))
"Arsalan" <arsalan_aslam@.hotmail.com> wrote in message
news:OKxzKOdzFHA.3924@.TK2MSFTNGP14.phx.gbl...
> Doesnt work.
> LTRIM and RTRIM will remove the space, but doesnt sort properly.
> MY records are like this
> 40
> 41
> 42
> .
> ..
> ..
> 50
> when i use order by clause, its sorts like this --> 40,50 [bec if
> character field]. How do I sort the numeric part of the character field
> properly?
>
> "Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
> news:%23G6I3%23czFHA.3832@.TK2MSFTNGP10.phx.gbl...
>|||Arsalan,
Worked on my server. Try the examples listed in the following posts with
CAST --> INT.
HTH
Jerry
"Arsalan" <arsalan_aslam@.hotmail.com> wrote in message
news:OKxzKOdzFHA.3924@.TK2MSFTNGP14.phx.gbl...
> Doesnt work.
> LTRIM and RTRIM will remove the space, but doesnt sort properly.
> MY records are like this
> 40
> 41
> 42
> .
> ..
> ..
> 50
> when i use order by clause, its sorts like this --> 40,50 [bec if
> character field]. How do I sort the numeric part of the character field
> properly?
>
> "Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
> news:%23G6I3%23czFHA.3832@.TK2MSFTNGP10.phx.gbl...
>|||Thanks
"Jay" <msnews.microsoft.com> wrote in message
news:unWe6ddzFHA.3152@.TK2MSFTNGP10.phx.gbl...
> order by cast(ltrim(rtrim(column as int)))
>
> "Arsalan" <arsalan_aslam@.hotmail.com> wrote in message
> news:OKxzKOdzFHA.3924@.TK2MSFTNGP14.phx.gbl...
>
What will be the proper SQL query to sort that column ? If i use order by
clause, the records are sorted in characted method, i.e 40,50 not 40,41Arsalan,
Try:
ORDER BY LTRIM(RTRIM(column))
HTH
Jerry
"Arsalan" <arsalan_aslam@.hotmail.com> wrote in message
news:%23o3VP5czFHA.3836@.TK2MSFTNGP10.phx.gbl...
>I have one column which contains numbers [but the column is in char format]
> What will be the proper SQL query to sort that column ? If i use order by
> clause, the records are sorted in characted method, i.e 40,50 not 40,41
>|||Doesnt work.
LTRIM and RTRIM will remove the space, but doesnt sort properly.
MY records are like this
40
41
42
.
..
..
50
when i use order by clause, its sorts like this --> 40,50 [bec if character
field]. How do I sort the numeric part of the character field properly?
"Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
news:%23G6I3%23czFHA.3832@.TK2MSFTNGP10.phx.gbl...
> Arsalan,
> Try:
>
> ORDER BY LTRIM(RTRIM(column))
> HTH
> Jerry
> "Arsalan" <arsalan_aslam@.hotmail.com> wrote in message
> news:%23o3VP5czFHA.3836@.TK2MSFTNGP10.phx.gbl...
>|||create table #t(s char(4))
insert into #t(s) values('5')
insert into #t(s) values('50')
insert into #t(s) values('40')
insert into #t(s) values('41')
select s
from #t
order by s
select cast(s as int) p
from #t
order by p
drop table #t
Payson
Arsalan wrote:
> Doesnt work.
> LTRIM and RTRIM will remove the space, but doesnt sort properly.
> MY records are like this
> 40
> 41
> 42
> .
> ..
> ..
> 50
> when i use order by clause, its sorts like this --> 40,50 [bec if characte
r
> field]. How do I sort the numeric part of the character field properly?
>
> "Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
> news:%23G6I3%23czFHA.3832@.TK2MSFTNGP10.phx.gbl...|||order by cast(ltrim(rtrim(column as int)))
"Arsalan" <arsalan_aslam@.hotmail.com> wrote in message
news:OKxzKOdzFHA.3924@.TK2MSFTNGP14.phx.gbl...
> Doesnt work.
> LTRIM and RTRIM will remove the space, but doesnt sort properly.
> MY records are like this
> 40
> 41
> 42
> .
> ..
> ..
> 50
> when i use order by clause, its sorts like this --> 40,50 [bec if
> character field]. How do I sort the numeric part of the character field
> properly?
>
> "Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
> news:%23G6I3%23czFHA.3832@.TK2MSFTNGP10.phx.gbl...
>|||Arsalan,
Worked on my server. Try the examples listed in the following posts with
CAST --> INT.
HTH
Jerry
"Arsalan" <arsalan_aslam@.hotmail.com> wrote in message
news:OKxzKOdzFHA.3924@.TK2MSFTNGP14.phx.gbl...
> Doesnt work.
> LTRIM and RTRIM will remove the space, but doesnt sort properly.
> MY records are like this
> 40
> 41
> 42
> .
> ..
> ..
> 50
> when i use order by clause, its sorts like this --> 40,50 [bec if
> character field]. How do I sort the numeric part of the character field
> properly?
>
> "Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
> news:%23G6I3%23czFHA.3832@.TK2MSFTNGP10.phx.gbl...
>|||Thanks
"Jay" <msnews.microsoft.com> wrote in message
news:unWe6ddzFHA.3152@.TK2MSFTNGP10.phx.gbl...
> order by cast(ltrim(rtrim(column as int)))
>
> "Arsalan" <arsalan_aslam@.hotmail.com> wrote in message
> news:OKxzKOdzFHA.3924@.TK2MSFTNGP14.phx.gbl...
>
Subscribe to:
Posts (Atom)