Forum Replies Created

Viewing 15 posts - 271 through 285 (of 907 total)

  • RE: Case statement in where clause

    Here is an example of a case in the where clause. Not sure if this is what you are looking for:

    create table xxx (regionid int, col1 int, col2 int)

    insert...

    Gregory A. Larsen, MVP

  • RE: Case statement in where clause

    Will this work for you:

    select * from table

    where (regionid>0 and col1 = 1)

    ...

    Gregory A. Larsen, MVP

  • RE: Dymanic database context change

    I see the problem. I think you will either need to you place your common SP in master, or replicate them in all your user db's.

    Gregory Larsen, DBA

    If you...

    Gregory A. Larsen, MVP

  • RE: Need a good Internet Mail Server

    Thanks for the tip on this EMAIL software. Does anyone else recommend a different software package?

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at...

    Gregory A. Larsen, MVP

  • RE: Populate a Table Variable Dynamic SQL results?

    You might try something like this:

    declare @cmd varchar(8000)

    set @cmd = 'declare @table table (l datetime)' + char(13) +

    'insert...

    Gregory A. Larsen, MVP

  • RE: Dymanic database context change

    You need to do something like this:

    declare @cmd nvarchar(4000)

    set @cmd = 'declare @db2 nvarchar(50)' + char(13) +

    'use pubs' + char(13)+...

    Gregory A. Larsen, MVP

  • RE: Need a good Internet Mail Server

    It is my understanding you need a POP3 server to set up SQL Mail even if you are only sending mail. At least that is what I understand via...

    Gregory A. Larsen, MVP

  • RE: Top 20 and sum of the others

    How about something like this:

    select * from (SELECT top 20 [LoginName], sum([CPU]) as SUM_CPU

    FROM [master].[dbo].[proc_use]

    GROUP BY [LoginName]

    order by Sum_cpu DESC

    ) B

    union

    select 'Others' 'LoginName', (select sum([CPU]) FROM [master].[dbo].[proc_use])...

    Gregory A. Larsen, MVP

  • RE: trimming trailing spaces and zeros from a string

    You might try something like this:

    declare @d decimal(10,5)

    set @d = 25.000

    select case when @d = floor(@d) then CAST(floor(@d) AS CHAR) else rtrim(cast(floor(@d) as char)) + '.' + REVERSE(RTRIM(CAST(CAST(floor(reverse(cast(@d as char(10))))AS...

    Gregory A. Larsen, MVP

  • RE: collations

    Here is an article I wrote about changing collation.

    http://www.sqlservercentral.com/columnists/glarsen/collate_part2_1.asp

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • RE: Dynamic SQL With USE

    You can do what you want by building dynamic sql that builds dynamic sql, that then gets executed. Here is an example that issues a USE statement, followed by...

    Gregory A. Larsen, MVP

  • RE: Invalid object name

    Possibly your stored procedures are still in cache. You might try SP_RECOMPILE on all SP. Seems like there is an easy way flush all execution plans from cache,...

    Gregory A. Larsen, MVP

  • RE: backup to compresses disk

    Now there is a acronym "DASD" that I normally don't here people use any more. I do all the time, and people look at me like they don't know...

    Gregory A. Larsen, MVP

  • RE: xp_cmdshell, DIR and remote machine

    Andy, I guess I'm now confused. I know there are two service accounts, one for MSSQLSERVER, and one for SQLSERVERAGENT. Now I always thought if you run JOBs...

    Gregory A. Larsen, MVP

  • RE: Late in the day query help requested

    Winash, would you please explain? For some reason I can't figure out what the three *'s in the following statement means:

    select distinct(F2.machine_id),F1.product_key

    from Forum F1,Forum F2 where

    cast(F2.machine_id as varchar)***'#'***cast(F1.product_key as varchar)...

    Gregory A. Larsen, MVP

Viewing 15 posts - 271 through 285 (of 907 total)