Showing posts with label index. Show all posts
Showing posts with label index. Show all posts

Friday, March 23, 2012

read file and exec contents

I have a text file that contains "create index" statements - thanks to those
of you here who helped me get past my hurdles with this step earlier in the
w. :)
Now I need to read the file and execute it - basically execute the contents
of the file. I'm looking for suggestions on how to do it. I thought about
using the code below to read the contents into a global var but it seems as
if it only reads so many chars into a global var. My thought was to read it
into a global var then use an execute sql task to execute the global var.
Here is what I have so far. Any suggestion on the best way to apply the
create index statements in the text file?
Thanks, Andre
Function Main()
Set fso = CreateObject("Scripting.FileSystemObject")
Set textStreamObject = fso.OpenTextFile("c:\TableIndexes.txt",1,false,0)
' msgbox textStreamObject.ReadAll
DTSGlobalVariables("strIndexes").Value = textStreamObject.ReadAll
Set textStreamObject = Nothing
Set fso = Nothing
Main = DTSTaskExecResult_Success
End Function
Sample of my TableIndexes.txt file
ALTER TABLE [MYTABLE] ADD
CONSTRAINT [PK_MYTABLE] PRIMARY KEY CLUSTERED
(
[RowID]
) WITH FILLFACTOR = 90 ON [PRIMARY]
GO
CREATE INDEX [prov_id] ON [MYTABLE]([Col1]) WITH FILLFACTOR = 90 ON
[PRIMARY]
GO
CREATE INDEX [ref_id] ON [MYTABLE]([Col2]) WITH FILLFACTOR = 90 ON
[PRIMARY]
GOWhy don't you just use OSQL or SQLCMD to do this?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Andre" <no@.spam.com> wrote in message news:eufKUxwTGHA.1728@.TK2MSFTNGP11.phx.gbl...darkred">
>I have a text file that contains "create index" statements - thanks to thos
e of you here who helped
>me get past my hurdles with this step earlier in the
> w. :)
> Now I need to read the file and execute it - basically execute the content
s of the file. I'm
> looking for suggestions on how to do it. I thought about
> using the code below to read the contents into a global var but it seems a
s if it only reads so
> many chars into a global var. My thought was to read it
> into a global var then use an execute sql task to execute the global var.
> Here is what I have so far. Any suggestion on the best way to apply the c
reate index statements
> in the text file?
> Thanks, Andre
> Function Main()
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set textStreamObject = fso.OpenTextFile("c:\TableIndexes.txt",1,false,0)
> ' msgbox textStreamObject.ReadAll
> DTSGlobalVariables("strIndexes").Value = textStreamObject.ReadAll
> Set textStreamObject = Nothing
> Set fso = Nothing
> Main = DTSTaskExecResult_Success
> End Function
>
> Sample of my TableIndexes.txt file
> ALTER TABLE [MYTABLE] ADD
> CONSTRAINT [PK_MYTABLE] PRIMARY KEY CLUSTERED
> (
> [RowID]
> ) WITH FILLFACTOR = 90 ON [PRIMARY]
> GO
> CREATE INDEX [prov_id] ON [MYTABLE]([Col1]) WITH FILLFACTOR = 90 ON
> [PRIMARY]
> GO
> CREATE INDEX [ref_id] ON [MYTABLE]([Col2]) WITH FILLFACTOR = 90 ON
> [PRIMARY]
> GO
>|||Since you are reading the file from VBScript, you could simply store the
string in a local variable and execute as a statement using
ADODB.Command.Execute method call from the same script:
http://msdn.microsoft.com/library/d.../>
xecutex.asp
It seems there is no need to store the string in a DTS variable, just a
local variable. For example:
Dim strIndexes
If this task does not need to be schedules, then perhaps instead of DTS, use
Windows Scripting Host or OSQL from the command line.
"Andre" <no@.spam.com> wrote in message
news:eufKUxwTGHA.1728@.TK2MSFTNGP11.phx.gbl...
>I have a text file that contains "create index" statements - thanks to
>those of you here who helped me get past my hurdles with this step earlier
>in the
> w. :)
> Now I need to read the file and execute it - basically execute the
> contents of the file. I'm looking for suggestions on how to do it. I
> thought about
> using the code below to read the contents into a global var but it seems
> as if it only reads so many chars into a global var. My thought was to
> read it
> into a global var then use an execute sql task to execute the global var.
> Here is what I have so far. Any suggestion on the best way to apply the
> create index statements in the text file?
> Thanks, Andre
> Function Main()
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set textStreamObject = fso.OpenTextFile("c:\TableIndexes.txt",1,false,0)
> ' msgbox textStreamObject.ReadAll
> DTSGlobalVariables("strIndexes").Value = textStreamObject.ReadAll
> Set textStreamObject = Nothing
> Set fso = Nothing
> Main = DTSTaskExecResult_Success
> End Function
>
> Sample of my TableIndexes.txt file
> ALTER TABLE [MYTABLE] ADD
> CONSTRAINT [PK_MYTABLE] PRIMARY KEY CLUSTERED
> (
> [RowID]
> ) WITH FILLFACTOR = 90 ON [PRIMARY]
> GO
> CREATE INDEX [prov_id] ON [MYTABLE]([Col1]) WITH FILLFACTOR = 90 ON
> [PRIMARY]
> GO
> CREATE INDEX [ref_id] ON [MYTABLE]([Col2]) WITH FILLFACTOR = 90 ON
> [PRIMARY]
> GO
>|||It does need to be scheduled, and is actually part of a large DTS package.
I did change it to be in a local var rather than a global var - thanks for
that tip. It's working great now, thanks for your help.
Andre

Saturday, February 25, 2012

rda dropping primary key index

I am using RDA to download a tables

I use TrackingOffWithIndexes

the issue is that when I download a small set of data the primary key index is there

when I download a larger set. the index gets dropped (no error) just slowness when querying the table

the max database size is set to 1024mb and the temp database size is set to 1024mb

the actual db size (with the missing index) is 262 mb... lot's of room left!

when I try to create the index manually after the download in sql server management studio I get this error:

Not enough storage is available to complete this operation

I am using 2GB sd cards and nothing else is on the card.

any ideas?

Regards,

eric [at] westgen com

This indicates an out of error condition, make sure you dispose of the RDA objects before creating the index in code.|||

Thanks for the reply but

when running the code I get NO error... just a missing index

the index should come down automatically as long as it can fit in the db size... but it does not.. it only comes down whith a smaller set of data.

The error I get when creating the index manually is in sql server management studio... and there is no rda object to get rid of

can you please explain your reply a little more

Regards,

eric

|||How wide is your index, please detail schema and create index statement. Do you create the index with the sdf file on your hard disk or on the SD card?|||

Hi,

The table could have in excess of 1 million rows... I am not sure at how many it decides not to download the index/primary key constraint but it seems to be around the point where the database reaches 150mb although as stated previously the max size and max temp file size are set to 1024 mb

The table structure is:

Bull_id int

Cow_id int

Inbreeding_Value real

the primary key is bull_id, cow_id

I used this script to try to manually apply the index/key

ALTER TABLE INBREEDING ADD
CONSTRAINT PK_INBREEDING PRIMARY KEY
(
COW_Id,
BULL_Id
)

the db was on the device at the time I did not try from the desktop

the goal here is not to do this manually but to have the index be downloaded with the rda pull command

Thanks a lot for your help!!!

regards,

ric

|||You may be hitting a limitation in SQL CE, like max table size = 512 MB? For limits, see SQL CE BOL: Database Objects|||

Thanks again Erik

I checked the sql mobile limitations... and according to the docs the table size limit is the same as the db size limit.

I didn't see any other limits that seemed relevant

I will continue my search for an answer/solution

Regards,

ric

|||

Hi Erik,

I want to correct my previous post

you are right... there is a 512 mb size limit on tables

I will investigate on wether or not this is the cause of my issue

thanks again

ric

|||

based on my calcs

5335074 rows has a table size of 120mb even if the index took twice as much memory as the rows the total size would still be under the 512mb limit

so I still can't explain why RDA pull is dropping the primary key/index when the table reaches a certain number of rows

Regards,

ric

|||If you can provide sample data and you Pull code off-line (see my email i my profile), then I can see if I can reproduce, if so it may be a case for Microsoft to fix.|||

Hi..

I have meet the same problem, too.

I create a table with 1,380,000 rows data,

the db real size around 114 MB.

The primary key size is nchar(6).

When I use RDA pull, I found that the primary

key in the PDA disappear. So, It took a long time

to get query response.

But when I delete some rows to 680,000 rows of data.

After I pull, The primary key can pull from the SQL Server.

PS: I didn't change any code. Just delete some rows.

Is that SQL-Mobile's bug!!!

VIckrey

|||Maybe a connection timeout problem, see this post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1624137&SiteID=1|||

ErikEJ wrote:

Maybe a connection timeout problem, see this post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1624137&SiteID=1[/quote]

No, there is no any error.

HRESULT=S_OK..!@.#$

Sad

|||

Vickrey,

Have you found a solution?

I still can't get mine to work with so many rows

I am convinced this is a sql mobile bug

I cannot even add the key back (with code) once the rows are downloaded

There must be some max row bug when the table has a key.

Please let me know if you come across anything.

Regards,

eric

rda dropping primary key index

I am using RDA to download a tables

I use TrackingOffWithIndexes

the issue is that when I download a small set of data the primary key index is there

when I download a larger set. the index gets dropped (no error) just slowness when querying the table

the max database size is set to 1024mb and the temp database size is set to 1024mb

the actual db size (with the missing index) is 262 mb... lot's of room left!

when I try to create the index manually after the download in sql server management studio I get this error:

Not enough storage is available to complete this operation

I am using 2GB sd cards and nothing else is on the card.

any ideas?

Regards,

eric [at] westgen com

This indicates an out of error condition, make sure you dispose of the RDA objects before creating the index in code.|||

Thanks for the reply but

when running the code I get NO error... just a missing index

the index should come down automatically as long as it can fit in the db size... but it does not.. it only comes down whith a smaller set of data.

The error I get when creating the index manually is in sql server management studio... and there is no rda object to get rid of

can you please explain your reply a little more

Regards,

eric

|||How wide is your index, please detail schema and create index statement. Do you create the index with the sdf file on your hard disk or on the SD card?|||

Hi,

The table could have in excess of 1 million rows... I am not sure at how many it decides not to download the index/primary key constraint but it seems to be around the point where the database reaches 150mb although as stated previously the max size and max temp file size are set to 1024 mb

The table structure is:

Bull_id int

Cow_id int

Inbreeding_Value real

the primary key is bull_id, cow_id

I used this script to try to manually apply the index/key

ALTER TABLE INBREEDING ADD
CONSTRAINT PK_INBREEDING PRIMARY KEY
(
COW_Id,
BULL_Id
)

the db was on the device at the time I did not try from the desktop

the goal here is not to do this manually but to have the index be downloaded with the rda pull command

Thanks a lot for your help!!!

regards,

ric

|||You may be hitting a limitation in SQL CE, like max table size = 512 MB? For limits, see SQL CE BOL: Database Objects|||

Thanks again Erik

I checked the sql mobile limitations... and according to the docs the table size limit is the same as the db size limit.

I didn't see any other limits that seemed relevant

I will continue my search for an answer/solution

Regards,

ric

|||

Hi Erik,

I want to correct my previous post

you are right... there is a 512 mb size limit on tables

I will investigate on wether or not this is the cause of my issue

thanks again

ric

|||

based on my calcs

5335074 rows has a table size of 120mb even if the index took twice as much memory as the rows the total size would still be under the 512mb limit

so I still can't explain why RDA pull is dropping the primary key/index when the table reaches a certain number of rows

Regards,

ric

|||If you can provide sample data and you Pull code off-line (see my email i my profile), then I can see if I can reproduce, if so it may be a case for Microsoft to fix.|||

Hi..

I have meet the same problem, too.

I create a table with 1,380,000 rows data,

the db real size around 114 MB.

The primary key size is nchar(6).

When I use RDA pull, I found that the primary

key in the PDA disappear. So, It took a long time

to get query response.

But when I delete some rows to 680,000 rows of data.

After I pull, The primary key can pull from the SQL Server.

PS: I didn't change any code. Just delete some rows.

Is that SQL-Mobile's bug!!!

VIckrey

|||Maybe a connection timeout problem, see this post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1624137&SiteID=1|||

ErikEJ wrote:

Maybe a connection timeout problem, see this post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1624137&SiteID=1[/quote]

No, there is no any error.

HRESULT=S_OK..!@.#$

Sad

|||

Vickrey,

Have you found a solution?

I still can't get mine to work with so many rows

I am convinced this is a sql mobile bug

I cannot even add the key back (with code) once the rows are downloaded

There must be some max row bug when the table has a key.

Please let me know if you come across anything.

Regards,

eric

rda dropping primary key index

I am using RDA to download a tables

I use TrackingOffWithIndexes

the issue is that when I download a small set of data the primary key index is there

when I download a larger set. the index gets dropped (no error) just slowness when querying the table

the max database size is set to 1024mb and the temp database size is set to 1024mb

the actual db size (with the missing index) is 262 mb... lot's of room left!

when I try to create the index manually after the download in sql server management studio I get this error:

Not enough storage is available to complete this operation

I am using 2GB sd cards and nothing else is on the card.

any ideas?

Regards,

eric [at] westgen com

This indicates an out of error condition, make sure you dispose of the RDA objects before creating the index in code.|||

Thanks for the reply but

when running the code I get NO error... just a missing index

the index should come down automatically as long as it can fit in the db size... but it does not.. it only comes down whith a smaller set of data.

The error I get when creating the index manually is in sql server management studio... and there is no rda object to get rid of

can you please explain your reply a little more

Regards,

eric

|||How wide is your index, please detail schema and create index statement. Do you create the index with the sdf file on your hard disk or on the SD card?|||

Hi,

The table could have in excess of 1 million rows... I am not sure at how many it decides not to download the index/primary key constraint but it seems to be around the point where the database reaches 150mb although as stated previously the max size and max temp file size are set to 1024 mb

The table structure is:

Bull_id int

Cow_id int

Inbreeding_Value real

the primary key is bull_id, cow_id

I used this script to try to manually apply the index/key

ALTER TABLE INBREEDING ADD
CONSTRAINT PK_INBREEDING PRIMARY KEY
(
COW_Id,
BULL_Id
)

the db was on the device at the time I did not try from the desktop

the goal here is not to do this manually but to have the index be downloaded with the rda pull command

Thanks a lot for your help!!!

regards,

ric

|||You may be hitting a limitation in SQL CE, like max table size = 512 MB? For limits, see SQL CE BOL: Database Objects|||

Thanks again Erik

I checked the sql mobile limitations... and according to the docs the table size limit is the same as the db size limit.

I didn't see any other limits that seemed relevant

I will continue my search for an answer/solution

Regards,

ric

|||

Hi Erik,

I want to correct my previous post

you are right... there is a 512 mb size limit on tables

I will investigate on wether or not this is the cause of my issue

thanks again

ric

|||

based on my calcs

5335074 rows has a table size of 120mb even if the index took twice as much memory as the rows the total size would still be under the 512mb limit

so I still can't explain why RDA pull is dropping the primary key/index when the table reaches a certain number of rows

Regards,

ric

|||If you can provide sample data and you Pull code off-line (see my email i my profile), then I can see if I can reproduce, if so it may be a case for Microsoft to fix.|||

Hi..

I have meet the same problem, too.

I create a table with 1,380,000 rows data,

the db real size around 114 MB.

The primary key size is nchar(6).

When I use RDA pull, I found that the primary

key in the PDA disappear. So, It took a long time

to get query response.

But when I delete some rows to 680,000 rows of data.

After I pull, The primary key can pull from the SQL Server.

PS: I didn't change any code. Just delete some rows.

Is that SQL-Mobile's bug!!!

VIckrey

|||Maybe a connection timeout problem, see this post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1624137&SiteID=1|||

ErikEJ wrote:

Maybe a connection timeout problem, see this post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1624137&SiteID=1[/quote]

No, there is no any error.

HRESULT=S_OK..!@.#$

Sad

|||

Vickrey,

Have you found a solution?

I still can't get mine to work with so many rows

I am convinced this is a sql mobile bug

I cannot even add the key back (with code) once the rows are downloaded

There must be some max row bug when the table has a key.

Please let me know if you come across anything.

Regards,

eric