Combine CTE “WITH” and a “WITH XMLNAMESPACES….” in SQL Server

Use a comma instead of the second WITH, e.g. WITH XMLNAMESPACES(‘http://schemas.myself.com/SomeSchema’ as ns) ,CTEQuery AS ( SELECT (list of fields) FROM dbo.MyTable WHERE (conditions) ) SELECT * FROM CTEQuery The same if you want multiple CTE expressions. You only need to specify WITH once, and then all other WITH blocks just use a comma instead … Read more

PostgreSQL: Query has no destination for result data

The stored procedure won’t just return the result of the last SELECT. You need to actually return the value: CREATE OR REPLACE FUNCTION fun() RETURNS text AS $$ BEGIN — …. RETURN(SELECT dblink_disconnect()); END $$ LANGUAGE plpgsql; You’re getting the error because Postgres expects the function to return something of type text, but your function … Read more

How to use a CTE statement in a table-valued function in SQL Server

Syntax for the CTE in table valued function would be: CREATE FUNCTION GetDistributionTable ( @IntID int, @TestID int, @DateFrom datetime, @DateTo datetime ) RETURNS TABLE AS RETURN ( WITH cte AS ( SELECT ROUND(Result – AVG(Result) OVER(), 1) Result FROM RawResults WHERE IntID = @IntID AND DBTestID = @TestID AND Time >= @DateFrom AND Time … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)