Showing posts with label mask. Show all posts
Showing posts with label mask. Show all posts

Monday, March 12, 2012

question about display mask & select number N to M records

Two questions:
1. With SQL, how can I setup display mask for value:
eg. display 100000 as $100,000
2. How can I select number N to M records in a table.
eg. select No. 50 - 100 records from a table. ( not top 50)
Thanks,
Guyang> 1. With SQL, how can I setup display mask for value:
> eg. display 100000 as $100,000
(a) I wouldn't rely on Enterprise Manager for data viewing / modification...
use a development tool for that, like Query Analyzer.
(b) there is no such thing as a "display mask" in SQL Server... this is
something that cute GUIs do. The data is not stored that way; if you want
it to be *presented* that way, write a view, e.g. SELECT CONVERT(VARCHAR,
moneyColumn, 1) FROM table
> 2. How can I select number N to M records in a table.
> eg. select No. 50 - 100 records from a table. ( not top 50)
SELECT TOP 50 * FROM
(SELECT TOP 100 * FROM table
ORDER BY some_column) x
ORDER BY some_column DESC
If you really need it to come back 50 -> 100, then
SELECT * FROM
(
SELECT TOP 50 * FROM
(SELECT TOP 100 * FROM table
ORDER BY some_column) x
ORDER BY some_column DESC) y
ORDER BY some_column

Monday, February 20, 2012

Question

In SqlServer, What is the datatype to mask a field of a table ? I mean if I want to save a password in a table, entering to SQLServer I'd want to display "*****" instead of "hello".

Thanks...

There are HTML, .NET, and Win32 controls that can be used to mask user input as they're entering some sensitive data in your application.

If, however, you want to ensure that users can't query your database for the names and passwords of all of the other users of the database, then you'll want to use any of a variety of permissions on your database.

For instance, if some operation is being done on the user's behalf, you could control the permissions on a table containing sensitive data to allow only indirect access (e.g. allow a server process to insert, update, delete from the table on the user's behalf, but disallow direct manipulation of the underlying table by the user). This obviously requires some form of strong and reliable user authentication.

You could also use row and/or column level permissions to control the amount of data that a user is able to see. For example, row level security (applied correctly) would allow everyone to perform a SELECT username, password FROM users and only see the data from rows that they had specifically been given access to.

There is lots of good documentation on establishing permissions on securables (tables, views, columns, etc.) in the SQL Server Books Online. There is also an excellent article on this subject at: http://www.microsoft.com/technet/prodtechnol/sql/2005/multisec.mspx