Forum Replies Created

Viewing 15 posts - 13,051 through 13,065 (of 13,457 total)

  • RE: Need some help with a select statement

    you want to use the datediff function for this:

    SELECT DATEDIFF(day, somedatecolumn, getdate()) AS no_of_days from sometable

     

    SELECT * from sometable where DATEDIFF(day, somedatecolumn, getdate()) =3 --exactly 3 days old

    SELECT * from...

  • RE: searching for value in the database

     monster searches like this are bad, but sometimes you gotta do it:

    I made an ugly server intensive cursor for a similar question a while back;noone came up with a...

  • RE: script all stored procedures into one file

    you would not need to increase the size of the isql variable; that is just containing the command "sp_helptext your_long_procedure_name" ; i think the max size it could ever be...

  • RE: select UNION

    ahh;

    the subquery in the parenthesis needs an alias:

    this fails: select name from (select name,id from sysobjects union select name,id from syscolumns)

    this works:select name from (select name,id from sysobjects union...

  • RE: select UNION

    because of the sum function, you have to GROUP BY in the outer select: try this syntax:

    select sum(col1),col2 from

    (select col1,col2 from table1 union select col1,col2 from table2)

    GROUP BY COL2

  • RE: Wildcard Searches

    your syntax is incorrect:

    AND (src_terrier.Areacode LIKE @chr_div+ '%')

    so if @chr_div = 'EV', the addition of the % sign makes the wild card search anything that STARTS with 'EV', like 'evansville'...

  • RE: IN or OR

    if the IN statement was running accross a bigger list, like  in(SELECT X FROM SOME TABLE),

    I would expect it should be faster, because it would bailout as true on the...

  • RE: Connecting to an Internet database

    i doubt it; most db servers are hidden behind the firewall at the hosting company, and only the web server can see the db server.

    but that also means that you...

  • RE: Case, loop or cursor

    just missing the END command of the case statement: let me know how this seems to work now

     (CASE WHEN @PropertyValue BETWEEN 1 AND 10

      THEN @PropertyValue * 100000

      WHEN @PropertyValue...

  • RE: Case, loop or cursor

    there are quite a few on this site;

    here is an example using this version of split:

    http://www.sqlservercentral.com/scripts/viewscript.asp?scriptid=225

     

    declare @string        varchar(200),

            @LeadTimeFrame int

    set @LeadTimeFrame=3

    if @LeadTimeFrame = 1       set @string='24'

    else if @LeadTimeFrame =...

  • RE: Case, loop or cursor

    MAYBE another indicator is this: the only difference i see forwhen

     IF (@LeadTimeFrame = 1)

    is evaluated, the SQL is the same except for an additional check in the WHERE...

  • RE: Case, loop or cursor

    i can see a minor improvement; it looks like that huge if-then-else to get the @PriceRange  could be replaced by a three line case statement:

    SET @PriceRange = (CASE...

  • RE: Subversion with SQL SRVR- How to manage SP AND TABLES

    there is a plug in for source safe on this site which keeps all the DDL in source sage for you; you could use that application as far as source...

  • RE: script all stored procedures into one file

    here's another way to get them by using a cursor to enumerate the procs, and simply using sp_helptext:

    declare

     @isql varchar(2000),

     @provname varchar(64)

     

     declare c1 cursor for select name from sysobjects where name not...

  • RE: Want to back up over LAN - how do I get SQL to see network drive?

    the GUI doesn't let you browse to, or paste a UNC path; so to use the GUI, you MUST map a drive; if the problem was a scheduled job, then you...

Viewing 15 posts - 13,051 through 13,065 (of 13,457 total)