Forum Replies Created

Viewing 15 posts - 6,346 through 6,360 (of 7,613 total)

  • RE: regarding validations in stored procedure

    SELECT

    @paid =

    CASE WHEN day_of_week = 5 /*Sat*/ THEN CASE WHEN @age <= 10 THEN 300 ELSE 500 END

    ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: How to retrieve two sets of values from one column

    -- one more test data row

    INSERT INTO MyTestTable (ID, Col1) SELECT 4, 'a longer string value1 / a much much much much longer string value2 / whatever / whatever /...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Need Advice in Training . (This is a Repost by the way form a different Section in the Forum)

    Actually I would never have seen this except that it was posted here ... I only check a limited number of threads as I don't have the time for all...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Advice In Training

    Definitely go to a local user group. In particular, get a good mentor to help you learn. With the sheer volume of what you have to learn, a...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Error 21335: [SQL-DMO] The new DB File size must be larger than the current size.

    Great, glad it helped!

    Btw, use DBCC commands such as those above to do file shrinks and other such db maintenance tasks, not the SSMS gui, which can be flaky for...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Differential restore issue - file not found....

    Are you absolutely sure it's file #2? SQL verifies a file before restoring it.

    Check the backup file contents just to be sure:

    RESTORE FILELISTONLY

    FROM DISK = 'F:\For restore\Lss_backup_2013_10_13_000010_4544977\Lss_backup_2013_10_18_000012_9335308.dif'

    Edit: Corrected backup...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: UNION Query help

    T.Ashish (10/17/2013)


    Jeff Moden (10/17/2013)


    ScottPletcher (10/17/2013)


    Or just:

    ORDER BY 1

    I often avoid using the column names at all in UNIONed queries, as the names somehow seem to

    change a lot 🙂 :

    Thank...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: A File Activation Error Occurred. Physical file name may be incorrect.

    Also, you need to review the SQL log from when the error first occurred. Sometimes when errors occur SQL gets stopped and restarted, which causes a log switch. ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: UNION Query help

    Or just:

    ORDER BY 1

    I often avoid using the column names at all in UNIONed queries, as the names somehow seem to

    change a lot 🙂 :

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: How do delete multiple CHAR(9) at end of string

    The CROSS APPLY and SUBSTRING below should do what you need. Let us know if you need some clarification for getting it into an UPDATE statement.

    DECLARE @leading_trailing_chars_to_eliminate varchar(10)

    SET @leading_trailing_chars_to_eliminate...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: datediff producing erroneous result when datetime is between midnight and 1AM

    You'll need to format the hours separately, as below, since style "114" will only handle up to 23 hours:

    SELECT

    CAST(DATEDIFF(ms, ActualStartTime, EndTime) / 3600000 AS varchar(3)) +

    ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: need NULL defined when adding to the table

    I think the code below is a reasonable interpretation, but whether it's correct or not is far from certain:

    ALTER TABLE [Lkup].[ReceiptReasonCodes]

    ADD [IsValidSap] [bit] NULL

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Preventing All Updates and Deletes

    LutzM (10/14/2013)


    ScottPletcher (10/14/2013)


    ...You would have to use a trigger to prevent sa activity....

    Every sa could disable the trigger and still perform updates.

    I should have mentioned that. I was thinking...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Preventing All Updates and Deletes

    You can't directly restrict sa (sysadmin) accounts from any activity in SQL Server. You would have to use a trigger to prevent sa activity.

    For only non-sa, you could try:

    DENY...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: wish to add rows having NULL values as placeholders for "missing" dates

    Use LEFT OUTER JOIN, but don't cast datetimes in any data table to dates to do comparisons; instead, use a range check.

    Here's a sample join for the tables you've described:

    SELECT...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

Viewing 15 posts - 6,346 through 6,360 (of 7,613 total)