Skip to content
Advertisement

Tag: sql-server-2012

SQL select where column begins with Letters

I have a table tbl1 with row of data: I want to query the the Legal_Doc_No of each ID. The value of each ID is either the TIN or the SSS column. How can I query the TIN and SSS column starting with letters (none) so that only values starting with numbers will be assigned to Legal_Doc_No Answer Most databases

Cannot catch SQL Server alter table error

It is a really simple code, but it cannot catch the error. Or how to catch the error? Thanks. Answer Errors that occur as a result of batch recompilation after deferred name resolution cannot be caught at the same level the error occurs. One work-around is to wrap the DDL in dynamic SQL:

A constant expression was encountered in the ORDER BY list

Below is my dynamic query and it’s not working. It threw: A constant expression was encountered in the ORDER BY list, position 2. Original dynamic query: Extracted Query: If I remove second order by line, CASE WHEN ‘ItemDescription’=’ItemDescription’ AND ‘0’= ‘1’ THEN cteForPriceVen.ItemDescription END DESC the query seems working. Answer The second line: Is equivalent to NULL. You can’t order

Advertisement