SQL Server seems able to infer that an index on X seeked in ascending order will deliver rows ordered by X + Y and no sort is necessary. But it is not able to infer that travelling the index in descending order will deliver rows in the same order as Y-X (or even just unary ...
How to use SQL Hints within CTE/subquery How to use switch statement in Stored procedure in sql server 2005 How to use temporary table in WHERE clause? how to use use coalesce with 0 How to use WITH (NOLOCK) command when querying remote sql server without having linked server how to use...
Can I create a SSIS package to get only row 12 to row 123 from an excel sheet..?? Can I have multiple instances of SSIS on a server? Can I preserve carriage returns in a string variable from ...
If you're the sort of person who can effortlessly write complicated queries in SQL using a single SELECT statement, please click away from this article now! However, if ( like me ) your brain spins in proportion to the complexity of the query you're writing, read on to se...
* FROM tmp.student st JOIN two ON (two.student_id=st.id) WHERE two.level> 1 ; This seems to perform reasonably well, since the CTE-scan avoids the need for two separate subqueries. There is always a reason to misuse recursive queries! (BTW: mysql does not seem to have recursive ...
Write an SQL query to report the id and the salary of the second highest salary from the Employee table. If there is no second highest salary, the query should report null. My dummy data is: Create table If Not Exists Employee (id int, salary int); insert into Emp...
You can also grant these permissions using Transact-SQL Statements, such as: GRANT SELECT ON OBJECT::dbo.Table1 TO Kalyan; GRANT INSERT ON OBJECT::dbo.Table1 TO Kalyan; GRANT UPDATE ON OBJECT::dbo.Table1 TO Kalyan; GRANT DELETE ON OBJECT::dbo.Table1 TO Kalyan; ...
I am trying to write a SQL Server query that looks for duplicate IDs and always returns the Line containing a "Work" Address, but I want it to concatenate the Features from both lines so that I get something like this: ID | Name | AddressType | Address | Feat...
Hey there, I had a look around google for howto do something relatively simple like: INSERT INTO order_side (id) VALUES ('OTHER'),('MARKETSALE'),('MARKETBUY'),('LIMITBUY'),('LIMITSALE'); with npgsql and got into a world of weirdness and ...
If data type of locationID is varchar then: