Forum Replies Created

Viewing 15 posts - 241 through 255 (of 1,124 total)

  • RE: Best Insert Option

    saurabh.dwivedy (5/8/2009)


    Ramesh (5/4/2009)


    Most of the time cursors/loops performs poorly than set based methods with only some rare cases when loops performs better than a set-based approach.

    In your case, one go...

    --Ramesh


  • RE: SQL Query to find minimum of date

    Too much caffeinated today:hehe:

    DECLARE @FromDate DATETIME, @ToDate DATETIME

    DECLARE @FromDateConverted INT, @ToDateConverted INT

    SELECT @FromDate = '2009-04-09',

    @ToDate = '2009-04-10',

    ...

    --Ramesh


  • RE: SQL Query to find minimum of date

    Never mind the newbies...:-D

    DECLARE @FromDate DATETIME, @ToDate DATETIME

    DECLARE @FromDateConverted INT, @ToDateConverted INT

    SELECT @FromDate = '2009-04-09',

    @ToDate = '2009-04-10',

    ...

    --Ramesh


  • RE: saving results of exec(@sql) to a variable

    Madhivanan (5/8/2009)


    Ramesh (5/8/2009)


    It can also be done using sp_executesql system procedure

    declare @DateTime DATETIME

    declare @tablename varchar(100)

    declare @sql nvarchar(4000)

    create table #temp (starttime datetime)

    -- Using sp_executesql

    set @sql = 'select @DateTime = min(starttime) from...

    --Ramesh


  • RE: saving results of exec(@sql) to a variable

    It can also be done using sp_executesql system procedure

    declare @DateTime DATETIME

    declare @tablename varchar(100)

    declare @sql nvarchar(4000)

    create table #temp (starttime datetime)

    -- Using sp_executesql

    set @sql = 'select @DateTime = min(starttime) from ' +...

    --Ramesh


  • RE: SQL Query to find minimum of date

    Good...

    Thanks Flo for the script:-)

    So here is the solution same as Flo's solution except that considers UNIX-EPOCH date formats.

    DECLARE @t TABLE( sl_no INT, Initial_date INT, Log_Time INT, Description VARCHAR(100) )...

    --Ramesh


  • RE: saving results of exec(@sql) to a variable

    Something like this should work:

    declare @DateTime datetime

    declare @tablename varchar(100)

    declare @sql varchar(8000)

    declare @temp table(starttime datetime)

    set @tablename = 'perf270409'

    set @sql = 'select min(starttime) from ' + @tablename

    insert @temp(starttime)

    exec(@sql)

    select @DateTime = starttime...

    --Ramesh


  • RE: SQL Query to find minimum of date

    ansharma (5/8/2009)


    Hi Ramesh

    This should be the output (Please note that teh data is stored in UNIX format i.e int data type :

    sl_noinitial_datelog_timedescription

    2454/9/2009 13:00 ...

    --Ramesh


  • RE: SQL Query to find minimum of date

    You still didn't answered my question?

    Edit:

    I have the solution but it depends on what you answer to my question.

    --Ramesh


  • RE: varchar vs nvarchar - Which is preferred ?

    Its not the experience or the performance factor that decides the usage of data types but the business factors decides. If the business rule requires support for UNICODE (i.e....

    --Ramesh


  • RE: Read from Text file

    Jeff Moden (5/4/2009)


    Ramesh (5/4/2009)


    I would go with SSIS and the following link should get to started

    http://www.sqlis.com/post/Looping-over-files-with-the-Foreach-Loop.aspx

    Not a bad recommendation... I just do it all from T-SQL. I hope to...

    --Ramesh


  • RE: Get all FTP files matching a string

    You just have to use the wild card characters, for e.g. to get all text files that begins with "ord" set the path value to "C:\ord*.txt"

    --Ramesh


  • RE: SQL Query to find minimum of date

    What would be the expected output for the following data?

    401 4/10/2009 23:00 4/10/2009 23:07 This should return null value

    401 4/10/2009 23:00 4/10/2009 23:09 This is a description

    --Ramesh


  • RE: Help needed - How to insert / update / delete mapping table records automatically

    In case if you're inserting multiple rows then you may want to have a look at the OUTPUT Clause in Books Online

    DECLARE @T1Id INT

    CREATE TABLE T1

    (

    Id INT...

    --Ramesh


  • RE: ranking a fields value

    Look up Books Online for Ranking Functions

    --Ramesh


Viewing 15 posts - 241 through 255 (of 1,124 total)