Forum Replies Created

Viewing 15 posts - 18,271 through 18,285 (of 18,923 total)

  • RE: referential integrity for two foreign key based on same primary key

    Tried on my machine too. Looks like ms forbids you to do this as it could become some kind of infinte loop or something like that. Maybe someone...

  • RE: top n percent WITH group by?

    Here's another thaught: the in clause will kill the performance because the whole list will be scanned untill a match is found. Since

    where 1 in (3,1,2)

    is the same...

  • RE: top n percent WITH group by?

    I also thaught of something similar but I didn't pursue it because I wanted a set based approach. This temp table solution would however be much faster than the...

  • RE: Passing parameter to UDF

    try running this... it works for me :

    CREATE FUNCTION [dbo].[ufn_WeekdaysBetween]

    (@StartDate datetime, @EndDate Datetime)

    RETURNS int

    AS

    BEGIN

    DECLARE @Day1 int

    DECLARE @Day2 int

    SET @Day1 = Datepart(dw, @StartDate)

    SET @Day2 = Datepart(dw, @EndDate)

    DECLARE @dSunday...

  • RE: Passing parameter to UDF

    Sorry but we don't see anything here.. can you just post the code and err message?

  • RE: IF Exists stored procedure

    IF EXISTS(SELECT User_ID FROM dbo.User_Information

    WHERE First_Name = @FirstName AND Last_Name = @LastName AND Email_1 = @Email)

    begin

    Select col1, col2... from YourTable

    return 1

    end

    else

    begin

    return 0

    end

  • RE: optimize this query?

    This wouldn't be any faster than PW's solution. The advantage that PW's solution has is that an index can be used on the date because no modification has to...

  • RE: Variable data movement

    Select C.company, E.fname, E.lname, ISNULL(e.Phone, C.phone) as Phone

    from tblCompany C inner join tbkEmployees E on C.id = E.companyidfk

    You just need to apply this technique to the insert/update statement you will...

  • RE: top n percent WITH group by?

    Here's somthing to play with (I wouldn't recommend it on a 8 M lines table though).

    SELECT O.XType

    --, count(*) AS TotalHits_Found

    , O.name

    , (SELECT CEILING(COUNT(*) * 0.9) FROM dbo.SysObjects O4 WHERE...

  • RE: Auto-generate SQL Script for entire DB?

    One way to accomplish this would be to do a backup of A and restore to B.

  • RE: Query test for just date of smalldatetime

    This solution has already been posted, also if you only want the date portion you're still better off using dates than strings as they will compare must faster than varchars.

  • RE: Query test for just date of smalldatetime

    Have you actually run this statement??

    select CAST(dateadd (d, 0, datediff(d, 0, getdate())) AS SMALLDATETIME)

  • RE: Query test for just date of smalldatetime

    I think that my version (well Frank Kalis' version) is prettier and actually will run much faster on larger datasets... it's just a matter of understanding what's actually happening under...

  • RE: Query test for just date of smalldatetime

    Select * from dbo.MyTable where

    dateadd (d, 0, datediff(d, 0, MyDateField))

    =

    CAST(dateadd (d, 0, datediff(d, 0, getdate())) AS SMALLDATETIME)

  • RE: Rows to Columns

    NP.. R U normalizing your tables or just doing the select?

Viewing 15 posts - 18,271 through 18,285 (of 18,923 total)