Forum Replies Created

Viewing 15 posts - 16 through 30 (of 82 total)

  • RE: list user sprocs that contain a certain word

    .......

    
    
    declare @criteria varchar(500)
    set @Criteria = 'product'

    select distinct name
    -- optional text excerpt:
    /*,replace('... ' + substring(text, (patindex('%' + @Criteria + '%',text) - 55), 155)
    + ' ...', ...
  • RE: Stored procedure help needed.

    Unless I misunderstand, wouldn't something like this be what your after:

     
    
    select
    CategoryID,
    Count(*) as [Count]
    from TableName
    group...
  • RE: Update Row with Combination of Values

    ok... Not finished yet

    How about the following.

    If I am still oversimplifying things, then I appologise, and I will get back to my own work!!!

    (Shame all the...

  • RE: Update Row with Combination of Values

    Is this the kind of thing you are after?

    create table #temp (name varchar(50), Code varchar(50), CodeDesc varchar(50), Jan int,Feb int)

    set nocount on

    insert into #temp values ('JohnGinglehim', '45','Sick', 16, 0)

    insert...

  • RE: Function with variable table and column name

    I don't think your going to be able to easily do this in a function. It can be done quite easily in an SP:

    create proc Max

    @T varchar(255),

    @C...

  • RE: Listing Columns names in a tabel Query

    Try having a look at the INFORMATION_SCHEMA. Views in SQL Books Online.

    eg:

    select * from INFORMATION_SCHEMA.Columns where Table_Name = "TableName"

  • RE: an ugly way of counting

    No Worries

  • RE: an ugly way of counting

    Suggestion:

    select count(*) from

    (

    select 1 as Num

    from dbo.tbl_DocumentDownloads DD

    where ......

    group by

    DD.fk_intDocumentID,

    DD.fk_intUserID

    )as A

  • RE: Name of table memorized into a variable

    Ahh, sp_pkeys, have to remember that one!

    beats my method!! =:)

  • RE: Name of table memorized into a variable

    Try looking at INFORMATION_SCHEMA views in Books On-line:

    This select will pull out the column names that make up the (Primary) key.

    declare @TableName varchar(255)

    set @TableName = 'TABLE NAME'

    select COLUMN_NAME

    from INFORMATION_SCHEMA.KEY_COLUMN_USAGE...

  • RE: arithmatic function

    Or......

    declare @N int

    declare @m int

    set @N = 86548

    set @m = 21458

    select

    cast(left(@N,1) + replicate(0,len(@N)-1) as int)

    *

    cast(left(@M,1) + replicate(0,len(@M)-1) as int)

  • RE: function owner

    Books on line: User Defined Functions:

    Calling User-Defined Functions

    When calling a scalar user-defined function, you must supply at least a two-part name:

    SELECT *, MyUser.MyScalarFunction()

    FROM MyTable

    Table-valued functions can be called by using...

  • RE: Scientfic Notation problem

    Where are you getting the float from?.

    Is it from a table, or an external source

  • RE: Distinct count of records in a table

    ..>>..

    you can do

    select count(distinct col1), count(distinct col2),... from TableName

    But your still going to need to list each field

    ..<<..

  • RE: @@ERROR

    Your @@Error number is being lost with the if @@Error <> 0 begin part (ie: this part does not produce any errors).

    Pass the @@error into another variable immediately after the...

Viewing 15 posts - 16 through 30 (of 82 total)