Forum Replies Created

Viewing 15 posts - 1,366 through 1,380 (of 1,417 total)

  • RE: Problem with stored procedure

    You will have to provide more information.

    Your query will not run as Col1 is ambiguous.

    Why do you left join when the join to #temp will take out any nulls in...

  • RE: Help with a simple Function

    You probably have a null in either LastName or Firstname. ( null + 'Anything' = null)

    There is no need for a function as something like the following should work:

    SELECT LastName

     ,FirstName

     ,CASE WHEN...

  • RE: Need help with a query statement

    There is no need for an outer join here:

    SELECT T.*

    FROM dbo.Ticket T

     JOIN dbo.Audit A ON T.ticket_id = A.ticket_id

     JOIN ( SELECT A1.ticket_id, MAX(A1.last_updated_date) AS last_updated_date

      FROM dbo.Audit A1

      GROUP BY A1.ticket_id) D

     -- filter audit...

  • RE: prevent a delete - cross-database

    >> I want to ask what type of sp can be used

    You do not allow your users delete access to the table and force them to use a...

  • RE: How to tell if a character exists

    select *

    from YourTable

    where ShipToNum not like '%[^0-9]%'

  • RE: prevent a delete - cross-database

    There are no BEFORE Triggers so you have to use an INSTEAD OF trigger or a SP.

     

  • RE: Other Ways to Exclude Values

    Just noticed that you do not want AcctCode in addition to 'Payment Servi'.

    This may work:

    -- Do not have enough info to tell if distinct is needed

    select distinct PR.PrmLog_Acct_Code, PR.PrmLog_Customer_ID

    from dbo.PrmrLog...

  • RE: Other Ways to Exclude Values

    A quick perusal of your code suggests that the following may work.

    -- Do not have enough info to tell if distinct is needed

    select distinct PR.PrmLog_Acct_Code, PR.PrmLog_Customer_ID

    from dbo.PrmrLog PR

    where exists (select...

  • RE: T_SQL

    Replace @test-2 with [Description] as above.

    ps If you do need local variables, do not declare them in the parameter list.

    pps If possible, normalize the database.

  • RE: T_SQL

    If the position of the !'s is not fixed use the following, otherwise hardcode in the numbers.

    ALTER PROCEDURE dbo.spGetInks

    (@Company varchar(50), @Site varchar(50), @Zone varchar(50))

    AS

    SET NOCOUNT ON

    SELECT D.[Name]

     ,D.[Description]

     ,RTRIM(SUBSTRING(D.[Description], D.P1 + 1, D.P2...

  • RE: T-SQL against Sybase Database?

    Sybase uses a different dialect of T-SQL. There is some documentation at:

    http://manuals.sybase.com/onlinebooks/group-as/asg1250e/sqlug

     

     

  • RE: SQL Query Latest Tracking details

    I think you need to force the join order with something like:

    select T1.[Name], T1.tracking_number, T2.start_date, T3.first_name, T3.last_name

    from Table1 T1

     left join

     (

      Table2 T2

      join

      ( select T22.tracking_number, max(T22.start_date) as start_date

       from Table2 T22

       group by T22.tracking_number) D

      on...

  • RE: Pivot/Rotate Table

    I think this would be best done either in the middle tier or by using a cursor.

    If you have less than 1000 rows something like the following ghastly looking query...

  • RE: Unable to make this query run.. trying to build query by concatenating strings

    Try sp_executesql with output parameters. Something like:

    declare @EmployeeNo int, @AccessLevelID int, @err int

    set @queryString = 'select @EmployeeNo = b.employee_no, @AccessLevelID = a.Access_Seq from '

      + @dbName + '..employee a, '...

  • RE: TSQL PRoblm

    -- Test data

    declare @t table

    (

     refNo char(5) not null primary key

    )

    insert @t

    select 'ABC-0' union all

    select 'ABC-1' union all

    select 'XYZ-0' union all

    select 'XYZ-1' union all

    select 'XYZ-2' union all

    select 'PQR-0' union all

    select 'MNO-0'...

Viewing 15 posts - 1,366 through 1,380 (of 1,417 total)