Forum Replies Created

Viewing 15 posts - 91 through 105 (of 130 total)

  • RE: CAN we?

    Sean Lange (10/4/2012)


    raghavender.2369 (10/4/2012)


    Thanq for your suggestion, but there is a requirement to store date in 'dd-mm-yyyy' in this format only(use only date datatype, dont use varchar), i googled about...

  • RE: CAN we?

    raghavender.2369 (10/4/2012)


    create table dates(todate date)

    insert into dates values('01-02-1988') (or) insert into dates values('1988-02-01')

    select * from dates

    output:

    01-02-1988

    I want the output in the above mentioned format,

    I assume you want to store date...

  • RE: Seeking alternate method to CTE

    Ignacio A. Salom Rangel (10/4/2012)


    haiao2000 (10/4/2012)


    Jeff Moden (10/4/2012)


    Without a copy of the actual execution plan, it's impossible to tell for sure but I do see one potential problem that guarantees...

  • RE: Seeking alternate method to CTE

    Jeff Moden (10/4/2012)


    Without a copy of the actual execution plan, it's impossible to tell for sure but I do see one potential problem that guarantees and index or table scan...

  • RE: Seeking alternate method to CTE

    Ray M (10/4/2012)


    Trees in sql require a little different modeling and query strategies.

    a quick google search on "Trees in SQL" reveals tons of articles.

    Joe Celko's book on the exact subject...

  • RE: Seeking alternate method to CTE

    ChrisM@home (10/4/2012)


    What are the indexes on thoee tables, specifically mytree? Try running the results of the rCTE into a #temp table and joining the other tables to it.

    Chris,

    There are both...

  • RE: Find sub-tree nodes

    Mark-101232 (10/9/2007)


    Try this

    DECLARE @RootID INT

    SET @RootID=12;

    WITH CTE AS(

    SELECT GroupID,ParentGroupID

    FROM AframeGroup

    WHERE ParentGroupID=@RootID

    UNION ALL

    SELECT a.GroupID,a.ParentGroupID

    FROM AframeGroup a

    INNER JOIN CTE c ON c.GroupID=a.ParentGroupID)

    SELECT GroupID

    FROM CTE

    ORDER BY GroupID

    Eventually I run into performance issue when...

  • RE: Insert from another database

    And if you want to avoid the natural tendency to do some sort of looping to build your dynamic sql you can do something like this.

    select 'insert YourNewTable select' +...

  • RE: Common Table Expression - Is this consider a recursive code being called twice?

    Now I see your point it is a really bad example I have there. My Bad.

    Thanks Guys!

  • RE: Common Table Expression - Is this consider a recursive code being called twice?

    Matt Miller (#4) (10/3/2012)


    haiao2000 (10/3/2012)


    Matt,

    Actually, I know which is base and recursive parts, what I don't know is which part in that entire code triggers the retrival of data. ...

  • RE: Common Table Expression - Is this consider a recursive code being called twice?

    Jeff,

    Maybe that is just a quick bad example I came up with on fly, but what I meant was that table can have data like this:

    parent/child

    1/2

    2/3

    3/4

    1/5...so on and so forth....

  • RE: Common Table Expression - Is this consider a recursive code being called twice?

    Matt Miller (#4) (10/3/2012)


    This is the "base" part of the CTE

    WITH TempCTE AS

    (

    [highlight=#ffff11]SELECT ParentID, ChildID, 0 as Depth

    FROM Table1

    WHERE ParentID=1 [/highlight]

    UNION ALL

    SELECT T1.ParentID,...

  • RE: Insert from another database

    this is code to get columns name from a table,

    SELECT COLUMN_NAME FROM SourceDbName.dbo.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='';

    if you want to do all in sql, them you may have to build sql...

  • RE: Optimize query needed

    Ahh - what I was missing was the actual requirements! 🙂

    This may get you part-way there: http://pratchev.blogspot.com/2008/04/convert-hex-string-to-binary-string.html. You will need to efficiently deal with leading...

  • RE: Optimize query needed

    TheSQLGuru (10/2/2012)


    I am seriously missing something:

    SELECT CAST(5 AS VARBINARY(128)) --0x00000005

    SELECT CAST(0x00000005 AS bigint) --5

    SELECT dbo.ConvertBigIntToVarBinary1(5) --0x010001

    SELECT CAST(0x010001 AS bigint) --65537

    NAH! you aren't missing anything. it was just our requirements written...

Viewing 15 posts - 91 through 105 (of 130 total)