Monday, March 26, 2012
resetting count on INT type field (autonumber field)
I have an INT field that auto increments by 1, now that I am approaching the
end of the testing phase, I need to delete all the records and reset the
"count" to 1.
Any help?
MitchJust truncate the table (or drop and recreate it) since you don't need the
data. Truncate will reset the identity.
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"mitchel" <mitch_001@.yahoo.com> wrote in message
news:ez5tT1U2DHA.2396@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I have an INT field that auto increments by 1, now that I am approaching
the
> end of the testing phase, I need to delete all the records and reset the
> "count" to 1.
> Any help?
> Mitch
>|||Sorry, I'm kind of new to SQL server, what does "truncate the table" mean
and how do I do it?
SQL Server 2000
Thanks!
Mitch
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
news:%23r8XWCV2DHA.2792@.TK2MSFTNGP09.phx.gbl...
> Just truncate the table (or drop and recreate it) since you don't need the
> data. Truncate will reset the identity.
> --
> HTH
> Jasper Smith (SQL Server MVP)
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
>
> "mitchel" <mitch_001@.yahoo.com> wrote in message
> news:ez5tT1U2DHA.2396@.TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > I have an INT field that auto increments by 1, now that I am approaching
> the
> > end of the testing phase, I need to delete all the records and reset the
> > "count" to 1.
> >
> > Any help?
> >
> > Mitch
> >
> >
>|||In Query Analyzer run the following in your database
TRUNCATE TABLE name
Have a look at TRUNCATE TABLE in BOL (Books on Line - the SQL Server help)
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"mitchel" <mitch_001@.yahoo.com> wrote in message
news:OWOSvYV2DHA.1704@.tk2msftngp13.phx.gbl...
> Sorry, I'm kind of new to SQL server, what does "truncate the table" mean
> and how do I do it?
> SQL Server 2000
> Thanks!
> Mitch
>
> "Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
> news:%23r8XWCV2DHA.2792@.TK2MSFTNGP09.phx.gbl...
> > Just truncate the table (or drop and recreate it) since you don't need
the
> > data. Truncate will reset the identity.
> >
> > --
> > HTH
> >
> > Jasper Smith (SQL Server MVP)
> >
> > I support PASS - the definitive, global
> > community for SQL Server professionals -
> > http://www.sqlpass.org
> >
> >
> > "mitchel" <mitch_001@.yahoo.com> wrote in message
> > news:ez5tT1U2DHA.2396@.TK2MSFTNGP09.phx.gbl...
> > > Hi,
> > >
> > > I have an INT field that auto increments by 1, now that I am
approaching
> > the
> > > end of the testing phase, I need to delete all the records and reset
the
> > > "count" to 1.
> > >
> > > Any help?
> > >
> > > Mitch
> > >
> > >
> >
> >
>|||Thanks!
Worked perfectly!
Mitch
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
news:%23703ihV2DHA.1532@.TK2MSFTNGP10.phx.gbl...
> In Query Analyzer run the following in your database
> TRUNCATE TABLE name
> Have a look at TRUNCATE TABLE in BOL (Books on Line - the SQL Server help)
> --
> HTH
> Jasper Smith (SQL Server MVP)
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
>
> "mitchel" <mitch_001@.yahoo.com> wrote in message
> news:OWOSvYV2DHA.1704@.tk2msftngp13.phx.gbl...
> > Sorry, I'm kind of new to SQL server, what does "truncate the table"
mean
> > and how do I do it?
> >
> > SQL Server 2000
> >
> > Thanks!
> >
> > Mitch
> >
> >
> >
> > "Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
> > news:%23r8XWCV2DHA.2792@.TK2MSFTNGP09.phx.gbl...
> > > Just truncate the table (or drop and recreate it) since you don't need
> the
> > > data. Truncate will reset the identity.
> > >
> > > --
> > > HTH
> > >
> > > Jasper Smith (SQL Server MVP)
> > >
> > > I support PASS - the definitive, global
> > > community for SQL Server professionals -
> > > http://www.sqlpass.org
> > >
> > >
> > > "mitchel" <mitch_001@.yahoo.com> wrote in message
> > > news:ez5tT1U2DHA.2396@.TK2MSFTNGP09.phx.gbl...
> > > > Hi,
> > > >
> > > > I have an INT field that auto increments by 1, now that I am
> approaching
> > > the
> > > > end of the testing phase, I need to delete all the records and reset
> the
> > > > "count" to 1.
> > > >
> > > > Any help?
> > > >
> > > > Mitch
> > > >
> > > >
> > >
> > >
> >
> >
>
resetting count on INT type field (autonumber field)
I have an INT field that auto increments by 1, now that I am approaching the
end of the testing phase, I need to delete all the records and reset the
"count" to 1.
Any help?
MitchJust truncate the table (or drop and recreate it) since you don't need the
data. Truncate will reset the identity.
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"mitchel" <mitch_001@.yahoo.com> wrote in message
news:ez5tT1U2DHA.2396@.TK2MSFTNGP09.phx.gbl...
quote:
> Hi,
> I have an INT field that auto increments by 1, now that I am approaching
the
quote:|||Sorry, I'm kind of new to SQL server, what does "truncate the table" mean
> end of the testing phase, I need to delete all the records and reset the
> "count" to 1.
> Any help?
> Mitch
>
and how do I do it?
SQL Server 2000
Thanks!
Mitch
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
news:%23r8XWCV2DHA.2792@.TK2MSFTNGP09.phx.gbl...
quote:|||In Query Analyzer run the following in your database
> Just truncate the table (or drop and recreate it) since you don't need the
> data. Truncate will reset the identity.
> --
> HTH
> Jasper Smith (SQL Server MVP)
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
>
> "mitchel" <mitch_001@.yahoo.com> wrote in message
> news:ez5tT1U2DHA.2396@.TK2MSFTNGP09.phx.gbl...
> the
>
TRUNCATE TABLE name
Have a look at TRUNCATE TABLE in BOL (Books on Line - the SQL Server help)
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"mitchel" <mitch_001@.yahoo.com> wrote in message
news:OWOSvYV2DHA.1704@.tk2msftngp13.phx.gbl...
quote:|||Thanks!
> Sorry, I'm kind of new to SQL server, what does "truncate the table" mean
> and how do I do it?
> SQL Server 2000
> Thanks!
> Mitch
>
> "Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
> news:%23r8XWCV2DHA.2792@.TK2MSFTNGP09.phx.gbl...
the[QUOTE]
approaching[QUOTE]
the[QUOTE]
>
Worked perfectly!
Mitch
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
news:%23703ihV2DHA.1532@.TK2MSFTNGP10.phx.gbl...
quote:
> In Query Analyzer run the following in your database
> TRUNCATE TABLE name
> Have a look at TRUNCATE TABLE in BOL (Books on Line - the SQL Server help)
> --
> HTH
> Jasper Smith (SQL Server MVP)
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
>
> "mitchel" <mitch_001@.yahoo.com> wrote in message
> news:OWOSvYV2DHA.1704@.tk2msftngp13.phx.gbl...
mean[QUOTE]
> the
> approaching
> the
>
reset toolbox doesn't delete my components
Hi,
I am in the process of developing a custom component. During that time I went through many versions of my custom component, including various DLL names and signatures, different code etc.
The problem is that now I have old versions of my custom components stuck in the default settings of the toolbox. When I reset the toolbox, even if I manually deleted the old items, it appears again.
I tried to delete all the DLLs I previously copied to the SQL Server directories, and also uninstalled all the DLLs from GAC.
The result was that the new components didn't appear, and I don't have the option to choose them in the "choose items" menu, but they still appear on the toolbox.
It is not something I can't live with, but it's really annoying seeing old and irrelevant versions right in your face...
Please help :-)
I believe the toolbox enumeration is driven off the %ProgramFiles%\DTS\<ComponentType> folder, so if you delete the old versions from there and reset they should be removed from the toolbox.|||I don't have that folder... I tried deleting everything from the relevant sql server folder, but it didn't help.|||Sorry, what I meant was %ProgramFiles%\Microsoft SQL Server\90\DTS\<Component>. So to remove any Data Flow components, clean up C:\Program Files\Microsoft SQL Server\90\DTS\PipelineComponents. For Tasks, clean up C:\Program Files\Microsoft SQL Server\90\DTS\Tasks etc.|||That's what I did to begin with... it still didn't help.Friday, March 23, 2012
Reset pimary key to 1
Hi Forum, I have a .mdf that I have used to test SQL data app. I want to reuse the .mdf; delete all added data and reset Customer_ID primary colomn back to 1. All good info appreciated thanks Paul
Hello there,
Try execute the statement TRUNCATE TABLE <table name>.
cheers,
Eric
Reset IDENTITY seed
Can I reset the IDENTITY seed of a Table column without delete/drop the table?
I want to delete all the table rows, restore de seed, and restore abackup made on a XML (using SET IDENTITY_INSERT Table ON)
I cant drop the table due to acount restricctions.
regards,
Edu
You could try
TRUNCATE TABLE MyTable|||Check outDBCC CHECKIDENT.|||Thanks,
DBCC CHECKIDENT. works fine!
Regards,
Edu
Reset Identity Column Counter.
TRUNCATE command resets identity counter.
http://msdn2.microsoft.com/en-us/library/ms177570.aspx
It's also minimally logged and will run faster than the DELETE statement
|||If TRUNCATE TABLE MyTable does not work for you, let us know.
There are other options if necessary.
|||Although I am able to delete all rows from the table (using 'delete from sometable'), attempting to truncate (using 'truncate table sometable') returns the error: 'Msg 4712, Level 16, State 1, Line 1
Cannot truncate table 'sometable' because it is being referenced by a FOREIGN KEY constraint.
The other table that references 'sometable' is also empty and was successfully truncated. It is also the only table that shows up in the dependencies dialog.
|||
A FK needs to be disabled (or removed) before executing the TRUNCATE command (this is because, in part, of the minimal logging that allows TRUNCATE to operate so quickly)|||
See http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1258966&SiteID=17&pageid=0#1258966
Reset Identity Column
I have a database table that I will delete all the
contents from regularly. I have an identity column that
I would like to start counting from 1 after deleting all
the records. However it keeps counting from the last
number it used even though all the records are deleted.
Is there anyway to reset the Identity number.
Thanks!
Either truncate the table ( it will automatically be reset)
or
DBCC checkident with a reseed parameter ( this is doc'd in books online..
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Chuck" <anonymous@.discussions.microsoft.com> wrote in message
news:2bd401c4287c$8a1ba5e0$a601280a@.phx.gbl...
> Hello,
> I have a database table that I will delete all the
> contents from regularly. I have an identity column that
> I would like to start counting from 1 after deleting all
> the records. However it keeps counting from the last
> number it used even though all the records are deleted.
> Is there anyway to reset the Identity number.
> Thanks!
sql
Reset Identity Column
I have a database table that I will delete all the
contents from regularly. I have an identity column that
I would like to start counting from 1 after deleting all
the records. However it keeps counting from the last
number it used even though all the records are deleted.
Is there anyway to reset the Identity number.
Thanks!Either truncate the table ( it will automatically be reset)
or
DBCC checkident with a reseed parameter ( this is doc'd in books online..
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Chuck" <anonymous@.discussions.microsoft.com> wrote in message
news:2bd401c4287c$8a1ba5e0$a601280a@.phx.gbl...
> Hello,
> I have a database table that I will delete all the
> contents from regularly. I have an identity column that
> I would like to start counting from 1 after deleting all
> the records. However it keeps counting from the last
> number it used even though all the records are deleted.
> Is there anyway to reset the Identity number.
> Thanks!
Reset Identity Column
I have a database table that I will delete all the
contents from regularly. I have an identity column that
I would like to start counting from 1 after deleting all
the records. However it keeps counting from the last
number it used even though all the records are deleted.
Is there anyway to reset the Identity number.
Thanks!Either truncate the table ( it will automatically be reset)
or
DBCC checkident with a reseed parameter ( this is doc'd in books online..
--
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Chuck" <anonymous@.discussions.microsoft.com> wrote in message
news:2bd401c4287c$8a1ba5e0$a601280a@.phx.gbl...
> Hello,
> I have a database table that I will delete all the
> contents from regularly. I have an identity column that
> I would like to start counting from 1 after deleting all
> the records. However it keeps counting from the last
> number it used even though all the records are deleted.
> Is there anyway to reset the Identity number.
> Thanks!|||Hi,
Try the 'Truncate Table' command, this will re-set the ID's
J
>--Original Message--
>Hello,
>I have a database table that I will delete all the
>contents from regularly. I have an identity column that
>I would like to start counting from 1 after deleting all
>the records. However it keeps counting from the last
>number it used even though all the records are deleted.
>Is there anyway to reset the Identity number.
>Thanks!
>.
>sql
Wednesday, March 21, 2012
reset all identity seed in table
how can I reset all identity seed in tables to the beginning numbers?
Tnx in advanced
Use this
DBCC CHECKIDENT (Tablename, RESEED, 30)
Markus
|||Use this
DBCC CHECKIDENT (Tablename, RESEED, 30)
Markus
|||Have a look at DBCC CHECKIDENT in SQL Books OnLine
"John" <john@.smith.com> wrote in message
news:doe4gc$n4j$1@.news2.netvision.net.il...
> I mad a clone of my db and delete all info that I don't need.
> how can I reset all identity seed in tables to the beginning numbers?
> Tnx in advanced
>
|||Use this
DBCC CHECKIDENT (tablename, RESEED,1)
|||this only work for one table
I want it all
Tnx
"MarkusB" <m.bohse@.quest-consultants.com> wrote in message
news:1135253936.827451.60600@.f14g2000cwb.googlegro ups.com...
> Use this
> DBCC CHECKIDENT (tablename, RESEED,1)
>
|||If your tables are not referenced by foreign keys you could give this a try
:-
TRUNCATE TABLE tablename
this will remove all data and reset the identity column to it's seed value.
To run this against every table in your database make use of exec
sp_MSforeachtable
"John" <john@.smith.com> wrote in message
news:doe5om$na6$1@.news2.netvision.net.il...
> this only work for one table
> I want it all
> Tnx
> "MarkusB" <m.bohse@.quest-consultants.com> wrote in message
> news:1135253936.827451.60600@.f14g2000cwb.googlegro ups.com...
>
reset all identity seed in table
how can I reset all identity seed in tables to the beginning numbers?
Tnx in advancedUse this
DBCC CHECKIDENT (Tablename, RESEED, 30)
Markus|||Use this
DBCC CHECKIDENT (Tablename, RESEED, 30)
Markus|||Use this
DBCC CHECKIDENT (tablename, RESEED,1)|||Have a look at DBCC CHECKIDENT in SQL Books OnLine
"John" <john@.smith.com> wrote in message
news:doe4gc$n4j$1@.news2.netvision.net.il...
> I mad a clone of my db and delete all info that I don't need.
> how can I reset all identity seed in tables to the beginning numbers?
> Tnx in advanced
>|||this only work for one table
I want it all :)
Tnx
"MarkusB" <m.bohse@.quest-consultants.com> wrote in message
news:1135253936.827451.60600@.f14g2000cwb.googlegroups.com...
> Use this
> DBCC CHECKIDENT (tablename, RESEED,1)
>|||If your tables are not referenced by foreign keys you could give this a try
:-
TRUNCATE TABLE tablename
this will remove all data and reset the identity column to it's seed value.
To run this against every table in your database make use of exec
sp_MSforeachtable
"John" <john@.smith.com> wrote in message
news:doe5om$na6$1@.news2.netvision.net.il...
> this only work for one table
> I want it all :)
> Tnx
> "MarkusB" <m.bohse@.quest-consultants.com> wrote in message
> news:1135253936.827451.60600@.f14g2000cwb.googlegroups.com...
> > Use this
> > DBCC CHECKIDENT (tablename, RESEED,1)
> >
>
reset all identity seed in table
how can I reset all identity seed in tables to the beginning numbers?
Tnx in advancedUse this
DBCC CHECKIDENT (Tablename, RESEED, 30)
Markus|||Use this
DBCC CHECKIDENT (Tablename, RESEED, 30)
Markus|||Have a look at DBCC CHECKIDENT in SQL Books OnLine
"John" <john@.smith.com> wrote in message
news:doe4gc$n4j$1@.news2.netvision.net.il...
> I mad a clone of my db and delete all info that I don't need.
> how can I reset all identity seed in tables to the beginning numbers?
> Tnx in advanced
>|||Use this
DBCC CHECKIDENT (tablename, RESEED,1)|||this only work for one table
I want it all
Tnx
"MarkusB" <m.bohse@.quest-consultants.com> wrote in message
news:1135253936.827451.60600@.f14g2000cwb.googlegroups.com...
> Use this
> DBCC CHECKIDENT (tablename, RESEED,1)
>|||If your tables are not referenced by foreign keys you could give this a try
:-
TRUNCATE TABLE tablename
this will remove all data and reset the identity column to it's seed value.
To run this against every table in your database make use of exec
sp_MSforeachtable
"John" <john@.smith.com> wrote in message
news:doe5om$na6$1@.news2.netvision.net.il...
> this only work for one table
> I want it all
> Tnx
> "MarkusB" <m.bohse@.quest-consultants.com> wrote in message
> news:1135253936.827451.60600@.f14g2000cwb.googlegroups.com...
>
Tuesday, March 20, 2012
Re-raising error
INSERT/UPDATE/DELETE. If any error, then I exit SP with this error
code. A client application does not receive much information
with this code, so it displays a message like "Cannot insert/update record.
Error : NNN".
Is there a way to get more detailed information about an error?
RAISERROR only throws user-defined errors. Any ideas?"Tumurbaatar S." <spam_tumur@.magicnet.mn> wrote in message
news:u6%23Wmxd8FHA.3132@.TK2MSFTNGP12.phx.gbl...
> In a stored procedure I usually check @.@.ERROR after every
> INSERT/UPDATE/DELETE. If any error, then I exit SP with this error
> code. A client application does not receive much information
> with this code, so it displays a message like "Cannot insert/update
> record. Error : NNN".
> Is there a way to get more detailed information about an error?
> RAISERROR only throws user-defined errors. Any ideas?
>
Unless you use TSQL TRY/CATCH the client will recieve both the original
error and the stored procedure return code. Different client libraries
interpret this data differently, but most have a way to grab the error.
David|||Is your client application SQLServer or something else (dotnet, java etc)?
If SQL then @.@.error is fine unless you want to catch the specific error from
sysmessages. I only ever use raiserror(@.text,1,1) for triggers and i don't
use triggers so I don't really use it.
If it is an external App and you are not a GOTOless programmer then try
something like below then just call the entries from the log table in the
external App:
If @.@.ERROR <> 0 or @.@.ROWCOUNT <= 0
begin
select @.text = 'Error -50: Could not update TableAdata for w
select @.result = -50
GOTO ERROR_POINT
end
ERROR_POINT:
PRINT 'ERROR_POINT'
GOTO FINISH
FINISH:
select @.resultText = 'RoutineName: ' + @.text + ' from User ' + @.pWho + ' at
' + convert(varchar(15),getdate(),3) + ' ' + convert(varchar(15),getdate(),1
4)
INSERT INTO log VALUES (@.resultText, 'RoutineName', getdate(), 'Y')
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET NOCOUNT OFF
GO|||No pun intended, but please explain how this one works.
There must be something missing from the sample you posted.
All statements will be executed - even if there is no error and the rowcount
is above 0, and in such a case a null value (or an unexpected one) will be
inserted into the log.
Do you actually use this in your production code?
ML|||Thank you!
But you are both talking about SQL2005? If I'm not mistaken,
SQL2000 does not support TRY/CATCH exception handling. And that
is only reason why I asked for how to re-raise (read "rethrow") an error.
If there was try/catch handling in SQL2000, I had no problem.|||"Tumurbaatar S." <spam_tumur@.magicnet.mn> wrote in message
news:%235tAGhh8FHA.3984@.TK2MSFTNGP11.phx.gbl...
> Thank you!
> But you are both talking about SQL2005? If I'm not mistaken,
> SQL2000 does not support TRY/CATCH exception handling. And that
> is only reason why I asked for how to re-raise (read "rethrow") an error.
> If there was try/catch handling in SQL2000, I had no problem.
>
IN SQL 2000 there is no way to prevent the error message from propagating to
the client. If the client is using, for instance, .NET the calling code
will get a SqlException. Only in SQL 2005 is there a way to stop the error
from going to the client (CATCH), and so only there is there any need to
"rethrow" the error in SQL Server.
David|||> IN SQL 2000 there is no way to prevent the error message from propagating
> to the client. If the client is using, for instance, .NET the calling
> code will get a SqlException.
But how does a client receive an error? For example, a SP executes
INSERT that fails due to some constraint violation:
INSERT ...
IF @.@.ERROR <> 0
...
What happens in this case? SP execution stops before IF @.@.ERROR,
exits with an error notification and the client engine receives a standard
SQL error. Or SQL server remembers this error, the SP continues processing
and when SP exits normally (i.e. RETURN @.some_value) the client engine
receives
this return code (@.some_value), but also it receives the previously saved
error too?|||"Tumurbaatar S." <spam_tumur@.magicnet.mn> wrote in message
news:e2m$$tq8FHA.472@.TK2MSFTNGP15.phx.gbl...
> But how does a client receive an error? For example, a SP executes
> INSERT that fails due to some constraint violation:
> INSERT ...
> IF @.@.ERROR <> 0
> ...
> What happens in this case? SP execution stops before IF @.@.ERROR,
> exits with an error notification and the client engine receives a standard
> SQL error. Or SQL server remembers this error, the SP continues processing
> and when SP exits normally (i.e. RETURN @.some_value) the client engine
> receives
> this return code (@.some_value), but also it receives the previously saved
> error too?
Sort of, yes. The client gets the return code and any errors which occured.
Most client libraries don't expose both through the API, however. If an
error occurs, you will likely not get a return code from the procedure.
David|||Many thanks!
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:e$Zbolw8FHA.740@.TK2MSFTNGP11.phx.gbl...
> "Tumurbaatar S." <spam_tumur@.magicnet.mn> wrote in message
> news:e2m$$tq8FHA.472@.TK2MSFTNGP15.phx.gbl...
> Sort of, yes. The client gets the return code and any errors which
> occured. Most client libraries don't expose both through the API, however.
> If an error occurs, you will likely not get a return code from the
> procedure.
> David
>
>
Monday, March 12, 2012
Request for SqlCeEngine.Exists(), .Delete() methods
However, there doesn't seem to be a way to determine whether a database exists, given a connection string. I would need to interpret the connection string myself and extract the file name to use File.Exists() etc.
There should be SqlCeEngine methods to test whether a database exists, test whether it's accessible, and to delete it, given a connection string.
Cheers, Oli
It is unlikely that would be added as you can easily do that with simple string manipulations and classes from System.IO – you already know how.
In compact world (where keeping size down is very important) functionality is usually added only if it’s not possible (or very hard) to do or if it’s some very common task. One example would be multiple connections support added in SQL Mobile. Your task is easy to do with existing functionality and it’s not that common – usually connection string is constructed from file name.
In any case you’re welcome to submit a request via Product feedback site: http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220
|||Hmm...I can get you a work around if you are taking connection string as input.
This should help you!
conn = new SqlCeConnection(inputConnectionString);
if (File.Exists(conn.DataSource))
File.Delete(conn.DataSource);
The important thing to note here is that, Connection Object parses the connection string the moment you assign it (need not call Open). And DataSource property will return the Database File Path.
Thanks,
Laxmi
Friday, March 9, 2012
Re-publishing and metadata deletion
drive on the server. Before I republish these databases can I delete the
metadata tables? I would assume that if the publication is dropped then the
metadata tables become meaningless, is this correct? Which tables exactly can
I delete? I believe msmerge_contents and tombstone can be deleted, any others?
Thanks,
Pete
Can anyone help me?
Another problem, I am trying to delete a few subscriptions from a server so
that I can resubscribe the databases to the new publications but I keep
getting the error below. I have already dropped the publications and
recreated them in the new location, and the new subscriptions will not
synchronize, the error is "The process could not drop one or more tables
because the tables are being used".
The error I get when trying to delete the old subscriptions is:
"Error 14274: Cannot add, update, or delete a job (or its steps or
schedules) that originated from a MSX server. The subscription could not be
dropped at this time."
I have no idea what a MSX server is.
Please help,
Pete
"Pete" wrote:
> I need to drop a few publications because they are located on the wrong hard
> drive on the server. Before I republish these databases can I delete the
> metadata tables? I would assume that if the publication is dropped then the
> metadata tables become meaningless, is this correct? Which tables exactly can
> I delete? I believe msmerge_contents and tombstone can be deleted, any others?
> Thanks,
> Pete