Forum Replies Created

Viewing 15 posts - 46 through 60 (of 334 total)

  • RE: Find date gaps

    Glad I could help. 🙂

  • RE: Find date gaps

    Would something like this get you started?

    create table #temp (

    Row_Ndb int,

    Account_Nbr int,

    Account_Name char(5),

    Account_Desc char(3),

    Begin_Date date,

    End_Date date

    )

    insert into #temp values

    (1, 1, 'test1', 'chk', '1/1/2012', '3/1/2012'),

    (2, 1, 'test1', 'chk', '3/2/2012', '6/30/2012'),

    (3, 1,...

  • RE: Understanding complex SQL scripts

    I generally break the script down into understandable chunks to analyze it and won't post anything to production until I fully understand it. Using the execution plans and client stats...

  • RE: msdb database not REALLY in single user mode?

    Yeah, ok, I'm an idiot without my morning coffee.. forgot to restart the server in single user mode for the system tables.. I'll give that a go and let you...

  • RE: msdb database not REALLY in single user mode?

    Both

    ALTER DATABASE msdb SET SINGLE_USER

    and

    ALTER DATABASE msdb SET SINGLE_USER WITH ROLLBACK IMMEDIATE

    return

    Command(s) completed successfully.

    but any attempt to run the dbcc command still gives me that same error. The...

  • RE: case when then or subquery?

    I think you're making it more complex than it needs to be.. this will give you the customer_ID of everyone who attended.. once you have that list you can use...

  • RE: reason for this???

    Excellent.. thank you folks.. I thought there must be some sort of fundamental flaw in my understanding.. lol

  • RE: reason for this???

    I just don't see the practical application of this foreign key. What benefit does it provide? I'll add that this is a user created database and the user is not...

  • RE: reason for this???

    Ok, Lynn, let me go pull some test data and post it. I can't, for the life of me, think of any reason why someone would build this structure.

  • RE: Group of Groups

    I'm out for the night but this might get you started.. it will get all the text between the first '.' and the last '.'

    NOTE: This is different than the...

  • RE: Help with a query to get substring

    If you're going to have different length numbers on either side of the underscore you can use this.. it's ugly but works.

    declare @textfield varchar(255)

    set @textfield = 'Receiving Batch [1234_456.TRN]'

    SELECT Replace(Substring(@textfield,...

  • RE: index scan

    Your PK and consequently your index is on StudentID + SchoolYear.

    Your where statement only queries half the key so you're still going to get a scan. If you want...

  • RE: sql datatype convertion error??

    Glad to be able to help.

  • RE: Assigning a fieldname with rollup

    It's a hack but you could always do:

    select case when ID is null then 'CountOf' else cast(id as varchar(20)) end as ID, countof

    from

    (

    select id, COUNT(*) as countof

    from

    (values(100001,1),

    (100002,1),

    (100003,1),

    (100004,1),

    (100005,1),

    (100006,1),

    (100007,1),

    (100008,1),

    (100009,1)) as Val...

  • RE: index scan

    As far as I know select * ALWAYS does a scan. You'd have to add WHERE conditions against the indexed columns to get a seek.

Viewing 15 posts - 46 through 60 (of 334 total)