Showing posts with label special. Show all posts
Showing posts with label special. Show all posts

Monday, March 26, 2012

How can I cast a money field in a view to look like money

I have a special need in a view for a money column to look like money and still be a money datatype. So I need it to look like $100.00 (prefered) or 100.00(can make work).

If I convert like this '$' + CONVERT (NVARCHAR(12), dbo.tblpayments.Amount, 1) it is now a nvarchar and will not work for me.

How can I cast so it is still money? by default the entries look like 100.0000.

They must remain a money datatype.

Try this out.

select'$' +cast (convert (decimal ( 10 , 2 ) , <column name> )as varchar )from <table name>
Hope this will help.|||

This still ends up as a varchar, so it will not work for me.

|||

Is there a way to cast to money and have it only show as 100.00 or can I only cast to decimal(10,2) to do this?

|||

As I have mentioned in my previous, for a similar question from you, what are you doing with the values? If its just for display purpose, use front end formatting functions.

|||

I think I can use the decimal(10,2) to work with my money issue. All though I would prefer that it remain as its original datatype.

I would love to use front end formatting; however, in this case it is not possible.

|||

Then you most likely have a serious design issue.

|||

If you have something constructive to say, please do so. Until you understand someone's underlying requirements you are as ignorant as the in experienced.

|||

If I needed more information to qualify my above statement, I would have asked for it. Fortunately, I don't.

Pointing out that what you are asking for would result in a poor design and you should probably rethink your process rather than implementation is hardly unconstructive. I do however, take offense to your statement, so I will end this conversation here. Good luck on getting help when you insult those around you.

PS. inexperienced is a single word.

|||

Motley,

It was not my intent to insult. What I hope for in these cases is not to be told that I'm wrong, as much as to be offered a constructive suggestion.

Monday, March 19, 2012

How can I "flag" a column on a table

I need to be able to "flag" a column on a table for special treatment and I am looking for a way to do this.

What I want to do is allow an administrator to somehow mark (flag) a column on a table. Then as part of another process, a script would scan all the columns in a database, looking for this flag, and take action based upon the data in this column.

This flag has to be applicable to existing, third-party databases, databases over which I have no control as to column names, or data types.

Ideally, I'd like to have some user-defined property of a column which would allow me to mark columns for use by my program. Does something like this exist.

The best solution I have come up with, so far, is to create a rule, which passes everything (LIKE '%'). By looking for the presence, or absence, of this rule, on a column, I have been able to flag columns.

I'd like to know, however, if there is a cleaner solution.

Thanks.

KenYou could create a seperate table with 2 columns:

tablename
columnname

Which lists the columns that have been flagged and in which table. The admin function can insert a record into this table and then during processing remove the record.

Friday, March 9, 2012

How am I protecting my Database from freign people at my network

as well particular tables in my database should be acceible only for users supply special U/N & PWD within my program

(Windows application - VB.NET)

thanks for referring

You better to have a security policy for your ENV. SQL Server follows two level security architecture. One at server level (LOGIN) and the other at Databaes level (User). You can restrict the permission on objects. you can give access to table(i would always prefer to create view or sp to access table instead of giving direct select permission on table) to individual user or role.

http://msdn2.microsoft.com/en-us/library/aa905172(SQL.80).aspx

http://www.microsoft.com/technet/community/chats/trans/sql/sql0522.mspx

Madhu