Forum Replies Created

Viewing 15 posts - 4,861 through 4,875 (of 10,144 total)

  • RE: Get week ending date given the week number

    FollowingSaturday = DATEADD(day,6-DATEDIFF(day,6,Today)%7,Today)

    -- example

    ;WITH ATableOfDates AS (

    SELECT TOP(300)

    Today = DATEADD(DAY,ROW_NUMBER() OVER(ORDER BY (SELECT NULL))-150,CAST(GETDATE() AS DATE))

    FROM sys.columns

    )

    SELECT

    Today,

    [DayOfWeek] = DATENAME(weekday,Today),

    FollowingSaturday = DATEADD(day,6-DATEDIFF(day,6,Today)%7,Today)

    FROM ATableOfDates

  • RE: T-SQL Variable vs String Equivalent

    If you examine the two plans in the first post of this thread, the first one – for the query with a constant predicate – has been considered for simple...

  • RE: Slows system performance

    Krishna1 (4/10/2013)


    thanks. I will check the perfromace and the size of log after adding the checkpoint

    How do u write it,

    Begin tran

    Commit tran

    checkpoint

    if i have 2 begin tran / commot tran...

  • RE: Query - Nested Loop Join

    sqldba_newbie (4/9/2013)


    In below query , in the exec plan i see nested loop join on TBFE table. This is executed for 25,000 times. I could force a hash join there...

  • RE: Please tell me how can I write one query to resolve this problem.

    Hi Liam, welcome aboard. Before you start, have a read of this article[/url]. It describes how to post a question and what to include with it, to increase your chances...

  • RE: Inserting into an auto increment PK field

    Have a look at IDENTITY_INSERT in Books Online.

  • RE: Which of the two queries is better ???

    T.Ashish (4/4/2013)


    Hi All,

    I have attached two queries with table definition and sample data.

    Query 2 is working better then query 1.

    Now the actual question is:

    Should I...

  • RE: Slows system performance

    Two key points - don't shrink after load, it will only cost you next time around; and checkpoint after each COMMIT to clear completed transactions from the log.

    Grant Fritchey has...

  • RE: split single row into four rows.

    abhas (4/9/2013)


    Thank you Chris.

    I found below code some where else which is resemble to my requirement. Now i want to insert whole result set into my database table. 🙂

    DECLARE...

  • RE: SQL /Procedure - for Transpose and Calculation

    sudhirnune (4/9/2013)


    Thanks all for helping on this: below is procedure which does the Trick

    Create procedure USP_TEST

    @NAME NVARCHAR(20)

    AS

    BEGIN

    IF object_id(N'tempdb..##TEMP_TEST') is not null

    DROP table ##TEMP_TEST;

    DECLARE @cols AS NVARCHAR(MAX),

    ...

  • RE: Slows system performance

    Which recovery model is your db set to?

  • RE: split single row into four rows.

    This might help:

    IF object_id('TempDB..#Temp') IS NOT NULL

    DROP TABLE #Temp

    CREATE TABLE #Temp (DateTimeRow DATETIME)

    DECLARE @STARTDATE DATETIME, @StartTimeChar CHAR(5), @EndTimeChar CHAR(5);

    SELECT

    @STARTDATE = CAST(GETDATE() AS DATE),

    @StartTimeChar = '08:00', -- note left-padded digit...

  • RE: SQL /Procedure - for Transpose and Calculation

    sudhirnune (4/9/2013)


    I will try to Explain you the Scenario and need Suggestion:

    1. I have te table which is Similar to TEST_SRC for which will tipically has 4000 to 5000 Payment...

  • RE: split single row into four rows.

    abhas (4/9/2013)


    Hi,

    Still facing an issue while inserting records. I have created Tally table with N. If i use select by applying join then data is showing properly but while inserting...

  • RE: SQL /Procedure - for Transpose and Calculation

    sudhirnune (4/9/2013)


    yes and might increase at any point of time.

    So to summarise, you want to take three or four very simple queries and convert them into a series of statements...

Viewing 15 posts - 4,861 through 4,875 (of 10,144 total)