Showing posts with label generate. Show all posts
Showing posts with label generate. Show all posts

Monday, March 26, 2012

Reg Exp for digits

Hi,

This is not SQL Server database problem, however, net search has failed
to generate a solution to the problem, I'm trying my luck at this NG
now.

Problem, remove the special character, [ from text.
e.g. text =
"this is [1] and [stuff] and some [2] and hat [3] and dog"

Desired result =
"this is 1 and [stuff] and some 2 and hat 3 and dog"

I know [[:digit:]] would find all the instances of digits inside
brackets such as [1], [2], [3]. However, I don't know how to get rid
of the special characters of [ and ].

Any regular expression expert out there?

Thanks.

DonNickName (dadada@.rock.com) writes:
> This is not SQL Server database problem, however, net search has failed
> to generate a solution to the problem, I'm trying my luck at this NG
> now.
> Problem, remove the special character, [ from text.
> e.g. text =
> "this is [1] and [stuff] and some [2] and hat [3] and dog"
> Desired result =
> "this is 1 and [stuff] and some 2 and hat 3 and dog"
> I know [[:digit:]] would find all the instances of digits inside
> brackets such as [1], [2], [3]. However, I don't know how to get rid
> of the special characters of [ and ].
> Any regular expression expert out there?

Since you did not specify which regular expressions you are using, I'm
taking the liberty to answer with the regexps I know, that is those of
Perl. In Perl you would say:

s/\[([0-9]+)\]/\1/g

The \[ means [, that is \ is an escape charactter. () is for grouping,
and \1 refers back to this paren.

I have only seen glimpses of the regexps in .Net, but it appears to be
similar to Perl. There might be different rules for when you need \
though. In Textpad that I use, I would have to say \( and \)to use parens
for grouping.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||> Problem, remove the special character, [ from text.
> e.g. text =
> "this is [1] and [stuff] and some [2] and hat [3] and dog"
> Desired result =
> "this is 1 and [stuff] and some 2 and hat 3 and dog"

Using the Zeus editor:

http://www.zeusedit.com

These are the search and replace regular expresions:

Search: (\[)([0-9]+)(\])
Replace: \2

Note: Zeus is shareware (45 day trial).

Jussi Jumppanen
Author: Zeus for Windows|||Jussi,

Thanks for the response, I think your tool seems clever, and yet I'm
trying not to introduce many tools within one project.

Don.|||Erland,

I appreciate your response, unfortunately I'm not using Perl.

Don|||NickName (dadada@.rock.com) writes:
> I appreciate your response, unfortunately I'm not using Perl.

If in you insist on not telling what you use, the responses may not always
be applicable.

Anyway, I hoped that you would be able to translate the Perl stuff to
whatever you are using.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||NickName wrote:

> Thanks for the response, I think your tool seems clever, and
> yet I'm trying not to introduce many tools within one project.

The good thing is the regexp's that I posted are just standard
unix style regexp's so they should work with any tool that can
handle these type of regexp's.

Jussi Jumppanen
Author: Zeus for Windows
http://www.zeusedit.com|||Shoot, you're tricky, now that you say it's sort of generic, I tried it
and it works nice, thanks.|||Erland,

Jussi's solution solved the problem. You seem a very kind person, if
one day I travel to Sweden and you're available, I would love to buy
you a beer.

Kind regards,

Don Lisql

Wednesday, March 7, 2012

Reducing the size of the transaction log file

At this time I am only playing with the applications that generate the data and send it to the database. Without doing too much, and with deleting most data tables that were created, my transaction log file has grown over a gigabyte. I tried using the SQL server management studio (express) to shrink the database (tried shrinking files, too) but that did not make the file smaller. Right now there is hardly any data in the database (6 tables, a dozen columns and rows each) so it must be old transactions that are kept in the log. How do I get rid of the old data and make the file size smaller? Thanks.
KamenHi,

I had the same issue yesterday, i had to, Backup the log file then use shrink, backup one moore time and shrink.|||1. Check your database 'Recovery Model', set it according to your requirement.
2. Make a backup plan matching your data sensitivity & requirement as well as schedule it.
3. Plan Log backup along with Log Truncate option.

Refer Books OnLine from SQL Query Analyzer.|||Thank you very much!
Kamen