Showing posts with label write. Show all posts
Showing posts with label write. Show all posts

Thursday, March 29, 2012

Estimating Table Sizes

Is it possible to write a query that can estimate the space a table is
using in the database? I would like to be able to generate a report
that can display the amount of disk space a table is consuming.How about using sp_spaceused?
RLF
<marcusq71@.gmail.com> wrote in message
news:1173901596.189278.188470@.l75g2000hse.googlegroups.com...
> Is it possible to write a query that can estimate the space a table is
> using in the database? I would like to be able to generate a report
> that can display the amount of disk space a table is consuming.
>|||Hello,
Go to the specific database and execute the below command to get the space
usage for all tables individually.
EXEC sp_MSForEachTable 'EXEC sp_spaceused [?]';
Thanks
Hari
<marcusq71@.gmail.com> wrote in message
news:1173901596.189278.188470@.l75g2000hse.googlegroups.com...
> Is it possible to write a query that can estimate the space a table is
> using in the database? I would like to be able to generate a report
> that can display the amount of disk space a table is consuming.
>|||On Mar 15, 12:46 am, "marcus...@.gmail.com" <marcus...@.gmail.com>
wrote:
> Is it possible to write a query that can estimate the space a table is
> using in the database? I would like to be able to generate a report
> that can display the amount of disk space a table is consuming.
Make sure you run DBCC UPDATEUSAGE on the database before you run
sp_spaceused
Reports and corrects inaccuracies in the sysindexes table, which may
result in incorrect space usage reports by the sp_spaceused system
stored procedure.
M A Srinivas|||On Mar 15, 2:07 am, "M A Srinivas" <masri...@.gmail.com> wrote:
> On Mar 15, 12:46 am, "marcus...@.gmail.com" <marcus...@.gmail.com>
> wrote:
>
> Make sure you run DBCC UPDATEUSAGE on the database before you run
> sp_spaceused
> Reports and corrects inaccuracies in the sysindexes table, which may
> result in incorrect space usage reports by the sp_spaceused system
> stored procedure.
> M A Srin
Thank you all for these suggestions. This is exactly what I am
looking for. I was not clear on my initial request but the
MSforeachtable stored procedure was exactly what I was looking for.

Estimating Table Sizes

Is it possible to write a query that can estimate the space a table is
using in the database? I would like to be able to generate a report
that can display the amount of disk space a table is consuming.
How about using sp_spaceused?
RLF
<marcusq71@.gmail.com> wrote in message
news:1173901596.189278.188470@.l75g2000hse.googlegr oups.com...
> Is it possible to write a query that can estimate the space a table is
> using in the database? I would like to be able to generate a report
> that can display the amount of disk space a table is consuming.
>
|||Hello,
Go to the specific database and execute the below command to get the space
usage for all tables individually.
EXEC sp_MSForEachTable 'EXEC sp_spaceused [?]';
Thanks
Hari
<marcusq71@.gmail.com> wrote in message
news:1173901596.189278.188470@.l75g2000hse.googlegr oups.com...
> Is it possible to write a query that can estimate the space a table is
> using in the database? I would like to be able to generate a report
> that can display the amount of disk space a table is consuming.
>
|||On Mar 15, 12:46 am, "marcus...@.gmail.com" <marcus...@.gmail.com>
wrote:
> Is it possible to write a query that can estimate the space a table is
> using in the database? I would like to be able to generate a report
> that can display the amount of disk space a table is consuming.
Make sure you run DBCC UPDATEUSAGE on the database before you run
sp_spaceused
Reports and corrects inaccuracies in the sysindexes table, which may
result in incorrect space usage reports by the sp_spaceused system
stored procedure.
M A Srinivas
|||On Mar 15, 2:07 am, "M A Srinivas" <masri...@.gmail.com> wrote:
> On Mar 15, 12:46 am, "marcus...@.gmail.com" <marcus...@.gmail.com>
> wrote:
>
> Make sure you run DBCC UPDATEUSAGE on the database before you run
> sp_spaceused
> Reports and corrects inaccuracies in the sysindexes table, which may
> result in incorrect space usage reports by the sp_spaceused system
> stored procedure.
> M A Srin
Thank you all for these suggestions. This is exactly what I am
looking for. I was not clear on my initial request but the
MSforeachtable stored procedure was exactly what I was looking for.
sql

Estimating Table Sizes

Is it possible to write a query that can estimate the space a table is
using in the database? I would like to be able to generate a report
that can display the amount of disk space a table is consuming.How about using sp_spaceused?
RLF
<marcusq71@.gmail.com> wrote in message
news:1173901596.189278.188470@.l75g2000hse.googlegroups.com...
> Is it possible to write a query that can estimate the space a table is
> using in the database? I would like to be able to generate a report
> that can display the amount of disk space a table is consuming.
>|||Hello,
Go to the specific database and execute the below command to get the space
usage for all tables individually.
EXEC sp_MSForEachTable 'EXEC sp_spaceused [?]';
Thanks
Hari
<marcusq71@.gmail.com> wrote in message
news:1173901596.189278.188470@.l75g2000hse.googlegroups.com...
> Is it possible to write a query that can estimate the space a table is
> using in the database? I would like to be able to generate a report
> that can display the amount of disk space a table is consuming.
>|||On Mar 15, 12:46 am, "marcus...@.gmail.com" <marcus...@.gmail.com>
wrote:
> Is it possible to write a query that can estimate the space a table is
> using in the database? I would like to be able to generate a report
> that can display the amount of disk space a table is consuming.
Make sure you run DBCC UPDATEUSAGE on the database before you run
sp_spaceused
Reports and corrects inaccuracies in the sysindexes table, which may
result in incorrect space usage reports by the sp_spaceused system
stored procedure.
M A Srinivas|||On Mar 15, 2:07 am, "M A Srinivas" <masri...@.gmail.com> wrote:
> On Mar 15, 12:46 am, "marcus...@.gmail.com" <marcus...@.gmail.com>
> wrote:
> > Is it possible to write a query that can estimate the space a table is
> > using in the database? I would like to be able to generate a report
> > that can display the amount of disk space a table is consuming.
> Make sure you run DBCC UPDATEUSAGE on the database before you run
> sp_spaceused
> Reports and corrects inaccuracies in the sysindexes table, which may
> result in incorrect space usage reports by the sp_spaceused system
> stored procedure.
> M A Srin
Thank you all for these suggestions. This is exactly what I am
looking for. I was not clear on my initial request but the
MSforeachtable stored procedure was exactly what I was looking for.

Monday, March 26, 2012

Esql/C calling stored procedure with output parameters

I'm trying to write an esqlc program that will run a stored procedure that returns several output parameters. I haven't been able to find any documentation to date that explains how to run the "EXEC SQL EXECUTE procname" command and specify the output parameters.

My stored procedure "aek_proc1" takes one input parameter (p1 - an 8-character string) and 3 output parameters (p2 - an integer; p3 - an 8-character string, and p4 a 40-character string).

My esqlc program contains the following code.

EXEC SQL BEGIN DECLARE SECTION;
char p1[9];
int p2;
char p3[9];
char p4[41];
WXEC SQL END DECLARE SECTION;

sprintf(&p1[0], "GL");
p2 = 0;
sprintf(&p3[0], "");
sprintf(&p4[0], "");

EXEC SQL EXECUTE aek_proc1 :p1,
:p2 OUTPUT,
:p3 OUTPUT,
:p4 OUTPUT;

I am getting errors at runtime about constants being passed for OUTPUT parameters.

I can run the same stored procedure in Query Analyser and it works beautifully (see below)

declare @.p1 char(8)
declare @.p2 integer
declare @.p3 char(8)
declare @.p4 char(40)

set @.p1 = 'GL'

execute aek_proc1 @.p1, @.p2 output, @.p3 output, @.p4 output

select @.p1 p1, @.p2 p2, @.p3 p3, @.p4 p4

Any idea what I'm doing wrong or how it should be coded?

I'd really appreciate any advice you can offer!!

I've spend hours browsing this newsgroup and found lots of examples of how to do this in VB and from Query Analyser but I can't find any examples for ESQL/C that work.

So, please help!!!

Thanks,

AllanK :rolleyes:Oops.

Don't know why the host variable names got turned into smileys, but that bit should have read...

EXEC SQL EXECUTE aek_proc1 :p1,
:p2 OUTPUT,
:p3 OUTPUT,
:p4 OUTPUT;|||Have you tried to replace : with @.?|||I tried changing the EXEC SQL EXEC command in the ESQL/C program to read...

EXEC SQL EXEC aek_proc1 @.p1, @.p2 OUTPUT, @.p3 OUTPUT, @.p4

after which I got the runtime error...

"0137- Must declare the variable '@.p1'."

I tried adding...

EXEC SQL DECLARE @.p1 char(8);
EXEC SQL DECLARE @.p2 int;
EXEC SQL DECLARE @.p3 char(8);
EXEC SQL DECLARE @.p4 char(40);

EXEC SQL SET @.p1 = 'GL';
EXEC SQL SET @.p2 = 0;
EXEC SQL SET @.p3 = '';
EXEC SQL SET @.p4 = '';

EXEC SQL EXEC aek_proc1 @.p1, @.p2 OUTPUT, @.p3 OUTPUT, @.p4 OUTPUT;

but the error persists.

Any further suggestions?

Thanks,

AllanK

Sunday, February 26, 2012

Error:Initializing SQL Server Reconciler has failed.

My exploit environment:

VS.net 2003, SQL Server 2000 SP4, SQL Server CE 2.0 SP4

I write next codes:

Private cn As New SqlCeConnection("data source=\my documents\SQLCECF.sdf")

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Try

If Not System.IO.File.Exists("\my documents\SQLCECF.sdf") Then

Dim en As New SqlCeEngine("data source=\my documents\SQLCECF.sdf")

en.CreateDatabase() 'create a blank database to subscribe

Synch()

End If

Catch err As SqlCeException

ShowErrors(err)

Catch err As Exception

MsgBox("There was an error:" & err.ToString())

End Try

End Sub

Sub Synch()

Try

Dim rep As SqlCeReplication = New SqlCeReplication

With rep

.Publisher = "192.168.0.222"

.PublisherDatabase = "CFLab"

.PublisherLogin = "sa"

.PublisherPassword = "sa"

.Publication = "CFLab"

.Subscriber = "SQLCENETCF"

.SubscriberConnectionString = "Provider=Microsoft.SQLServer.OLEDB.CE.2.0;Data Source=\My Documents\SQLCECF.sdf"

.InternetUrl = "http://192.168.0.222/SQLCE/sscesa20.dll"

' Create the Local SSCE Database subscription

rep.AddSubscription(AddOption.CreateDatabase)

rep.Synchronize() 'subscribe

End With

Catch err As SqlCeException

ShowErrors(err)

Finally

End Try

End Sub

Public Sub ShowErrors(ByRef e As SqlCeException)

Dim errorCollection As SqlCeErrorCollection = e.Errors

Dim bld As System.Text.StringBuilder = New System.Text.StringBuilder

Dim inner As Exception = e.InnerException

If Not inner Is Nothing Then

MessageBox.Show(("Inner Exception:" & inner.ToString()))

End If

For Each err As SqlCeError In errorCollection

bld.Append("/n Error Code: " + err.HResult.ToString("X", System.Globalization.CultureInfo.CurrentCulture))

bld.Append("/n Message : " + err.Message)

bld.Append("/n Minor Err.: " + err.NativeError.ToString())

bld.Append("/n Source : " + err.Source)

For Each numPar As Int32 In err.NumericErrorParameters

If 0 <> numPar Then

bld.Append("/n Num. Par. : " + numPar.ToString())

End If

Next

For Each errPar As String In err.ErrorParameters

If String.Empty <> errPar Then

bld.Append("/n Err. Par. : " + errPar)

End If

Next errPar

MessageBox.Show(bld.ToString())

bld.Remove(0, bld.Length)

Next err

End Sub

Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click

connect()

Dim query As String = "select * from FlightData"

Dim dap As New SqlCeDataAdapter(query, cn)

Dim dataset1 As New DataSet

dap.Fill(dataset1, "FlightData")

Disconnect()

End Sub

Sub connect()

Synch()

Try

cn.Open()

Catch err As SqlCeException

ShowErrors(err)

End Try

End Sub

Sub Disconnect()

Try

cn.Close()

Catch err As SqlCeException

ShowErrors(err)

End Try

End Sub

Private Sub dgdResults_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dgdResults.Click

End Sub

End Class

I want to synchronize the data from a SQLCE SERVER 2000

When i run the code above, the errors show:

Error Code:80045058
Message:Initializing SQL Server Reconciler has failed.

Error Code:80045058
Message:The course can't load "SSCE" Merge Replication program。please check the module wether enroll correctly.(probable description)

I do not know what's going wrong..=(
Who can help me?!!! HELP~~~~~~~~~
thanks..

Move to Sql Server Compact Edition forum.

Thanks!

|||

Please provide the exact error message, see here for instructions on how to get all error information:

http://msdn2.microsoft.com/en-us/library/ms174079.aspx

|||

I already used the error objectsuse and listed the error information above :

Error Code:80045058
Message:Initializing SQL Server Reconciler has failed.

Error Code:80045058
Message:The course can't load "SSCE" Merge Replication program。please check the module wether enroll correctly.(probable description)

and I do not know what's going wrong

help!

|||

You should also get a native error number (5 digits), please list this, and the proper english text for this:

The course can't load "SSCE" Merge Replication program。please check the module wether enroll correctly.(probable description)

|||

I use the SQL CE of Chinese Edition, so I don't know the proper english text for that.

the text list above is which I translate into English.

thanks

|||I still do not see the native error and the error source (although it appears to be in your ShowErrors code)|||

hi, eric zhang, I met a same problem with. and NATIVE_ERROR: 29045
I'm a chinese too.So, If you have any solution, please let me share with you, thx