SQL View Window with ID

I work with the SQL representation that I created, but I want to add to the identifier column (identification semantics), since the current one is missing. How to do it in SQL View?

enter image description here

+5
source share
4 answers

If there is no identifier column in the base table, you can create it with pseudo-columns.

In SQL server: SELECT ROW_NUMBER () OVER (ORDER by FiscalYear, FiscalMonth), FiscalYear, FiscalMonth, ... FROM ... See http://msdn.microsoft.com/en-us/library/ms186734.aspx

In Oracle: SELECT ROWNUM, FiscalYear, FiscalMonth, ... FROM .... In oracle, ROWNUM uses order in the result set.

+7
source

, . , .

+2

Unless you really care about being a genuine seed. You can use ROW_NUMBER () to create a surface identifier.

+1
source

You can simply use the following to automatically add a GUID to your view:

CREATE VIEW VIEW_Name
AS
   NEWID() AS ID,
   your other columns here
FROM 
   dbo.YourTable
+1
source

All Articles