Showing posts with label delete. Show all posts
Showing posts with label delete. Show all posts

Wednesday, February 15, 2012

Empty data files completely?

Hi,
Is there a way to completely empty some data files in the same filegroup so
I can delete them?
thanx
--
remove RmEaMkOnViEoTHvIoS from my email
svi komentari i razmisljanja su moja kao pojedinca i nikako se ne smiju
povezivati sa tvrtkom u kojoj radim
Yep. DBCC SHRINKFILE using the EMPTYFILE option. Then you can use ALTER DATABASE to drop the
file(s).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Zarko Jovanovic" <RmEaMkOnViEoTHvIoSmind_less@.bigfoot.com> wrote in message
news:1092738725.466707@.internet.fina.hr...
> Hi,
> Is there a way to completely empty some data files in the same filegroup so
> I can delete them?
> thanx
> --
> --
> remove RmEaMkOnViEoTHvIoS from my email
> svi komentari i razmisljanja su moja kao pojedinca i nikako se ne smiju
> povezivati sa tvrtkom u kojoj radim
>

Empty data files completely?

Hi,
Is there a way to completely empty some data files in the same filegroup so
I can delete them?
thanx
--
remove RmEaMkOnViEoTHvIoS from my email
svi komentari i razmisljanja su moja kao pojedinca i nikako se ne smiju
povezivati sa tvrtkom u kojoj radimYep. DBCC SHRINKFILE using the EMPTYFILE option. Then you can use ALTER DATA
BASE to drop the
file(s).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Zarko Jovanovic" <RmEaMkOnViEoTHvIoSmind_less@.bigfoot.com> wrote in message
news:1092738725.466707@.internet.fina.hr...
> Hi,
> Is there a way to completely empty some data files in the same filegroup s
o
> I can delete them?
> thanx
> --
> --
> remove RmEaMkOnViEoTHvIoS from my email
> svi komentari i razmisljanja su moja kao pojedinca i nikako se ne smiju
> povezivati sa tvrtkom u kojoj radim
>

Empty data files completely?

Hi,
Is there a way to completely empty some data files in the same filegroup so
I can delete them?
thanx
--
--
remove RmEaMkOnViEoTHvIoS from my email
svi komentari i razmisljanja su moja kao pojedinca i nikako se ne smiju
povezivati sa tvrtkom u kojoj radimYep. DBCC SHRINKFILE using the EMPTYFILE option. Then you can use ALTER DATABASE to drop the
file(s).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Zarko Jovanovic" <RmEaMkOnViEoTHvIoSmind_less@.bigfoot.com> wrote in message
news:1092738725.466707@.internet.fina.hr...
> Hi,
> Is there a way to completely empty some data files in the same filegroup so
> I can delete them?
> thanx
> --
> --
> remove RmEaMkOnViEoTHvIoS from my email
> svi komentari i razmisljanja su moja kao pojedinca i nikako se ne smiju
> povezivati sa tvrtkom u kojoj radim
>

Empty a Database SQL 2000

Hello,
Is there a way to export a database and delete the contents of it as
it creates the backup - leaving the database intact but devoid of
data?
Thanks,
TmuldHi,
You could create SP which uses BACKUP and TRUNCATE TABLE statement, I
guess. Is it something you want, or is there another constraint?
Tmuldoon wrote:
> Hello,
> Is there a way to export a database and delete the contents of it as
> it creates the backup - leaving the database intact but devoid of
> data?
> Thanks,
> Tmuld
>|||See Dan's post some times ago
DECLARE @.TruncateStatement nvarchar(4000)
DECLARE TruncateStatements CURSOR LOCAL FAST_FORWARD
FOR
SELECT
N'TRUNCATE TABLE ' +
QUOTENAME(TABLE_SCHEMA) +
N'.' +
QUOTENAME(TABLE_NAME)
FROM
INFORMATION_SCHEMA.TABLES
WHERE
TABLE_TYPE = 'BASE TABLE' AND
OBJECTPROPERTY(OBJECT_ID(QUOTENAME(TABLE_SCHEMA) +
N'.' +
QUOTENAME(TABLE_NAME)), 'IsMSShipped') = 0
OPEN TruncateStatements
WHILE 1 = 1
BEGIN
FETCH NEXT FROM TruncateStatements INTO @.TruncateStatement
IF @.@.FETCH_STATUS <> 0 BREAK
RAISERROR (@.TruncateStatement, 0, 1) WITH NOWAIT
EXEC(@.TruncateStatement)
END
CLOSE TruncateStatements
DEALLOCATE TruncateStatements
"Tmuldoon" <tmuldoon@.spliced.com> wrote in message
news:1185920307.362745.28610@.d30g2000prg.googlegroups.com...
> Hello,
> Is there a way to export a database and delete the contents of it as
> it creates the backup - leaving the database intact but devoid of
> data?
> Thanks,
> Tmuld
>

Empty a Database SQL 2000

Hello,
Is there a way to export a database and delete the contents of it as
it creates the backup - leaving the database intact but devoid of
data?
Thanks,
Tmuld
Hi,
You could create SP which uses BACKUP and TRUNCATE TABLE statement, I
guess. Is it something you want, or is there another constraint?
Tmuldoon wrote:
> Hello,
> Is there a way to export a database and delete the contents of it as
> it creates the backup - leaving the database intact but devoid of
> data?
> Thanks,
> Tmuld
>
|||See Dan's post some times ago
DECLARE @.TruncateStatement nvarchar(4000)
DECLARE TruncateStatements CURSOR LOCAL FAST_FORWARD
FOR
SELECT
N'TRUNCATE TABLE ' +
QUOTENAME(TABLE_SCHEMA) +
N'.' +
QUOTENAME(TABLE_NAME)
FROM
INFORMATION_SCHEMA.TABLES
WHERE
TABLE_TYPE = 'BASE TABLE' AND
OBJECTPROPERTY(OBJECT_ID(QUOTENAME(TABLE_SCHEMA) +
N'.' +
QUOTENAME(TABLE_NAME)), 'IsMSShipped') = 0
OPEN TruncateStatements
WHILE 1 = 1
BEGIN
FETCH NEXT FROM TruncateStatements INTO @.TruncateStatement
IF @.@.FETCH_STATUS <> 0 BREAK
RAISERROR (@.TruncateStatement, 0, 1) WITH NOWAIT
EXEC(@.TruncateStatement)
END
CLOSE TruncateStatements
DEALLOCATE TruncateStatements
"Tmuldoon" <tmuldoon@.spliced.com> wrote in message
news:1185920307.362745.28610@.d30g2000prg.googlegro ups.com...
> Hello,
> Is there a way to export a database and delete the contents of it as
> it creates the backup - leaving the database intact but devoid of
> data?
> Thanks,
> Tmuld
>

Empty a Database SQL 2000

Hello,
Is there a way to export a database and delete the contents of it as
it creates the backup - leaving the database intact but devoid of
data?
Thanks,
TmuldHi,
You could create SP which uses BACKUP and TRUNCATE TABLE statement, I
guess. Is it something you want, or is there another constraint?
Tmuldoon wrote:
> Hello,
> Is there a way to export a database and delete the contents of it as
> it creates the backup - leaving the database intact but devoid of
> data?
> Thanks,
> Tmuld
>|||See Dan's post some times ago
DECLARE @.TruncateStatement nvarchar(4000)
DECLARE TruncateStatements CURSOR LOCAL FAST_FORWARD
FOR
SELECT
N'TRUNCATE TABLE ' +
QUOTENAME(TABLE_SCHEMA) +
N'.' +
QUOTENAME(TABLE_NAME)
FROM
INFORMATION_SCHEMA.TABLES
WHERE
TABLE_TYPE = 'BASE TABLE' AND
OBJECTPROPERTY(OBJECT_ID(QUOTENAME(TABLE
_SCHEMA) +
N'.' +
QUOTENAME(TABLE_NAME)), 'IsMSShipped') = 0
OPEN TruncateStatements
WHILE 1 = 1
BEGIN
FETCH NEXT FROM TruncateStatements INTO @.TruncateStatement
IF @.@.FETCH_STATUS <> 0 BREAK
RAISERROR (@.TruncateStatement, 0, 1) WITH NOWAIT
EXEC(@.TruncateStatement)
END
CLOSE TruncateStatements
DEALLOCATE TruncateStatements
"Tmuldoon" <tmuldoon@.spliced.com> wrote in message
news:1185920307.362745.28610@.d30g2000prg.googlegroups.com...
> Hello,
> Is there a way to export a database and delete the contents of it as
> it creates the backup - leaving the database intact but devoid of
> data?
> Thanks,
> Tmuld
>