Syntax Error in showing Error Description - sql-server

What is the correct Syntax to be applied for "#[System::ErrorDescription]" inside the query like "INSERT" ? I am unable to retrieve the correct Error Description inside the table, as the result in the table is showing as "#[System::ErrorDescription]". I am not getting the result !

Use a command like:
INSERT YourTable (errordesc) SELECT ?
And then put a parameter called 1 in, populated with #[System::ErrorDescription]

Related

Can worksheet filters only be used in WHERE or GROUP BY Clause in Snow?flake

I would like to use the value selected in a filter as a returned column.
For instance like
SELECT :MyFilter;
but I get the following error:
No valid expression found for :Subscription. Expecting "<expression> = :MyFilter" (line 1)
You may need to declare a local variable, assign it the value from :MyFilter, and then use in your query. See the following reference: https://docs.snowflake.com/en/developer-guide/snowflake-scripting/variables.html#working-with-variables

How to filter "show tables"

I would like to filter the output of show tables.
The documentation has one example on how to do this using result_scan(last_query_id()), but for me the example does not work:
show tables;
select "schema_name", "name" as "table_name", "rows"
from table(result_scan(last_query_id()))
where "rows" = 0;
-- SQL compilation error: error line 1 at position 8 invalid identifier 'SCHEMA_NAME'
The column SCHEMA_NAME is actually in the output of show tables,
so I do not understand what is wrong.
Best,
Davide
Run the following on your account and see what it is set to:
show parameters like 'QUOTED_IDENTIFIERS_IGNORE_CASE';
If this is set to TRUE, then it is ignoring the quotes in your query, which will then uppercase the column names, which won't match to the lowercase names of the SHOW output.
To resolve for your own session, you can run the following:
ALTER SESSION SET QUOTED_IDENTIFIERS_IGNORE_CASE = False;
You can also change this at a user or account level, if you wish. Setting this value to TRUE isn't recommended for the reason that you are running into.
You can reference the filter column using $<col_n> syntax (#8 for rows).
Example:
show tables;
select *
from table(result_scan())
where $8 > 5
That being said, your query worked for me.

SSRS IIF Statement not working properly when passing one or more of the values from parameter

I have SSRS report parameter name "Status" which contains Passed and Failed values. In the report I have one column called Name. I want to hide this column when Status = "Failed" and I want to show this column when Status = "Passed" or Status = "Passed,Failed".
=IIF(InStr(JOIN(Parameters!Status.Value,","), "Failed"),True,False)
Above expression hide the Name column for when Status = "Passed,Failed".
You should be able to do this .. but with the join, you may not need the / ToString() bit
=IIF((JOIN(Parameters!Status.Value,",").ToString().Contains("Failed"),"True","False")
Alternative:
=IIf(InStr(JOIN(Parameters!Status.Value,",").ToString(),"Failed") > 0,"True","False")
How about this:
=String.Join(",", Parameters!Status.Label).Contains("Failed")

Why do I get "Synonym 'syn.Syn_AAA' refers to an invalid object" Error?

When I execute a stroed procedure it works. But specifically when I run the select statement I get the following error
Synonym 'syn.Syn_NEO_DB_tGradeAliases' refers to an invalid object.
SELECT
aa.CompanyId [LegCompanyId],
aa.ProductId AS [LegGradeId],
aa.GradeAliasId [LegGradeAliasId],
aa.ProductName AS [LobGradeText],
aa.[Alias] [GradeAlias],
aa.PhraseKey [PhraseKey],
GETUTCDATE() AS 'TimeStamp'
FROM syn.Syn_AAA aa
I haven't done any database change/permission change.
How can I overcome this?
I ran following query and it shows the base_object_name correctly linked to my table.
SELECT * FROM sys.synonyms WHERE name = 'Syn_AAA'
I overcame by replacing synonym with [LINKED_SERVER].[DB_NAME].[SCHEMA_NAME].[OBJECT_NAME].

Invalid Object error returned when using SELECT statement

When trying to select from 'jREwardToysRUs.dbo.MailDetail_198' table from jREwardToysRUs DataBase, I am getting the following error:
Invalid object name 'jREwardToysRUs.dbo.MailDetail_198'
Like below :
select top 10 *
from jREwardToysRUs.dbo.MailDetail_198
but giving [], the error is gone.Like:
select top 10 *
from [jREwardToysRUs.dbo.MailDetail_198]
Please suggest. how to remove error while selecting only with table name?
I think you are looking for "use" keyword:
use [jREwardToysRUs]
go
select top 10 *
from [dbo].[MailDetail_198]

Resources