Forum Replies Created

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

  • 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...

  • RE: null datetime in union query

    SELECT CAST(NULL as datetime)

  • RE: SQL Query

    You need to use an aggregate function. SUM will be the most efficient although AVG would also work.

    -- *** Test Data ***

    DECLARE @t TABLE

    (

        sampleno int NOT NULL

        ,workcode decimal(18,2) NOT NULL

        ,result...

  • RE: groupby/having not isolating duplicates

    You will need to post sample data and expected results to get any useful help.

    http://www.aspfaq.com/etiquette.asp?id=5006

     

  • RE: groupby/having not isolating duplicates

    Your question and query are extremely confused.

    It looks as though you need to extract FillerOrderID from ReasonText in order to count the number of people associated with each one. This...

  • RE: aggregate function "First" missing in SQL 2005 - workaround?

    If you are not worried about which secondary email to get, then the following will be better:

    SELECT T1.ID_Candidate, T1.MailAddress

    FROM @t T1

    WHERE T1.PrimaryAddress = 1

    UNION ALL

    SELECT T2.ID_Candidate, MIN(T2.MailAddress)

    FROM @t T2

    WHERE NOT...

  • RE: aggregate function "First" missing in SQL 2005 - workaround?

    I am not quite sure what you want but the following may help you:

    -- *** Test Data ***

    DECLARE @t TABLE

    (

        ID_MailAddress int NOT NULL PRIMARY KEY

        ,ID_Candidate int NOT NULL

        ,MailAddress varchar(255) NOT NULL

        ,PrimaryAddress...

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