Forum Replies Created

Viewing 15 posts - 256 through 270 (of 430 total)

  • RE: Grouping and suming on a specific number of rows

    Little better

    DECLARE @aa INT   SET @aa = 2

    SELECT Funds, Subscriber, SUM(Amount) FROM #tblTempRetros A

    WHERE

     @aa  > (SELECT COUNT(DISTINCT DateMonthEnd)

      FROM

       #tblTempRetros B

      WHERE

       B.DateMonthEnd > A.DateMonthEnd)

    GROUP BY Funds, Subscriber

    I should have taken my time. I didn't...

    Regards,
    gova

  • RE: Grouping and suming on a specific number of rows

    DECLARE @aa INT   SET @aa = 3

    SELECT Funds, Subscriber, SUM(Amount)

    FROM

     #tblTempRetros MyTable

    JOIN

     (SELECT DISTINCT DateMonthEnd FROM #tblTempRetros A

    WHERE

     @aa - 1 = (SELECT COUNT(DISTINCT DateMonthEnd)

      FROM

       #tblTempRetros B

      WHERE

       B.DateMonthEnd > A.DateMonthEnd)) MyDate

    ON

     MyTable.DateMonthEnd >= MyDate.DateMonthEnd

    GROUP BY Funds, Subscriber

     

    Regards,
    gova

  • RE: Bulk Copy from a text File to Table

    sp_help tablename

    will list all table properties including index details. Creating an index will not help you in this problem unless you have a data in datafile which can be in...

    Regards,
    gova

  • RE: Bulk Copy from a text File to Table

    If the table has a clusterd index the order will change as expected. If there is no index then we can never predict the order of storage.

    Regards,
    gova

  • RE: Bulk Copy from a text File to Table

    I am not sure whether it would be possible to retain the order with bcp itself.

    The workaround is edit the data file by appending row number with the help of...

    Regards,
    gova

  • RE: Casting a CHAR to an INT

    There may be rows with nonumeric values in the column in question.

    check

    SELECT SCRCTG, * FROM tblIntelecDownload

    WHERE

     ISNUMERIC(SCRCTG) = 0

     

    Good idea Remi

    Regards,
    gova

  • RE: Pass table name to stored procedure2

    I don't get it if you don't know the server names you cannot have it as linked server. So ServerName.DataBaseName.dbo.ObjectName will not work.

    You should be knowing the database names in...

    Regards,
    gova

  • RE: delete all constraints for a table

    You can get constraint names from sysreferences, sysindexes, sysconstraints table.

    Easy way is use sp_help tablename. All constraints will be listed. Then use ALTER TABLE  DROP CONSTRAINT to drop them.

    or...

    Regards,
    gova

  • RE: delete all constraints for a table

    Check ALTER TABLE in bol.

    BEGIN TRANSACTION

    ALTER TABLE dbo.[Primary]

     DROP CONSTRAINT PK_Primary

    GO

    COMMIT

    BEGIN TRANSACTION

    ALTER TABLE dbo.[Foreign]

     DROP CONSTRAINT FK_Foreign_Primary

    GO

    COMMIT

    It is not possible to drop all constraints in a single statement.

    Regards,
    gova

  • RE: Is this Possible?

    1. You cannaot refer to a temptable in tempdb by prefixing tempdb.dbo. (If you check tempdb sysobjects you will see #table name will be different like #tablename_________12121)

    2. To get fixed...

    Regards,
    gova

  • RE: ''''SET IDENTITY_INSERT '''' + @TablesName + '''' ON'''' dosn''''n work

    As Michael pointed it is outf scope. Your dynamic statements will have a seperate scope that the connection you are in.

    if you want to do it Dynamic do it thsi...

    Regards,
    gova

  • RE: Convert various dates to 2 INT columns

    More possible formats

    DECLARE @Month TABLE (MonthVal VARCHAR(10))

    INSERT @Month VALUES ('MM')

    INSERT @Month VALUES ('M')

    INSERT @Month VALUES ('Mon')

    INSERT @Month VALUES ('Month')

    DECLARE @Year TABLE (YearVal VARCHAR(10))

    INSERT @Year VALUES ('YYYY')

    INSERT @Year VALUES ('YY')

    INSERT...

    Regards,
    gova

  • RE: Set a value based on a return value from another SP

    You cannot use SP there. Create a function which returns the value and use it in the View.

    If you have SQL Server 7.0 or less you convert your view into...

    Regards,
    gova

  • RE: Create Table from a variable

    DECLARE @sql VARCHAR(2000)

    SELECT @sql = 'CREATE TABLE ' + @FileName + '(Phone VARCHAR(10) )'

    EXEC(@SQL)

    Thanks AJ Ahrens I did not take the question.

    Regards,
    gova

  • RE: Create Table from a variable

    That is because you already declared @FileName as VARCHAR(20). Change the name of any one of this you will be okay.

    Regards,
    gova

Viewing 15 posts - 256 through 270 (of 430 total)