September 14, 2015 at 3:21 pm
Im getting error for the below code:
Msg 102, Level 15, State 1, Procedure abcd, Line 26
Incorrect syntax near ')'.
can anyone help me figure out what it could be?
CREATE VIEW abcd AS
(
SELECT
a.description,
a.corporate_tag,
a.corporate ,
a.banner_tag,
a.banner,
a.region_tag,
a.region,
a.division_tag,
a.division,
a.hierarchy_level,
a.load_id,
a.process_name,
a.loop_id,
( case WHEN b.corporate_tag IS NULL or b.banner_tag IS NULL THEN 'I' Else 'U' END )
/* or ( case WHEN b.banner_tag IS NULL THEN 'I' Else 'U' END)
or (case WHEN b.region_tag IS NULL THEN 'I' Else 'U' END)
or ( case WHEN b.division_tag IS NULL THEN 'I' Else 'U' END )) */
AS OPERATION
FROM stg_ref_nielsen_hierarchy a
LEFT JOIN
ref_nielsen_hierarchy b
ONa.corporate_tag = cast(b.corporate_tag as varchar)
OR a.banner_tag = cast(b.banner_tag as varchar)
OR a.region_tag = cast(b.region_tag as varchar)
OR a.division_tag = cast( b.division_tag as varchar )
September 14, 2015 at 3:25 pm
Just remove the arbitrary opening parenthesis
😎
CREATE VIEW abcd AS
SELECT
a.description,
a.corporate_tag,
a.corporate ,
a.banner_tag,
a.banner,
a.region_tag,
a.region,
a.division_tag,
a.division,
a.hierarchy_level,
a.load_id,
a.process_name,
a.loop_id,
( case WHEN b.corporate_tag IS NULL or b.banner_tag IS NULL THEN 'I' Else 'U' END )
/* or ( case WHEN b.banner_tag IS NULL THEN 'I' Else 'U' END)
or (case WHEN b.region_tag IS NULL THEN 'I' Else 'U' END)
or ( case WHEN b.division_tag IS NULL THEN 'I' Else 'U' END )) */
AS OPERATION
FROMstg_ref_nielsen_hierarchy a
LEFT JOIN
ref_nielsen_hierarchy b
ONa.corporate_tag = cast(b.corporate_tag as varchar)
OR a.banner_tag = cast(b.banner_tag as varchar)
OR a.region_tag = cast(b.region_tag as varchar)
OR a.division_tag = cast( b.division_tag as varchar )
September 14, 2015 at 3:29 pm
Thanks!!...
September 14, 2015 at 3:56 pm
sqllearner1234 (9/14/2015)
ONa.corporate_tag = cast(b.corporate_tag as varchar)OR a.banner_tag = cast(b.banner_tag as varchar)
OR a.region_tag = cast(b.region_tag as varchar)
OR a.division_tag = cast( b.division_tag as varchar )
I recommend you add a size on those VARCHAR casts, otherwise you will get default size which might not be enough.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply