locked
Concat RRS feed

  • Question

  • Hi,

    Have the table as following

    move to a another table as following

    when i am try to concat this showing the error as following

    An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.

    Regards,

    Priviya .P

    Thursday, July 25, 2019 9:47 AM

Answers

  • Change the alias to a valid name.


    How does your query look like? In a cte all columns must have a unique Name, blank names on calculations are not allowed, you must define a alias, as the error message already says.

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Thursday, July 25, 2019 9:51 AM
    Answerer

All replies

  • Change the alias to a valid name.


    How does your query look like? In a cte all columns must have a unique Name, blank names on calculations are not allowed, you must define a alias, as the error message already says.

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Thursday, July 25, 2019 9:51 AM
    Answerer
  • I tried following  query,

    select 
    [WorkBreakDownID],
    concat([WorkedTime(Hrs)],':',[Worked Time(Mins)])
    into #temp1
    from  [dbo].[WorkTrackingSharepointListTGT]  

    error:

    An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.

    Thursday, July 25, 2019 10:22 AM
  • SELECT CAST( '00:'+ CAST(30 AS VARCHAR(5)) AS TIME (0))

    OR

    DECLARE @i int
    DECLARE @d Datetime
    SET @i= 30

    SET @d = DATEADD(ss,@i,'19000101')

    SELECT CONVERT(VARCHAR, @d, 114)


    Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/

    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting: Large scale of database and data cleansing
    Remote DBA Services: Improves MS SQL Database Performance
    SQL Server Integration Services: Business Intelligence


    Thursday, July 25, 2019 10:27 AM
  • i got it.

    thanks

    Thursday, July 25, 2019 10:32 AM
  • An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.

    You missed to give alias to the new column.

    Try below and also you would need additional logic to append 0's

    select 
    [WorkBreakDownID],
    concat([WorkedTime(Hrs)],':',[Worked Time(Mins)]) 'MergedColumn'
    into #temp1
    from  [dbo].[WorkTrackingSharepointListTGT] 


    Cheers
    Vaibhav
    MCSA (SQL Server 2012)

    Thursday, July 25, 2019 10:34 AM