Forum Replies Created

Viewing 15 posts - 1,876 through 1,890 (of 3,544 total)

  • RE: T-sQL datetime question

    What datatype is YYYYMM and what format/datatype is 'current month'

    Assuming, like Pam, that YYYYMM is char and 'current month' is the same format/type as YYYYMM then

    DECLARE @start char(6)

    SET @start =...

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

  • RE: Help with Derived Tables

    Put all the sql in one sql string and EXEC that

    or

    use a temp table

    CREATE TABLE #temp (col1, col2, col3)

    INSERT INTO #temp (col1, col2, col3)

    SELECT t1.col1, t1.col2, t2.col3 EXEC(@strSQL...

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

  • RE: call extended sp in function

    sp_executesql is not an extended sp it is internal to sql server, extended sp (xp_) are dll's

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

  • RE: Concatenating in select statement?

    quoteWhy did you do an Alias here?

    SQL Server requires sub queries to be aliased, you will get an...

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

  • RE: Optimizing Insert

    Depands on a lot of things (and not sure there is a 'most efficient')

    Is this a one off?

    Single insert or Multiple Inserts?

    Via Procedure?

    Via Trigger?

    One way to derrive the initials is...

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

  • RE: help constructing (what should be) an easy query.

    SELECT THREADS.ThreadID, THREADS.ThreadName, USERS.UserName,

    [a].DateCreated

    FROM USERS INNER JOIN

    (([SELECT THREADS.ThreadID, MAX(POSTS.DateCreated) as DateCreated

    FROM THREADS INNER JOIN POSTS ON THREADS.ThreadID = POSTS.ThreadID

    GROUP BY THREADS.ThreadID]. AS [a]

    INNER JOIN...

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

  • RE: Alphanumeric Primary Key Generator

    Deja Vu

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=235707

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

  • RE: help constructing (what should be) an easy query.

    Not sure it will

    This might

    SELECT t.ThreadID, t.ThreadName, t.ThreadDescription, u.UserName, x.DateEntered

    FROM [THREADS] t

    INNER JOIN (SELECT t2.ThreadID, MAX(p.DateEntered) AS [DateEntered] FROM [THREADS] t2...

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

  • RE: Concatenating in select statement?

    quoteThere must be dosen clues just in this forum for the last week.

    Yep and even longer than that...

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

  • RE: Words in a string

    If single spaced

    SELECT LEN(@anystring) - LEN(REPLACE(@anystring,' ','')) + 1

    (use LTRIM if required to remove leading spaces)

    If the number spaces between the words cannot be guaranteed then use the now famous...

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

  • RE: Cursors? Variable Tables and Temp Tables?

    quoteI'd be tempted to call it a control loop...

    Well it is

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

  • RE: Cursors? Variable Tables and Temp Tables?

    Yep my first thought as well, still RBAR though

    Not sure any faster than CURSOR though

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

  • RE: How to get data in 2 columns from 2 tables

    SELECT MAX(T1),MAX(T2)

    FROM (SELECT t1.T1 AS [T1],null AS [T2],(SELECT COUNT(*) FROM @temp1 a WHERE a.T1 <= t1.T1) AS [ID]

    FROM @temp1 t1

    UNION

    SELECT null AS [T1],t2.T2 AS [T2],(SELECT COUNT(*)...

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

  • RE: Cursors? Variable Tables and Temp Tables?

    quoteQUESTION: How do I return all the records in the QueryTable, together with the associated number of rows...

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

  • RE: Exists syntax using a variable table name

    IF OBJECT_ID(@TableName) IS NOT NULL AND OBJECTPROPERTY(OBJECT_ID(@TableName), N'IsUserTable') = 1

    PRINT 'Table Exists'

    ELSE

    PRINT 'Table Does Not Exist'

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

Viewing 15 posts - 1,876 through 1,890 (of 3,544 total)