Forum Replies Created

Viewing 15 posts - 1 through 15 (of 81 total)

  • RE: A script to answer: Should I use SPARSE?

    SET NOCOUNT ON

    GO

    DROP TABLE #tblHold

    GO

    DECLARE @tblA TABLE (RowId INT IDENTITY(1,1),SchemaName VARCHAR(65),TableName VARCHAR(65),TotalRows BIGINT)

    INSERTINTO @tblA

    SELECTS.[name] AS SchemaName,

    ST.[name] AS TableName,

    SUM(p.[rows]) AS TotalRows

    FROM[sys].[tables] AS ST WITH (NOLOCK)

    INNER JOIN [sys].[schemas] AS S WITH (NOLOCK)

    ONST.[schema_id]...

  • RE: Tables - Filegroups

    select Dataonfilegroup = s.groupname

    from sysfilegroups s, sysindexes i

    where i.id = object_ID('oRDERS')

    and i.indid < 2

    and i.groupid = s.groupid

  • RE: Max() not return max value from table (or we do not know why...)

    USE below to get the desired (Does not matter collation)

    SELECT CASE WHEN BINARY_CHECKSUM('###À#') > BINARY_CHECKSUM('###AÞ') THEN 'Greater' ELSE 'Less' END

    Ram

     

     

  • RE: Please Help

    Try this

    SELECT A.PartnerLeadTypeID,

     A.PartnerID,

     A.LeadTypeID,

     A.isActive,

     A.AllowedStates,

     A.RestrictedStates,

     A.CreditHistory,

     A.LoanAmount,

     A.PropertyValue,

     A.LoanToValue,

     A.PropertyType,

     A.RestrictedCityState,

     A.SoftCap,

     A.HardCap,

     A.HasLender,

     A.HasAgent,

     A.FoundHome,

     A.Bankruptcy,

     A.ProdPostURL,

     B.RowNumber

    FROM dbo.PartnerLeadTypes AS E

     LEFT JOIN (SELECT PartnerLeadTypeID,COUNT(1) AS RowNumber FROM dbo.PartnerLeadTypes GROUP BY PartnerLeadTypeID) AS B

      ON E.PartnerLeadTypeID <= B.PartnerLeadTypeID

    WHERE B.RowNumber BETWEEN 0 AND 10

    -Ram

     

  • RE: check duplicate value on six fields - if exists-not zero

    Midan1-

    Simple way of getting the desired

    DECLARE @demo TABLE (id INT, f1 INT, f2 INT, f3 INT, f4 INT, f5 INT)

    INSERT INTO @demo (id, f1, f2, f3,...

  • RE: using dos commands to check external file sizes

    You may try like this if you know the filename for eg "C:\Text.xls"

    declare @string varchar(50)

    set

    @string =

  • RE: How to filter out read-only databases

    Oops

    Try this

    SELECT  [Name] FROM SysDataBases

    WHERE DatabasePropertyEx([Name],'Updateability') <> 'READ_ONLY'

  • RE: How to filter out read-only databases

    Hi,

    You may try like this

    SELECT  [Name] FROM SysDataBases

    WHERE DatabasePropertyEx([Name],'Updateability') = 'READ_ONLY'

    Ram

  • RE: Alter Index rebuild

    May be you can try this for OnLine..

    USE [DBName]

    GO

    SELECT  OBJECT_NAME(X.[Id])  AS TableName,

     X.[Name]   AS IndexName,

     'DBCC INDEXDEFRAG('+DB_NAME()+','+RTRIM(X.[Id])+','+RTRIM(X.IndId)+')' AS OnLineMaintenance

    FROM SysIndexes AS X

     LEFT JOIN sysobjects SO ON X.[id] = SO.[id]

    WHERE  xtype = 'U'

    AND X.INDID >...

  • RE: Add zero before digit

    Hi

    Try this out

    SELECT RIGHT('0'+DATENAME(MINUTE,GETDATE()),2)

    Ram

  • RE: Determining what indexes that DB tables have in an exiting database.

    Hi

    Just try this query and you get everything you wanted.

    USE Pubs

    GO

     

    SELECT  OBJECT_NAME(X.[Id])  AS TableName,

     X.[Name]   AS IndexName,

     INDEXPROPERTY (X.[Id],X.[Name],'IndexFillFactor') AS IndexFillFactor,

     REPLACE(((CASE WHEN INDEX_COL(OBJECT_NAME(X.[Id]),X.IndId,1) IS NOT NULL THEN ''+INDEX_COL(OBJECT_NAME(X.[Id]),X.IndId,1)+',' ELSE '' END +

     CASE...

  • RE: Parse data for recurring value?

    Hi

    Try this out (No Split/ No Parse)

    DECLARE @col VARCHAR(2000)

    DECLARE @FF VARCHAR(10)

    SELECT @FF = '7104'

    SELECT @col ='7104 7106 7112 7107 7132 7108 7150 7105 7110 7109 7111 7104 7106 7112 7107 7132 7108...

  • RE: Field with autonumeric

    This might help you (SQL Server) 

    DECLARE @tbl TABLE (C VARCHAR(10))

    INSERT INTO @tbl VALUES ('zzz')

    INSERT INTO @tbl VALUES ('abc')

    INSERT INTO @tbl VALUES ('abc')

    INSERT INTO @tbl VALUES ('xxx')

    INSERT INTO @tbl VALUES ('rtt')

    INSERT INTO @tbl...

  • RE: Question on Serach using joins

    Try this out

    SELECT T1.EmployeeId AS EmployeeId,

     COALESCE(T2.EditedInDate,T1.InDate) AS InDate,

     COALESCE(T2.EditedInTime,T1.InTime) AS InTime,

     COALESCE(T2.EditedOutDate,T1.OutDate) AS OutDate,

     COALESCE(T2.EditedOutTime,T1.OutTime) AS OutTime

    FROM Table1 AS T1

     LEFT JOIN Table2 AS T2

      ON T1.EmployeeId = T2.EmployeeId

     

     

  • RE: return 1 row only with union all

    I do not know this is what u r looking for

    SELECT TOP 1 *

    FROM (

     SELECT 'A' AS COL1, 'B' AS COL2 UNION

     SELECT 'AA' AS COL1, 'BB' AS COL2 UNION

     SELECT 'AAA' AS COL1, 'BBB' AS COL2...

Viewing 15 posts - 1 through 15 (of 81 total)