Forum Replies Created

Viewing 15 posts - 1,666 through 1,680 (of 3,544 total)

  • RE: [HELP] Sum a field of varchar with coma and dot

    My first guess was

    SELECT SUM(CAST(REPLACE(STUFF(a.A,LEN(a.A)-CHARINDEX(',',REVERSE(a.A))+1,1,'.'),',','') as float))

    FROM (SELECT REPLACE(CASE WHEN CHARINDEX('-',A) > 0 THEN '-' ELSE '' END + REPLACE(A,'-',''),'.',',') AS [A] FROM [total]) a

    But

    what does...

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

  • RE: Dynamic Query output into Cursor

    Agree with Vladan

    However the answer to your question is

    Set @Qry='DECLARE mycurs CURSOR FOR SELECT ' + @col1 + ',' + @col2 +...

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

  • RE: using a selected value in join tablename

    Providing you do not exceed 4000 chars try

    DECLARE @sql nvarchar(4000)

    SET @strSQL = ''

    SELECT @sql = @sql + 'SELECT s.ShowID,sd.ContactName,sd.ContactEmail,' + [dataSource] + ' FROM show s INNER JOIN...

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

  • RE: Grouping data

    SELECT MIN([ID]) AS [ID], Value

    FROM

    GROUP BY Value

    ORDER BY Value DESC

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

  • RE: UDF question

    Notwithstanding the above try

    SELECT dbo.fnFindPositionSupervisor((SELECT PositionID FROM Employee WHERE  ID = 5))

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

  • RE: Problem with the ORDER BY and "-" char

    Sorting is affected by collation, e.g.

    Latin1_General_CI_AI is will give the results you posted

    whereas SQL_Latin1_General_CP1_CI_AI will give (I assume) the desired results as in

    select * from @tabla order by field collate SQL_Latin1_General_CP1_CI_AI

     

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

  • RE: Search all fields for a particular character

    quote...because LIKE doesn't work with text data types...

    That is not correct, it will 

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

  • RE: Conditional Linking

    quoteIf you care about performance you must fix database design.

    Always

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

  • quoteIt can, you just have to set up the table styles, and set each column style's visible property...

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

  • RE: Return cols with values

    You could try adding

    AND COALESCE(column,column,column) IS NOT NULL

    to the end of your query.

    Just list the columns you want to check between the brackets.

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

  • RE: Conditional Linking

    Or

    SELECT a., a.field1, COALESCE(b.field1, c.field1)

    FROM [table1] a

    LEFT JOIN [table2] b ON b. = a.

    LEFT JOIN [table2] c ON c. LIKE LEFT(a.,2)+'%' AND c. != a.

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

  • RE: Previous Max Date

    Will not work if there are duplicate tef_bas_tar values

    You will need to include a GROUP BY

    or you could extract the value to a variable

    DECLARE @maxdate datetime

    SELECT @maxdate = x.tef_bas_tar...

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

  • RE: Projection-Forecast used in a query

    You must size the varchar for PolicyNumber

    varchar is the same as varchar(1) one character/byte

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

  • RE: Projection-Forecast used in a query

    Change the datatype of PolicyNumber in the CREATE TABLE

    CREATE TABLE #temp (Period char(6),PolicyNumber int)

     to the datatype of your data

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

  • RE: Identifying foreign characters in rows of data

    quoteWhat is the "Numbers" table?

    It is a generic table of numbers like

    CREATE TABLE dbo.Numbers (Number int PRIMARY KEY...

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

Viewing 15 posts - 1,666 through 1,680 (of 3,544 total)