Forum Replies Created

Viewing 15 posts - 16 through 30 (of 89 total)

  • RE: MERGE Insert not working

    This might be because there is no record into the Source.

    IF Object_id('LOAN_GROUP_INFO') IS NULL

    CREATE TABLE LOAN_GROUP_INFO

    (

    LGI_GROUPLVR INT ,LGI_GROUPEXPOSURE INT ,LGI_DATECREATED DATETIMEOFFSET(3),LGI_CREATEDBY INT,LGI_DATEUPDATED DATETIMEOFFSET(3) ,LGI_UPDATEDBY INT ,LGI_ISACTIVE BIT,

    LGI_GROUPID INT

    )

    GO

    IF Object_id('LOAN_GROUPING') IS...

  • RE: More than 1 alphanumeric chars in a string

    DECLARE @tbl TABLE

    (

    ID INT IDENTITY(1,1),

    Char1 NVARCHAR(100)

    )

    INSERT INTO @tbl

    select 'ABC x.yz'

    UNION

    select 'A.BC X.*YZ'

    UNION

    select 'A.BC *X.YZ'

    DECLARE @tblNumber TABLE

    (

    Number INT

    )

    INSERT INTO @tblNumber

    SELECT TOP 1000 ROW_NUMBER() OVER(ORDER BY S.Object_id )

    from sys.objects s,sys.objects s1

    select...

  • RE: query

    Use Master

    GO

    select su.name,p.name from sys.server_principals P

    INNER JOIN sys.server_role_members sr

    On P.principal_id = sr.role_principal_id

    INNER JOIN (Select sr.Name,p.principal_id from sys.syslogins sr INNER JOIN sys.server_principals p

    On P.sid = sr.sid)su

    On sr.member_principal_id...

  • RE: Need urgent help on developing a query

    DECLARE @tbl TABLE

    (

    Col1 NVARCHAR(100),

    Col2 NVARCHAR(100),

    Col3 NVARCHAR(100),

    Col4 NVARCHAR(100),

    Col5 NVARCHAR(100),

    Col6 NVARCHAR(100)

    )

    INSERT INTO @tbl

    SELECT '2013', NULL, NULL, NULL,NULL, NULL UNION

    SELECT 'JED', 'Jan', 'Feb', 'Mar','Apr', 'May'UNION

    SELECT 'WT', '24', '9', '11', '10', '9' UNION

    SELECT 'L/B',...

  • RE: T SQL QUERY TO GROUPING SEQUENTIAL DATES IN SQL SERVER.

    DECLARE @COMP_RATINGS TABLE

    (

    EID INT,

    RATING VARCHAR(20),

    AbsenceStartDate DATETIME,

    AbsenceEndDate DATETIME

    )

    INSERT INTO @COMP_RATINGS VALUES

    (5364914, 'b+', '2011-09-30 00:00:00', '2011-12-31 00:00:00'),

    (5364914, 'bb', '2011-06-30 00:00:00' , '2011-09-30 00:00:00'),

    (5364914, 'bb', '2011-12-31 00:00:00' , '2012-03-31 00:00:00'),

    (5364914, 'bb',...

  • RE: Can I use table s in a where statement to get the expected result set?

    SELECT distinct p.dbPatID,

    p.dbAddDate,

    ISNULL(r.dbStaffLastName, 'No Ref - Staff') AS dbStaffLastName,

    ISNULL(r.RefTypeWord, 'No Ref') AS RefTypeWord

    FROM TEST2RefStaff s, TEST2Patient p

    LEFT OUTER JOIN TEST2ReferralKPIs r ON p.dbPatID = r.dbPatID

    ...

  • RE: previous months data

    with Companyloyalty as (

    select 1 as idloyalty, 1000 as company, 100 as IdClient, '2014-01-12' as loyaltystartdate, null as loyaltyenddate, 10 as cashback union all

    select 2 as idloyalty, 1000 as company,...

  • RE: Pattern Matching for Computer Column

    DECLARE @tbl TABLE

    (

    ID INT IDENTITY(1,1),

    Name VARCHAR(100),

    Name1 AS CASE WHEN Name LIKE '%corporation' THEN SUBSTRING(Name,1,LEN(Name)-11) ELSE Name END

    )

    INSERT INTO @tbl(Name)

    SELECT 'Oracle Corporation'

    UNION

    SELECT 'Union Corporation'

    UNION

    SELECT 'Union Corporate'

    select * from @tbl

    Regards,

    Mitesh Oswal

    +918698619998

  • RE: Need to merge data from two tables

    select COALESCE(t1.date1,t2.date1),

    t1.wsh as wsh,t1.ITN,

    t1.Executions,t2.MCG,t2.Positions

    from #Tbl1 t1 full outer join #Tbl2 t2 on t1.date1 = t2.date1

    Order by 1

    Regards,

    Mitesh Oswal

    +8698619998

  • RE: recursive query

    DROP TABLE #Installments;

    create table #Installments (idno int, payYear int, payMonth int,Payments decimal (10,2))

    insert into #Installments

    select 566232, 2006, 1 ,3568.67 union

    select 566232 ,2006, 2, 3542.76 union

    select 566232, 2006, 3, 3517.03...

  • RE: SQL Function to convert date time to string

    USE Master

    GO

    DECLARE @dt DATETIME

    SELECT @dt = '2014/01/27 01:00 PM'

    select REPLACE(CONVERT(VARCHAR(10),@dt,111),'/','')+CASE WHEN DATEPART(HH,@dt) >= 6 AND DATEPART(HH,@dt) < 18 THEN '1' ELSE '2'...

  • RE: adding more than one aggregation function in dynamic pivot

    IF OBJECT_ID('OrderDetails') IS NOT NULL

    DROP TABLE OrderDetails;

    IF OBJECT_ID('Products') IS NOT NULL

    DROP TABLE Products;

    CREATE TABLE dbo.Products

    (

    ProductID INT PRIMARY KEY,

    Name NVARCHAR(255) NOT NULL UNIQUE

    /* other columns */

    );

    INSERT dbo.Products VALUES

    (1, N'foo'),

    (2, N'bar'),

    (3, N'kin');

    CREATE...

  • RE: change feld value from 0 to 1 in all rows using sql 2005

    Update dbo.Main_Item

    SET Item_type = 0

    where Item_type = 1

  • RE: DATEDIFF Statement help!

    I am using the Date from the getdate and used below where clause to find out the last 7 days data

    DECLARE @dt Date

    SET @dt...

  • RE: T SQL QUERY TO GROUPING SEQUENTIAL DATES IN SQL SERVER.

    DECLARE @COMP_RATINGS TABLE

    (

    EID INT,

    RATING VARCHAR(20),

    AbsenceStartDate DATETIME,

    AbsenceEndDate DATETIME

    )

    INSERT INTO @COMP_RATINGS VALUES

    (769,'BBB','2011-06-30','2011-09-30'),

    (769,'BBB','2011-12-31','2012-03-31'),

    (769,'BBB','2012-03-31','2012-06-30')

    SELECT * FROM

    (

    select C.EID,C.RATING,C.AbsenceStartDate,ISNULL(C1.AbsenceEndDate,C.AbsenceEndDate)AbsenceEndDate from @COMP_RATINGS C

    LEFT JOIN @COMP_RATINGS C1

    On C.EID =C1.EID

    AND C.RATING = C1.RATING

    AND (C.AbsenceStartDate = C1.AbsenceEndDate...

Viewing 15 posts - 16 through 30 (of 89 total)