Bug or feature? The first returns an empty string as expected but the second is null. Is this a bug or feature? SELECT RIGHT('ABC', 0) SELECT RIGHT(CAST('ABC' AS VARCHAR(MAX)), 0) Cheers, Michael ... 3 Apr 2010 18:09
Hash Match best? I just saw 2 conflicting statements in 2 different posts and am confused on whether Hash Matches are good or bad when optimizing. I saw this earlier today: A clustered index scan means the query is looking at every entry in the index. You should try using a WHERE clause to turn that into an index seek inste... 29 Mar 2010 22:32
Subquery or Left Join If you have a Customer table with a column VendorName which could be null, which is better? SELECT CustomerID, CustomerName, VendorName = (SELECT VendorName FROM Vendor WHERE VendorID = Customer... 5 Apr 2010 13:53
records before 6 months Hello everyone, Anyone know how to select records before 6 months? Basically I have a date field and I need to select records older than 6 months from the current date. So today is 03/29/10. I would need all the records BEFORE 10/29/09. Let me know what you guys think. Thanks, Himansu ... 30 Mar 2010 11:39
Join Syntax multiple on I haven't seen this syntax before: RIGHT OUTER JOIN dbo.WORKSPACE WS WITH ON dbo.Security.UserID = WS.CheckoutUserID ON WS.WorkSpaceId = WSEd.WorkSpaceId Is this the same as: RIGHT OUTER JOIN dbo.WORKSPACE WS WITH ON dbo.Security.UserID = WS.CheckoutUserID AND WS.WorkSpaceId = WSEd.WorkSpaceId Where I r... 29 Mar 2010 20:20
Left Join - which table is left If you have the following: USE AdventureWorks; GO SELECT C.ContactID, C.FirstName, C.LastName, SP.SalesPersonID, SP.CommissionPct, SP.SalesYTD, SP.SalesLastYear, SP.Bonus, ST.TerritoryID, ST.Name, ST.[Group], ST.SalesYTD FROM Person.Contact C INNER JOIN Sales.SalesPerson SP ON C.ContactI... 29 Mar 2010 21:27
Assign permissions t user defined functions I'm running a report on SSRS that's based on a sproc - and this sproc uses a sql udf. The report runs fine when run it from the sql server machine, but it fails when I run it from other machines and I'm suspecting that this is because I have not assigned any permissions to the udf. I've assigned the role 'Rep... 29 Mar 2010 15:52
sqlcrl exception We have an sqlclr Stored procedure that invokes a web service. SqlServer sits on on one machine and the web service on another within the same lan. Everything works fine until the web service machine is rebooted - at which point all attempts to use the SP bomb with the exception below until we restart the Sql S... 29 Mar 2010 17:00
why end stored procedures with RAISERROR statement (with error number = 0)? Hi Everybody, A developer submitted T-SQL for a new stored procedure and I'm confused about the last line: CREATE PROCEDURE @SprocThatEndsWithRaiserror (@p1 int) AS BEGIN --numerous statements RAISERROR (@ErrorMsg, 0, 1) WITH NOWAIT END It's not part of any conditional statement, it's simply going to ... 29 Mar 2010 20:20
Not nullable field doesn't get set to default on virtual server Oops. I guess I need to add line-feeds to my text: My database has just been moved from a regular server running SQL Server 2005 to a virtual server running SQL server 2005. I have been getting calls today because integer fields that are set to NOT allow nulls and have a default value of 0 --- defined in the... 30 Mar 2010 10:33 |