June 27, 2011 at 5:49 am
hi,
i have problem in tsql while creating the surrogate key for a view table.
can any one help on this.....:-)
June 27, 2011 at 6:11 am
Can you expand a bit?
An example would help a lot.
-- Gianluca Sartori
June 27, 2011 at 10:08 am
Why would you create a surrogate key on a view?
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
June 27, 2011 at 10:55 pm
hi, this is my source table i need to create view table for this with surrogate key.Can u help me................
SELECT TOP 1000 [C_ID]
,[C_NM]
,[C_TYPE_ID]
,[DUR]
,[FEES]
,[LOAN_AV_FLG]
,[INSTALMENT]
,[NO_INSTALMENT]
FROM [Mahesh_DB].[dbo].[Course]
June 27, 2011 at 11:14 pm
maheshkrishnas (6/27/2011)
hi, this is my source table i need to create view table for this with surrogate key.Can u help me................SELECT TOP 1000 [C_ID]
,[C_NM]
,[C_TYPE_ID]
,[DUR]
,[FEES]
,[LOAN_AV_FLG]
,[INSTALMENT]
,[NO_INSTALMENT]
FROM [Mahesh_DB].[dbo].[Course]
My recommendation would be to lookup CREATE VIEW in Books Online for this. Books Online is the help-system that comes with SQL Server.
--Jeff Moden
Change is inevitable... Change for the better is not.
June 28, 2011 at 12:27 am
Any reason why you cannot use C_ID itself , if you need an other then try using the row_number function or a guid or a computed column. I cant see why your view would need one , however its godd to keep in mind that the key will be used by applications and should not change.
Ideally an Identity column on the underlying table is the best solution.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply