Forum Replies Created

Viewing 15 posts - 601 through 615 (of 897 total)

  • RE: Find first day of a week/month

    You can write a CASE statement and return the greatest among the First Date Of The Month and the First Date Of The Week

    DECLARE@from_date DATETIME

    SET@from_date = '02-Sep-2011'

    SELECTCASE

    WHEN DATEADD( MONTH, DATEDIFF(...

  • RE: How to Delete Right 3 Characters from a string

    Jeff Moden (7/22/2011)


    Sugsy (7/22/2011)


    Just for the record Kingston's suggestion works fine n'all

    Just for the record, it will also delete the wrong data if the right 3 occurs more than once...

  • RE: How to create CHECK CONSTRAINT based on a query?

    hxkresl (6/30/2011)


    In pl/sql it's possible to create a CHECK constraints based on a query of values in another table. Is the same posssible in SQL? My searches on...

  • RE: Divide By Zero Error

    Thanks for the replies folks. I will check the ARITHABORT and the ANSI WARNINGS option along with the connection settings.

  • RE: Divide By Zero Error

    I don't have much idea about the connection settings.

    But i remember in my previous case, a query in a derived table was returning a zero value for a particular column...

  • RE: database trigger

    You can create a single trigger for all three operations( INSERT, UPDATE and DELETE )

    Inside the trigger you will have write programming logic to INSERT values in Status table based...

  • RE: database trigger

    A trigger would be better as that would also help you to track if somebody has inserted, updated or deleted an Order from outside your C# Application.

  • RE: Get Table by name

    barakos (2/14/2011)


    HI.

    I want to ask if there's a way to call a function with the argument "table name" (string),

    and the function will return a variable of type Table?

    Thanks.

    I think...

  • RE: Msg 512, Level 16, State 1, Line 1

    crazekalyan (1/17/2011)


    ThanKs, it worked.

    Did you test if the results are correct? Adding a TOP 1 query would avoid the error but will most probably give you incorrect results. Please provide...

  • RE: Update statement

    This should help you out

    DECLARE @tbl_Table1 TABLE

    (

    Sequence_id INT,

    idINT,

    NameVARCHAR(100),

    [Key]INT,

    item_nameVARCHAR(100),

    rule_idINT

    )

    DECLARE@tbl_Table2 TABLE

    (

    rule_id INT,

    Name VARCHAR(100)

    )

    INSERT INTO @tbl_Table1 VALUES( 1, 6761, 'Includes', 0, NULL, NULL )

    INSERT INTO @tbl_Table1 VALUES( 2, 6761, 'item', 160, 'abc', NULL...

  • RE: get dependent job

    This will give you the desired information

    SELECTJ.name, J.description, JS.step_name, JS.database_name

    FROMmsdb.dbo.sysjobs J

    INNER JOIN msdb.dbo.sysjobsteps JS ON J.job_id = JS.job_id

    WHEREJS.database_name IN ( 'database1', 'database2' ) -- List your databases here

  • RE: Current year and Previous year values in same report

    New Commer (12/28/2010)


    Yes Kingston it does work...

    When i run the code with a date of 15-January-2010, I get the CurrentYearBeginDate as 01-April-2010. Should it not be 01-April-2009?

  • RE: Current year and Previous year values in same report

    New Commer (12/28/2010)


    Abhijeet Chavan (12/28/2010)


    Some changes

    DECLARE @CYBeginDate smalldatetime, @CYEndDate smalldatetime,

    @LYBeginDate smalldatetime, @LYEndDate smalldatetime

    select @CYBeginDate = dateadd(year, datepart(year, getdate()) - 1900, '1900-04-01')

    select @CYEndDate = dateadd(day, -1, dateadd(month, 12, @CYBeginDate))

    select @LYBeginDate...

  • RE: Current year and Previous year values in same report

    New Commer (12/27/2010)


    DECLARE @CYBeginDate VARCHAR(10)

    DECLARE @CYEndDate VARCHAR(10)

    DECLARE @LYBeginDate VARCHAR(10)

    DECLARE @LYEndDate VARCHAR(10)

    DECLARE @CYDate DATETIME

    DECLARE @LYDate DATETIME

    SET @CYDate = GETDATE()

    --Test Data

    SET @CYDate = (Select Case When MONTH(GETDATE()) between...

  • RE: Current year and Previous year values in same report

    New Commer (12/27/2010)


    Sorry i didn't get you.

    Actually the query willo be run at any time and it has to take care by itself to result with the current yr data...

Viewing 15 posts - 601 through 615 (of 897 total)