Forum Replies Created

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

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

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

  • RE: Grouping data

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

    FROM

    GROUP BY Value

    ORDER BY Value DESC

  • RE: UDF question

    Notwithstanding the above try

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

  • 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

     

  • RE: Search all fields for a particular character

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

    That is not correct, it will 

  • RE: Conditional Linking

    quoteIf you care about performance you must fix database design.

    Always

  • quoteIt can, you just have to set up the table styles, and set each column style's visible property...
  • 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.

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

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

  • RE: Projection-Forecast used in a query

    You must size the varchar for PolicyNumber

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

  • 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

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

  • RE: Projection-Forecast used in a query

    Damn   I did say untested

    Replace

    SELECT DISTINCT CONVERT(char(6),DATEADD(year,10,Period),112),PolicyNumber

    with

    SELECT DISTINCT CONVERT(char(6),DATEADD(year,10,EffectiveDate),112),PolicyNumber

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