Forum Replies Created

Viewing 15 posts - 4,426 through 4,440 (of 7,597 total)

  • RE: Filter sp_msforeachdb @myvariable

    Most flexible is probably to put the dbs names/LIKE patterns into a temp table and process only names that have a match in that table:

    IF OBJECT_ID('tempdb.dbo.#databases') IS NOT NULL

    ...

  • RE: Query on Using DB Snapshots

    Perry Whittle (2/9/2016)


    ScottPletcher (2/9/2016)


    Perry Whittle (2/9/2016)


    Luis Cazares (2/8/2016)


    DB Snapshots use the database as the main source of data and only store pages that get modified. That means that querying against...

  • RE: Query on Using DB Snapshots

    Perry Whittle (2/9/2016)


    Luis Cazares (2/8/2016)


    DB Snapshots use the database as the main source of data and only store pages that get modified. That means that querying against the snapshot is...

  • RE: Change column smallint to int 300 million records

    Sergiy (2/8/2016)


    Igor Micev (2/5/2016)


    This is not a good thinking. What if you have many schema bound objects with that table?

    The advise from ScottPletcher is just fine. Changing from smallint to...

  • RE: Query on Using DB Snapshots

    Snapshot won't help you, in fact it will very likely make performance worse.

    If you only need to refresh the reporting view once a day, back up the original db and...

  • RE: Building DATETIME from two strings

    Interesting. The code below should work fine. What error are you getting? Are you sure that time is always formatted correctly?

    SELECT CAST(LEFT([Date],8)+' '+Time_on AS datetime)

  • RE: Change column smallint to int 300 million records

    The command to change an existing data type is simple enough to issue:

    ALTER TABLE dbo.table_name ALTER COLUMN <new_data_type> NULL --or "NOT NULL" of course

    --always explicitly specify NULL or NOT NULL,...

  • RE: How do I concatenate Month and Day to get date mm/dd format

    Since using character data tends to slow things down, maybe this:

    SELECT DATEADD(DAY, b.Fiscal_Year_End_Day_Nbr - 1,

    DATEADD(MONTH, b.Fiscal_Year_End_Month_Nbr - 1,

    ...

  • RE: Need to sum up a team's win totals in last 5 games

    Give this query a try: I couldn't test it as I don't have data:

    SELECT team,sum(ats) as W,sum(atsloss) as L,sum(O) as Ov, sum(U) as Un,

    ...

  • RE: Pull string between a certain string and a tab (char(9))

    Here's some sample code, in case it helps:

    DECLARE @text_column varchar(max)

    SET @text_column =

    'I need to pull whatever the string is in a text column that occurs after the word Requestor:...

  • RE: @@ROWCOUNT not working if stored procedure has temp table in it

    If you want a specific value, return it from the proc, don't rely on the "last" statement in the proc yielding the correct @@ROWCOUNT: how is someone later supposed to...

  • RE: How to do CASE WHEN THEN CASE

    Hugo Kornelis (1/30/2016)


    Though you have your answer, I'd like to add that in many cases it is not needed to nest CASE expression. For instance, this should work for you...

  • RE: Datetime conversion

    Since the final date format is "self delimiting", you don't have to add spaces in the result. But I would adjust the code to allow the day to be...

  • RE: Multiple queries in the same stored procedure

    Jeff Moden (1/27/2016)


    ScottPletcher (1/27/2016)


    Jeff Moden (1/26/2016)


    Manic Star (1/26/2016)


    So we had a development. An SQL MVP at days of .Net told our devs that their beloved UberQueries were ok since the...

  • RE: Having my query use less resources.

    I don't have any sample data, so I can't possibly test the code first. If I had data, I would have tested it first.

Viewing 15 posts - 4,426 through 4,440 (of 7,597 total)