Forum Replies Created

Viewing 15 posts - 541 through 555 (of 1,217 total)

  • RE: Distinct DB Name - Table row counts

    I think you should not include sysdatabases. Why would you do it?

    Sysobjects and sysindexes are in each database; that means, your query always works only with tables from the CURRENT database....

  • RE: Strip off year from date field

    That's it, Sergiy... I said right at the beginning that I would know how to do it with CASE, but then started to ponder about your solution that wasn't using...

  • RE: Strip off year from date field

    Hi Murtaza,

    this is how you could do it:

    /*parameters*/

    DECLARE @datefrom DATETIME, @dateto DATETIME

    SET @datefrom=GETDATE()+14

    SET @dateto = GETDATE()+28

    /*query*/

    SELECT Q.memberID,Q.Title,Q.FirstName,Q.LastName,Q.DOB,Q.Email,Q.Country

    FROM

    (SELECT memberID,Title,FirstName,LastName,DOB,Email,Country,

     DATEADD(yy,DATEDIFF(yy,BirthDate,0),BirthDate) as DMOB /*day and month of birth*/

    FROM dbo.members) as Q

    WHERE DMOB...

  • RE: Dynamic Sp creation

    No, ; and GO will not work in dynamic SQL - at least not in SQL Server 2000. The only way is to change database before you start dynamic SQL,...

  • RE: Dates in Queries

    DATEADD and DATEDIFF functions have very good performance, as long as you stick to this way, you should be OK. Performance problems can be sometimes caused by excessive use of...

  • RE: Dynamic Sp creation

    Oh... right, I forgot about that. Well, then no, I don't know how to create procedure in another DB using dynamic SQL - but I wouldn't want to do it anyway. Are...

  • RE: Dynamic Sp creation

    Did you try to include USE command into the dynamic SQL? That should be enough.

    select @sql = 'USE db_name create proc newsp as select 1'

  • RE: select reoccuring values only

    I'm still guessing, but it seems to me that such GROUP BY clause will not work... as I understand it, the only thing that has to be the same in these...

  • RE: Compare two tables

    Or you can use this (I like it more than IN clause and at least sometimes it works a lot quicker - didn't do any extensive testing though):

    SELECT M.ItemCode

    FROM tblMaster M

    LEFT JOIN...

  • RE: select reoccuring values only

    Hmm.. I think it more probable that there was a typo in the first post and no cross join is required. Following query could be how it is now:

    SELECT loi.LOB_ID,...

  • RE: Strip off year from date field

    Actually, this isn't next birthday. It is the birthday for current year, no matter whether it is in future or past.

    I'm not sure whether it is possible to get next...

  • RE: How do you use a variable for the table name in SET IDENTITY_INSERT?

    This looks pretty dangerous... "needs to be applied to many, many tables". In my opinion it should be used sparingly, more as a workaround than as a standard. Are you...

  • RE: Combine 2 queries with different where clause

    1. Do whatever you can to change "localday" column to DATETIME. If INT is required by some application or you can't change it for some other reason, consider creating another column that...

  • RE: HTML in SQL Mail

    Yeah, that could be it... Bhushan, is the computer on which this SP runs configured as mail server? I guess you are launching that on your SQL Server... which probably isn't mailserver...

  • RE: Cursors, cursors, CURSES!!!!

    Jason,

    just in case you don't know - if you click on "Watch This Topic" link at the top of page, you will receive notifications of new posts even if you...

Viewing 15 posts - 541 through 555 (of 1,217 total)