Answers

Question and Answer:

  Home  MS SQL Server

⟩ How To Assign New Column Names in a View?

By default, column names in a view are provided by the underlying SELECT statement.

But sometimes, the underlying SELECT statement can not provide names for output columns that specified as expressions with functions and operations. In this case, you need to assign new names for the view's columns. The tutorial exercise below creates a view to merge several table columns into a single view column with a format called CSV (Comma Separated Values):

CREATE VIEW ggl_links_dump AS

SELECT CONVERT(VARCHAR(20),id)

+ ', ' + CONVERT(VARCHAR(20),counts)

+ ', ''' + url + ''''

FROM ggl_links WHERE counts > 1000

GO

Msg 4511, Level 16, State 1, Procedure ggl_links_dump,

Line 2

Create View or Function failed because no column name

was specified for column 1.

 141 views

More Questions for you: