SQLTeam.com | Weblogs | Forums

Correct Usage of ISNULL?


#1

Hello, I have this SQL query and when I run it with the ISNULL line it does not work. How am I using ISNULL incorrectly? I get the following 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.

 SELECT PROJECT.proj_id, 
        PROJECT.proj_short_name, 
        TASK.task_id, 
        TASK.task_name,
    	TASK.task_code,
    	TASK.task_type, 
    	TASK.wbs_id, 
    	ISNULL(TASK.act_start_date,TASK.target_start_date), 
    	TASK.target_end_date, 
    	TASK.phys_complete_pct, 
    	PROJWBS.seq_num
    INTO [PROJECTS].[dbo].[SUBTASKS]
    FROM [TEST].[dbo].[PROJECT]
    INNER JOIN [TEST].[dbo].[PROJWBS]
    ON PROJECT.proj_id = PROJWBS.proj_id
    INNER JOIN [TEST].[dbo].[TASK]
    ON PROJWBS.wbs_id = TASK.wbs_id
    Where proj_short_name = 'Project D1012'

#2

You're very close:

ISNULL(TASK.act_start_date,TASK.target_start_date) AS target_start_date,


#3

That did the trick, thanks.