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
Tag: sql-server-2012
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
SSMS Intellisense is not consistent
I have a problem with my SSMS. For every 5 minutes of interval Intellisense is not working. Is there something wrong with my SSMS software or something wrong with the local server. I won’t say it is …
Bulk insert in SQL Server database from one table to another
I have 200k records in one table and I want to insert these records into another table. I read about the bulk insert but the query I found on msdn website is just not making any sense. This is the query What is f:orderslineitem.tbl and the whole this is just not making any sense. I have a table with four
SQL Server: Replace invalid XML characters from a VARCHAR(MAX) field
I have a VARCHAR(MAX) field which is being interfaced to an external system in XML format. The following errors were thrown by the interface: mywebsite.com-2015-0202.xml:413005: parser error : …
how to set N prefix before sql parameter
i writed a query like this: SELECT [FirstName], [LastName] FROM [WorkersView] WHERE ([FirstName] LIKE ‘%’ + N’علی’ + ‘%’ ) AND ([LastName] LIKE ‘%’ + N’مسروری’ + ‘%’) and it’s work very well! and …
Get previous and next row from rows selected with (WHERE) conditions
For example I have this statement: This statement is splitted by word, like this table: I want to get previous and next word of each word For example I want to get previous and next word of “name”: How could I get this result? Answer you didn’t specify your DBMS, so the following is ANSI SQL: SQLFiddle: http://sqlfiddle.com/#!12/7639e/1
Default row order in SELECT query – SQL Server 2008 vs SQL 2012
Our team recently upgraded our databases from SQL Server 2008 to SQL Server 2012. One breaking change we noticed was in the default order of rows returned by the SELECT statement, i.e. when an explicit ORDER BY clause is not specified. As per MSDN, SQL Server 2012 does not gaurantee the order of the rows returned unless an ORDER BY
CASE Statement for Order By Clause with Multiple Columns and Desc/Asc Sort
Following on from my earlier question here Case statement for Order By clause with Desc/Asc sort I have a statement like this: This works well, but sometimes I need more than column in the order by. I actually need something like this: I can’t work out how to make the CASE statement allow multiple columns in the THEN part. Answer