SQL Server Output Clause equivalent in Sybase - sybase

Is there a SQL Server Output clause equivalent in Sybase Version 15? As far as I know there's no Output clause in Sybase which gives the output rows from Update, delete query.

Indeed there is no directly identical statement-level clause. However you can achieve the same effect with a trigger.

Related

SQL server linked server to PostgreSQL query conversion of TOP clause is not converted

I created a SQL linked server to connect to PostgreSQL 11, and issue a query like this
SELECT TOP 1 *
FROM [LinkedServer_PostgreSQL].[DBname].[dbo].[TableName] a;
It is very slow and seems to take forever, I ended up killing the query every time. Upon investigation, I found the query on the PostgreSQL server is selecting all rows, the TOP N row clause on the PostgreSQL is not converted. That's why the query cannot finish, because the table has more than 10 million rows.
As I cannot replace TOP clause using LIMIT clause on SQL server. This really beats me. Help, anyone?

Copy only column header from resultset in microsoft sql server management studio

I want to copy only 'Column Headers' from the result set in Microsoft Sql Server Management Studio but I didn't find any option. Same option is there is Oracle SQL server management. I googled about it but didn't find any thing that would help me so wanted to check if there a way to do this
Run your query without any result-set using
select * from tablename where 1=2
then use "Copy with Header".This is the only way to copy only columns header.
Instead of result into grid please use Result to text. Result to Text - Ctrl+3
Hope this helps.
No straight method as far as I know. One method is to output the result to text and copy only the header. Another trick is to execute the query without returning any results to grid by applying a false predicate like SELECT column_list FROM yourtable WHERE 1 = 2; then, use 'Copy with Headers' option.
Use SET FMTONLY ON before execute query .
It,s used to test the format of the response without actually running the query.
Choose results to grid and choose copy with headers option .
mark the table name and run alt+F1.
than you can copy directly from the cells of the Column_name table
SSMSBoost appears to have this as a feature. It is an addon for SQL Server Management Studio but the Pro edition (which you need for this feature) will cost you US$195.
(I am not affiliated with this product)

Azure SQL server IN statement not throwing error

When I write a sql statement containing an in clause, if the column in the in statement does not exist it does not throw an error, but just ignores the in statement and returns a resultset.
Query below will return all rows from T1
SELECT * FROM T1 WHERE Id IN(SELECT Id FROM T2)
Is that the correct behaviour for SQL Azure?
My local MS SQL server throws an error saying the column does not exist.
Frankly, what you are describing is impossible. If the column inside the IN statement doesn't exist, Azure will throw an exception. A result set cannot possibly be returned. Currently there is very little difference between the way SQL Server executes a query and the way Azure v12 does. Each may generate a different execution plan, but essentially there is very little difference between the two.
This is expected behavior, same as in Sql Server. Basically, if a column is referenced in a subquery that does not exist in the table referenced by the subquery's FROM clause, but exists in a table referenced by the outer query's FROM clause, the query executes without error. SQL Server implicitly qualifies the column in the subquery with the table name in the outer query.
This is documented here:
https://technet.microsoft.com/en-us/library/ms178050(v=sql.105).aspx

Doing a linguistic sort in SQL Server 2008

In Oracle, in order to do a linguistic sort, suppose with arabic characters, I use following :
ALTER SESSION SET nls_sort='arabic'
How can I achieve linguistic sorting in SQL Server 2008 ?
SQL Server has the concept of collations which affect ordering and comparison operations.
If your data is configured using a different collation to the one you require, you can force a specific one to sort by in your ORDER BY statement like this:
SELECT *
FROM Table
ORDER BY TextColumn COLLATE Arabic_CI_AS

Insert Date Field to MS SQL from Proc SQL

I'd like to insert a date field into a SQL server table form Proc SQL in SAS. Here is my code for Proc SQL:
proc sql;
insert into CFS_SQL.Data_DSB_Raw(sasdatefmt=(TheDate='mmddyy10.'))
select TheDateIncoming
from Work.Upload;
quit;
According to the SAS help documentation (http://support.sas.com/kb/6/450.html), this should work as long as TheDateIncoming also has format mmddyy10.. I've verified that the format on TheDateIncoming is correct, so I think this should work.
Unfortunately, however, I'm getting a "Value 1 on the SELECT clause does not match the data type of the corresponding column" error.
Any thoughts?
Annnnnd... solved. It actually had nothing to do with the code. It was a driver problem. Switching to the SQL Server Native Client 11.0 ODBC driver fixed the issue.

Resources