Showing posts with label extraction. Show all posts
Showing posts with label extraction. Show all posts

Friday, March 30, 2012

How to truncate a str?

Hello All,

I am doing some data extraction from a database table: custtable. The customers have zip codes of 9 digits however I just need the first five of them. I am not sure of the syntax. Can anyone suggest me on this one?

This is what my statement is

where ((len (ct.zipcode ) > 5 and ct.country = '001')or ct.country <> '001')

This one returns customers with zipcodes > 5 and I need to only truncate this, coz my database also contains cust with zip code of only 5 digits and I have extracted that data already. Now I need all the zipcodes that have a length of 9 to be truncted to 5.

An earliest possible response is highly appreciable.

Thanks,

Rashi

Hello Rashi,

Try this:

select left(ct.zipcode, 5)
where ((len (ct.zipcode ) > 5 and ct.country = '001')or ct.country <> '001')

Hope this helps.

Jarret

|||useless post|||

Even for T-SQL, it's still is

SELECT LEFT(postal_code, 5)

FROM AddressTable

Shouldn't need to, but if you want to trim it - RTRIM(LTRIM(LEFT(postal_code,5)))

Sunday, February 19, 2012

How to Stop Logging

Hi,

I am doing some resource hungry tasks (some extraction and loading
through DTS), for which each time the SQL Server Log files gets filled
up!

Is there any way to stop the logging (like as during restore)?

Thanks in advance.

-surajits_laha@.rediffmail.com (Surajit Laha) wrote in message news:<ba8ee108.0401290212.6defeb00@.posting.google.com>...
> Hi,
> I am doing some resource hungry tasks (some extraction and loading
> through DTS), for which each time the SQL Server Log files gets filled
> up!
> Is there any way to stop the logging (like as during restore)?
> Thanks in advance.
> -surajit

You can't disable logging, but you could set the database recovery
model to simple during the load. You might also be able to load in
batches, instead of in a single transaction, which should require less
log space. The DTS Transform Data Task allows you to specify a batch
size, for example.

Simon