Forum Replies Created

Viewing 15 posts - 1,861 through 1,875 (of 3,544 total)

  • RE: looking for images

    This is because one of the CHARINDEX is returning 0 (string not found) and being subtracted from resulting in a negative number for length to a substring, hence the error.

    What...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Help with report-like sproc thing

    Deleted answer, thought I had it but

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Use trigger or not?

    Unless I missed something here

    quoteThe column has a bit data type

    Therefore can only be null,0 ro 1

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: looking for images

    SUBSTRING(col1,CHARINDEX('src="',col1,CHARINDEX('<IMG',col1))+5,

     CHARINDEX('"',col1,CHARINDEX('src="',col1,CHARINDEX('<IMG',col1))+5)-

     CHARINDEX('src="',col1,CHARINDEX('<IMG',col1))-5)

    providing the filename is always ecapsulated by double-quotes

     

    Far away is close at hand in the images of elsewhere.
    Anon.

  • quoteDang... missed that one, David... nice catch.

    Thanks Jeff

    But it is...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: sql substring

    STUFF(STUFF(comment,CHARINDEX('Seam:',comment)+5,0,REPLICATE('0',8-(CHARINDEX('Roll:',comment)-CHARINDEX('Seam:',comment)))),8,0,REPLICATE('0',13-CHARINDEX('Seam:',comment)))

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: sql substring

    What values do you want from your example, eg to get the Bar Codes

    STUFF(comment,1,CHARINDEX('Bar Code:',comment)+8,'')

     

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Requesting help creating ''''by month'''' summary query

    Requirement is to show missing months as well 

    DECLARE @from datetime, @diff int

    SELECT @from = DATEADD(month,DATEDIFF(month,0,MIN([Date])),0),

    @diff = DATEDIFF(month,MIN([Date]),MAX([Date]))

    FROM @Table

    SELECT STUFF(CAST(d.[Date] as...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: How to assign a value to a variable when using an Execute statement to run query

    Yes it can have any number of input and output paramters

    EXECUTE sp_executesql @strSQL, N'@x int OUTPUT,@y int OUTPUT', @x OUTPUT, @y OUTPUT

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Need to find the number of rows in every table in a DB

    You can use an undocumented procedure

    sp_msforeachtable 'SELECT ''?'',COUNT(*) FROM ?'

    also you could create a temp table and insert the results to it

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: How to assign a value to a variable when using an Execute statement to run query

    use sp_executesql instead

    DECLARE @x INT

    DECLARE @strSQL VARCHAR (2000)

    DECLARE @dbname VARCHAR (50)

    SET @dbname = 'A40001_1'

    SET @strSQL = 'SELECT @x = MAX(Key_ID) FROM ' + @dbname + '.dbo.TableABC'...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: How do I use dynamic SQL in Cursor declaration

    Agree with Vladan

    But if you must do this using a cursor then

    DECLARE @sql nvarchar(4000)

    SET @sql = 'DECLARE c CURSOR FOR SELECT...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Help with Derived Tables

    SET @strSQL1 = 'SELECT t1.col1, t1.col2, t2.col3 FROM mytable t2 INNER JOIN  ('

    SET @strSQL2 = 'SELECT col1 AS col1, col2 AS col2'

    SET @strSQL3 = ''

    ...code here to add...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: Help with Derived Tables

    You can EXEC more than 8000 chars by supplying more than one variable, eg

    EXEC(sql1 + sql2 + sql3)

    Why SLECT INTO ?

    And why inside the EXEC ?

    I just converted your...

    Far away is close at hand in the images of elsewhere.
    Anon.

  • RE: self-join question

    DECLARE @start datetime, @end datetime

    SET @start = DATEADD(month,DATEDIFF(month,0,GETDATE()),0)

    SET @end = DATEADD(month,1,@start)

    SELECT creative,COUNT(DISTINCT sessionid)

    FROM [pagehits]

    WHERE adate >= @start and adate < @end

    GROUP BY creative

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 15 posts - 1,861 through 1,875 (of 3,544 total)