Showing posts with label quotdata. Show all posts
Showing posts with label quotdata. Show all posts

Wednesday, March 21, 2012

Data Dictionary

Hi,
Is there anything analogous to a "data dicitionary" tool that is bundled with SQL Server 2005? Something that could be used to store and manage enterprise data meta-data.
Thanks,
JR

The system tables and views...following:

Data dictionary

From Wikipedia, the free encyclopedia

A data dictionary is a set of metadata that contains definitions and representations of data elements. Within the context of a DBMS, a data dictionary is a read-only set of tables and views. The data dictionary is database in its own dictionary. Amongst other things, a data dictionary holds the following information:

Precise definition of data elements

Usernames, roles and privileges

Schema objects

Integrity constraints

Stored procedures and triggers

General database structure

Space allocations|||Hi,
Thanks for the info. May I assume that these system tables and their contents are officially documented somewhere? Any pointers to any such docs would be greatly appreciated.
Regards,
JR|||

In Object Explorer in SQL Server Management Studio, look under Databases/System Databases/master/Views. Master contains server level information. Similarly Databases/System Databases/msdb/Views | Tables has server level information for SQL Agent, Database Mail, Log Shipping and other technologies.

Each user database also has system views.

With the exception of a few internal views and tables each view or table has a topic in Books Online.

|||True most of the information pertaining to the components & objects of SQL Server are documented in Books online, there are few bits and pieces that are not documented in BOL where you can find information by searching them on web.

Data Dictionary

Hi,
Is there anything analogous to a "data dicitionary" tool that is bundled with SQL Server 2005? Something that could be used to store and manage enterprise data meta-data.
Thanks,
JR

The system tables and views...following:

Data dictionary

From Wikipedia, the free encyclopedia

A data dictionary is a set of metadata that contains definitions and representations of data elements. Within the context of a DBMS, a data dictionary is a read-only set of tables and views. The data dictionary is database in its own dictionary. Amongst other things, a data dictionary holds the following information:

Precise definition of data elements Usernames, roles and privileges Schema objects Integrity constraints Stored procedures and triggers General database structure Space allocations|||Hi,
Thanks for the info. May I assume that these system tables and their contents are officially documented somewhere? Any pointers to any such docs would be greatly appreciated.
Regards,
JR
|||

In Object Explorer in SQL Server Management Studio, look under Databases/System Databases/master/Views. Master contains server level information. Similarly Databases/System Databases/msdb/Views | Tables has server level information for SQL Agent, Database Mail, Log Shipping and other technologies.

Each user database also has system views.

With the exception of a few internal views and tables each view or table has a topic in Books Online.

|||True most of the information pertaining to the components & objects of SQL Server are documented in Books online, there are few bits and pieces that are not documented in BOL where you can find information by searching them on web.

Sunday, March 11, 2012

data conversion - numeric to string loosing precision

Hi All,

i'm using a "data conversion" object to convert a numeric field to a string just before i save the record set to the database.

the problem is when this numeric field is > 0 it looses the precision on its decimal value.

example, if numeric value is 0.32

after converting this to a string, the new value will be : .32

it's lost the 0 infront of it. i can't do this converion in the query level because it's a derived field, so i need to convert it to a string before stroing it.

when converting to string i'm using the code page 1252 (ANSI - Latin I). i also tried with unicode string both looses this 0 infront.

can any one help on this?

Is your ultimate database target for the numeric data type a character based column, hence the need to retain the leading zeros?

If that is the case, retaining leading zeros can be accomplished with a derived column transform, rather than a data conversion transform. There you have access to the SSIS expression language, with a relatively standard, if meager, set of string functions, as well as type casts.

Another alternative for pretty much an data type conversion is a Script Transform, which will afford you the full power of the .NET framework, including in this case custom numeric formats for types destinated for strings.|||

Hi jaegd,

i tried that, but no luck. i use a derived table and this is my expression

ISNULL(investmentPercentage) ? 0.00 : investmentPercentage

here investmentPercentage is a numeric (15,2). i add the above expression as a new column (string) (8 chars). but still it looses the 0

.00 when it's null

.32 when it;s 0.32

any comments

AJ

|||

Use the Script Task, and follow the instructions in this link for numeric format specifiers for strings. You need to do something similar to this...

Dim number as float

number.ToString("D")

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconstandardnumericformatstrings.asp

|||

In the derived column, you can still acheive it with conditional logic The script as mentioned above is cleaner, but if you want to avoid adding that, you can try an expression like:

(investmentPercentage < 1 ? "0" : "") + (DT_WSTR, 20)investmentPercentage

This expression will add a "0" to the beginning of the string if the number is less than one (which is the only time the zero is dropped). When the number is greater than or equal to 1, an empty string is added.

NOTE: this does not take into account negative values. If investmentPercentage can be negative, you will need to tweak the expression a little (or post here, and I can help with that).

Thanks
Mark

|||

Hi Mark,

thanks for that, but it sort of half answer my question.

yes investmentPercentage can be negative or can even be null. i was wondering if there's an eaisier way. i've got a lot of cloumns like this, writing an expression for each of them this long can be tedious. is this how you would "tweak" it?

ISNULL(investmentPercentage) ? "0.00" : (investmentPercentage < 1 && investmentPercentage >-1 ? "0" : "") + (DT_WSTR, 8)investmentPercentage

|||

You might find it easier to use string formatting in the script component... I can't think of any other way that would be better.

As for tweaking the expression, you will have to do some extra things to take care of the negative sign (so the prepended zero doesn't end up before the negative sign). The following expression adds a case for values between -1 and 0 to handle that:

ISNULL(investmentPercentage) ? (DT_WSTR,8)"0.00" : investmentPercentage < 0 && investmentPercentage > -1 ? "-0" + SUBSTRING((DT_WSTR,8)investmentPercentage, 2, 8) : ((investmentPercentage >= 0 && investmentPercentage < 1 ? "0" : "") + (DT_WSTR,8)investmentPercentage

Let me know if this does the trick for you.

Thanks
Mark