all groups > sql server mseq > june 2004 >
You're in the

sql server mseq

group:

Defining a concatenated column size


Defining a concatenated column size Kirk
6/18/2004 7:49:01 AM
sql server mseq: I have a column within a view that is a concatenation of several different columns of another table. It goes something like: tblA.columnA + '-' tblA.columnB + '-' tblA.columnC + '-' tblA.columnD As 'NewColumn'

Is it possible to define the size of the 'NewColumn' within the view? I have a stored procedure that is going to create a temp table based on this view, but when I execute the stored procedure I get the following error:

Line 1: Incorrect syntax near '*'.

In looking at the stored procedure code, the error is a result of when the create table occurs, it defines the NewColumn as nvarchar(*), which is causing the error.

Any help would be appreciated.

Re: Defining a concatenated column size Hugo Kornelis
6/18/2004 10:06:57 PM
[quoted text, click to view]

Hi Kirk,

Define the column as nvarchar(4000) (the maximum length). Or, if you want
the max. length to be shorter, use a lower number. The result of the
concatenation will be trimmed to the max. length the column holds (and you
may also choose to trim explicitly, using LEFT or CAST function).

Best, Hugo
--

AddThis Social Bookmark Button