Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 29th, 2004, 07:44 AM
kenny tan kenny tan is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 kenny tan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry How to create a Unique ID Column at VIEWS

Hi,

Does any one know how to create a new column which is not in the table at the SQL VIEWS?
And the column should generate ID automatically.

I really don know how to get it done...hope someone can help me asap....

Thanks

Reply With Quote
  #2  
Old November 29th, 2004, 11:48 AM
MrData MrData is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Sacramento, California, USA
Posts: 13 MrData User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 11 sec
Reputation Power: 0
Make sure you're reading your requirements correctly

You could just throw together some code like this that would do it:

Code:
 
 DECLARE @new_id uniqueidentifier
 
 SET @new_id = newid()
 
 SELECT @new_id, column1, column2
 FROM table
 WHERE whatever = whatever_else
 
 


But you wouldn't be able to use that ID to reference that particular record again, nor would you have any way to store it inside the view.
You'd have to use the code accessing the record to keep track of this ID, which would be essentially unrelated to the data (breaking one of the rules of normality).
It really is a better idea to add a column to the table, or find some combination of columns that is unique to the record and coming up with a coding scheme based on the value of those columns.

Hope this helps,
Steve

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > How to create a Unique ID Column at VIEWS


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway