Forum Replies Created

Viewing 15 posts - 1,276 through 1,290 (of 1,497 total)

  • RE: Merging rows in a table

    This assumes comments will never exceed 8000 characters.

    -- *** Test Data ***

    CREATE TABLE dbo.YourTable

    (

        [Date] datetime NOT NULL

        ,Incident int NOT NULL

        ,Comments varchar(100) NOT NULL

    )

    GO

    INSERT INTO dbo.YourTable

    SELECT '20070228', 1, 'c1' UNION ALL

    SELECT...

  • RE: Update Null values

    As your primary key has some meaning you can get away with something like:

    -- *** Test Data ***

    DECLARE @t TABLE

    (

        Code varchar(5) NOT NULL PRIMARY KEY

        ,Prov varchar(25) NULL

    )

    INSERT INTO @t

    SELECT 'BE31',...

  • RE: Datetime imprecision

    This is all in BOL.

    Smalldatetime is rounded to the nearest minute.

    Milliseconds in datetime are rounded to 0, 3 or 7.

     

  • RE: TSQL Faster Than Stored Procedure?

    Sorry, that exhausts my suggestions.

     

  • RE: TSQL Faster Than Stored Procedure?

    @NetworkId should be varchar(255) to avoid datatype precedence issues.

    Putting order into a view is not a good idea. Try removing the TOP 100 PERCENT and ORDER BY from the view....

  • RE: TSQL Faster Than Stored Procedure?

    What is the datatype of EmailAddress? varchar(100) or nvarchar(100)?

     

  • RE: Using a Function to Determine an Excel Worksheet Source

    You could try something like:

    DECLARE @Query varchar(255)

    SET @Query = 'SELECT * FROM [' + LEFT(DATENAME(month, GETDATE()), 3) + '$]'

    SELECT * FROM OPENQUERY(Charlie_file, @Query)

     

  • RE: getting the list of databases with full recovery model

    Try:

    SELECT [name]

    FROM master.dbo.sysdatabases

    WHERE DATABASEPROPERTYEX([name],'recovery') = 'FULL'

     

  • RE: count problem - ???

    SELECT coursegroup

        ,COUNT(*)  AS NoOfIPTS

    FROM (

            SELECT DISTINCT coursegroup, nnp

            FROM course

        ) D

    GROUP BY coursegroup

  • RE: stored procedure to export data

    Concatenating nunerics to varchars will not work. I suspect all your code like:

    CAST(CRLMTAMT AS numeric(19,2))

    should be like:

    STR(CRLMTAMT, 19, 2)

    It may be better to use the BCP utility.

     

     

  • RE: Need help with a query/procedure

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_NULLS ON

    GO

    -- *** Test Data ***

    CREATE TABLE dbo.Students

    (

        StudentID int NOT NULL

            CONSTRAINT PK_Students PRIMARY KEY

        ,StudentName varchar(20) NOT NULL

    )

    GO

    CREATE TABLE dbo.StudentGrades

    (

        StudentID int NOT NULL

            CONSTRAINT FK_StudentGrades_Students REFERENCES dbo.Students(StudentID)

        ,ExamID...

  • RE: removing single quotes

    DECLARE @Name varchar(20)

    SET @Name = 'O''Shea'

    SELECT @Name

    SET @Name = REPLACE(@Name, '''', ' ')

    SELECT @Name

    -- may want to replace with 146

    SET @Name = 'O''Shea'

    SELECT @Name

    SET @Name = REPLACE(@Name, '''', CHAR(146))

    SELECT @Name

     

  • RE: Help.....This runs so slow

    I do not think the DISTINCT or the IN will help the speed if there are a lot of rows in FTR. The following may work better especially if there...

  • RE: Help rewriting a not in query

    Something like the following gets rid of the NOT IN but introduces the overhead of an OUTER JOIN.

    After checking the same results are produced, you will need to look at the execution...

Viewing 15 posts - 1,276 through 1,290 (of 1,497 total)