Solved

Need to create new output column

Posted on 2014-03-26
3
163 Views
Last Modified: 2014-03-26
I need to create a new output column in a query that will be used as a index.  I    can not use the existing field for security reasons (Col A)  So I must generate a new column (Col B)
Lets say that Col A is a Social Security Number and a call center person can not see it so we will create a new field Col B.  Later internally we will re associate the records.

Col A exists in the table Col B does not.  I can not modify the table

How can I create a query to do this.  A stored procedure will be ok as long as it produces a result set that I can see and export

Example

TableX

Col A           Col B
163777439     1
163777439     1
163777439     1
163777439     1
163777439     1
163777439     1
718108418     2
718108418     2
718108418     2
918233645     3
918233645     3
418323022     4
418323022     4
418323022     4
418323022     4
418434193     5
418434193     5
418434193     5
418434193     5
0
Comment
Question by:charlesbaldo
  • 2
3 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 39957778
So ... is the point of the 1, 2, 3, 4, 5 numbers in Column B just to have a 'placeholder' to Column A?

If so, and you want it in a query, meaning the 1, 2, 3, 4, 5 won't be stored in a table, you can just use a RANK statement, sorted by whatever floats your boat...

SELECT ColA, RANK() OVER (ORDER BY ColA) as ColB
FROM YourTable
0
 

Author Closing Comment

by:charlesbaldo
ID: 39957790
Thank You
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39957794
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question