Forum Replies Created

Viewing 15 posts - 61 through 75 (of 78 total)

  • RE: SELECT INTO SQL2K8 from SQL2K

    Be sure on what server and db do you execute "select ... into" query. Also specify schema like "select ... into dbo.MyTable...".

    After that, when you want to query created table...

  • RE: Addition Of Digits

    WoW! When I asked for testing, I didn't think that it will turn into a kind of contest =)

    Here is one more for uint.

    PRINT '========== ??? ========================'

    SET STATISTICS TIME ON;

    DECLARE...

  • RE: Addition Of Digits

    Cadavre,

    Thx for the testing scripts! Especially pointing a bug with replace function (closed as by design).

    I have quite similar results

    ========== SomewhereSomehow ===========================================

    SQL Server Execution Times:

    CPU time...

  • RE: Addition Of Digits

    Cool!!! 4 ways to solve the problem! Definitly all go to my KB.

    CELKO's - is the fastest or isn't it? Who will make a proof test?

    ps

    CELKO,

    Are you a Joe Celko,...

  • RE: Set command to concatteneate strings

    Yes, because it trims all the right spaces. So maybe you should consider to change data type to varchar.

    Good luck!

  • RE: How do I remove nulls from case statements with date fields?

    I could hardly understand your question.

    Could you please provide table structure, sample data, your query as whole, the results you get and the results you want?

  • RE: Update table where there is FOREIGN KEY reference

    You may disable constraint like that

    alter table dbo.T4 nocheck constraint fk_T4_sid

    and do what you want, but, be aware of performance problems. I blogged about it here[/url] (unfortunatelly it is only...

  • RE: How do I to convert varchar datatype to datetime

    CAST and CONVERT (Transact-SQL)

    Is there any problem with that?

  • RE: Set command to concatteneate strings

    gerard-593414 (8/5/2012)


    I am trying to use a variabe to camcattenate a string

    I use following:

    DECLARE @MYVAR Char(1000) = 'INITIAL'

    if Conditon 1

    SET @MYVAR = @MYVAR + ' ABC'

    If Condition 2

    ...

  • RE: Addition Of Digits

    CELKO,

    Good idea, interesting approach! Smth tell's me that it would be also the fastest way of doing this!

  • RE: Addition Of Digits

    XMLSQLNinja,

    Using the same logic. Yor solution will not work if there will be 51 digits.

    Try to understand - my solution was intended to work only with int (and 999 999...

  • RE: Please Help me for Float DataType

    No, you don't need a cursor, you may write it directly in query

    update dbo.tblgas01g4c40

    set DailyConsumption = convert(float,Consumption)/convert(float,FindDiffRead)

    where FindDiffRead<>0

    This will update all the rows in dbo.tblgas01g4c40, by setting to the column...

  • RE: Pivot And Unpivot Table

    When you asking about alternate solution you, do mean funtctional equivalent? you may use case+group by instead of pivot, and cross apply instead of unpivot. You may also check out...

  • RE: Please Help me for Float DataType

    You are trying to devide integer by integer, the result will be also integer.

    To get float you should first convert your arguments to float like this, convert(float,@integer1)/convert(float,@integer2).

    Btw, remember, that float...

  • RE: Addition Of Digits

    Here is my solution

    declare @i int = 985;

    with nums(n) as(select n from (values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10))nums(n))

    select sum(convert(int,substring(convert(varchar(10),@i),n,1)))

    from nums where n <= len(convert(varchar(10),@i))

Viewing 15 posts - 61 through 75 (of 78 total)