Forum Replies Created

Viewing 15 posts - 2,536 through 2,550 (of 3,543 total)

  • RE: Recursive query for heirarchy

    Try this

    BEGIN

     DECLARE @SplitID int

     SET @SplitID = 1035

     SET NOCOUNT ON

     SET DATEFORMAT dmy

     DECLARE @DealTree table (

      DealID int

      , ParentID int

      , lvl varchar(50))

     

     DECLARE @Temp table...

  • RE: Linked Queries Issue

    If there are only two workshops then

    SELECT q2.Location, q2.Product, q2.Workshop,

    (CASE WHEN q2.WorkShop = 'Work1'

      THEN (CASE WHEN q1.Unshipped_Qty > q2.TotalQTYAvailable

        THEN 0 ELSE q2.TotalQTYAvailable - q1.Unshipped_Qty END)...

  • RE: Retrieving first 100 chars from a column of type text

    cannot use LEFT with text data type

  • RE: saveas(backup restore) question!

    For SQL2K try

    declare @rc int,@dir nvarchar(4000)

    exec @rc = master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE',N'Software\Microsoft\MSSQLServer\MSSQLServer',N'DefaultData', @dir output, 'no_output'

    select @dir

    declare @rc int,@dir nvarchar(4000)

    exec @rc = master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE',N'Software\Microsoft\MSSQLServer\MSSQLServer',N'DefaultLog', @dir output, 'no_output'

    select @dir...

  • RE: Query trouble

    SELECT i.WgtGrp, i.ItemNo, i.Description, i.RegDate, i.Weight

    FROM ITEM2 i

    INNER JOIN (

    SELECT WgtGrp, ItemNo, MIN('2004/09/18 11:15:00' - RegDate) AS [Diff]

    FROM ITEM2

    GROUP  BY WgtGrp, ItemNo) x

    ON x.WgtGrp...

  • RE: divide by zero error

    Phil's query will give errors, I think this what he meant.

    SELECT

    QNumber, Bulletin, Issue, Locale, Installed, Applicable,

    Installed + Applicable as Total

    from ( select QNumbers0 as QNumber

    , ID0 as Bulletin

    ,...

  • RE: Union Views

    Seems like a presentation problem more than a sql one but you are right the union output has to have the same dataype, so your best bet it to use...

  • RE: print stored procedure result data into text file

    This sort of question pops up now and again. Whilst the solutions presented will work and possibly satisfy most needs it got me thinking. ...

  • RE: Messages in Query Analyzer

    SET NOCOUNT ON

    will stop the rows affected message

  • RE: Simple SQL using IN

    The following will anser you last question

    WHILE CHARINDEX(',',@Section) > 0

    BEGIN

    insert into [TBLCONTACT_TO_TBLSECTION] puTBLCONTACT, puTBLTOP)

     values (@ContactID, LEFT(@Section,CHARINDEX(',',@Section)-1)

    SET @Section = SUBSTRING(@Section,CHARINDEX(',',@Section)+1,LEN(@Section))

    END

    insert into [TBLCONTACT_TO_TBLSECTION] puTBLCONTACT, puTBLTOP)

     values...

  • RE: Simple SQL using IN

    You could use this in the where clause

    CHARINDEX(',' + CAST(@LearnID as varchar) + ',',',' + puTOP_SECTIONID) + ',') > 0

    but you will sacrifice performance

  • RE: Extract IP Address from text field

    Try this for a laugh

    SELECT COALESCE(

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9]%',[column]),15),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9]%',[column]),14),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9]%',[column]),13),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9].[0-9][0-9][0-9]%',[column]),14),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9].[0-9][0-9]%',[column]),13),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9].[0-9]%',[column]),12),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9].[0-9][0-9][0-9]%',[column]),13),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9].[0-9][0-9]%',[column]),12),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9].[0-9]%',[column]),11),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9]%',[column]),14),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9].[0-9][0-9][0-9].[0-9][0-9]%',[column]),13),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9].[0-9][0-9][0-9].[0-9]%',[column]),12),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9].[0-9][0-9].[0-9][0-9][0-9]%',[column]),13),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9].[0-9][0-9].[0-9][0-9]%',[column]),12),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9].[0-9][0-9].[0-9]%',[column]),11),

      SUBSTRING([column],PATINDEX('%[0-9][0-9][0-9].[0-9][0-9].[0-9].[0-9][0-9][0-9]%',[column]),12),

     ...

  • RE: T-SQL issue?? or do I have to UDF

    If you want to have both sets of data in the same row then you have to join the table to itself.

    Performance will depend of several factors.

    Correct Indexing

    Dates having no...

  • RE: Query Reg. Fetching Monthname

    DECLARE @monthnumber int

    SET @monthnumber = 9

    SELECT DATENAME(month,DATEADD(month,@monthnumber - 1,0))

Viewing 15 posts - 2,536 through 2,550 (of 3,543 total)