Forum Replies Created

Viewing 15 posts - 256 through 270 (of 568 total)

  • RE: How can I count any character in a column?

    neo_pom (9/9/2009)


    If a column keeps email address look like these

    p@hotmail.com;a@hotmail.com

    I'd like count '@' in the column

    How can I write TSQL just only one statement(without loop) to do that ?

    Hi,

    Suppose...

  • RE: How to display integer value from numeric data

    Hi,

    The 1.5, 1.3 is the Integer (whole number)?

    Use the ROUND OFF Method.

    Round (col2, 1)

  • RE: How to trace who run SQL command "delete" on specific dbase?

    Hi,

    Is be very sure that the sequence of records change means some records were removed from the table?

    Try with this table output

    select * from master..syscacheobjects

    where objtype = 'ADHOC'

  • RE: ignore data for null value

    Hi,

    Try this

    create table #temp1

    (

    id1 int null,

    id2 varchar(10) null,

    id3 int null,

    id4 int null

    )

    insert into #temp1

    select null,'TEST',null,null

    union all

    select 1,'REAL',2,3

    union all

    select 2,'REAL1',3,4

    union all

    select 1,null,2,3

    union all

    select 1,'TEST',2,null

    01)

    select * from #temp1

    where id1 is not null

    and...

  • RE: Transpose rows to columns

    Hi,

    try this

    create table TAB1

    (

    col char(2)

    )

    insert into TAB1

    select 'A'

    union all

    select 'B'

    union all

    select 'C'

    union all

    select 'D'

    create table TAB2

    (

    col1 char(2),

    col2 char(2),

    col3 char(2),

    col4 char(2)

    )

    DECLARE @TAB1 VARCHAR(100),@SQL Nvarchar(500)

    SELECT @TAB1 = COALESCE(@TAB1+''',''' , '') +...

  • RE: Group by help needed

    Repeated post, discussions already started in

    http://www.sqlservercentral.com/Forums/Topic780424-8-1.aspx

  • RE: Group by help needed

    Hi,

    try this

    select x.*,y.date as [date]

    from

    (

    select sort,type,Max(price)price,name from @tbl

    group by sort,type,name

    ) as X

    left outer join

    @tbl Y

    on x.sort = y.sort

    and x.type = y.type

    and x.name = y.name

    and...

  • RE: Calculating the Second Sunday jus giving the month alone

    Hi,

    complie this statement

    and getback with the result

    declare @month int,@year int,@DATE varchar(15)

    select @month = 8,@year = 2009

    set @DATE = (cast(@year as varchar)+'-'+cast(@month as varchar)+'-'+'01')

    select @DATE

    SELECT DAY(DATEADD(day,7+7-DATEPART(dw,(cast(@year as varchar)+'-'+cast(@month as varchar)+'-'+'01')),

    (cast(@year...

  • RE: Calculating the Second Sunday jus giving the month alone

    Hi,

    Just modify David Burrows coding posted in the same question early

    SET DATEFIRST 1

    CREATE function get_2_sunday

    (

    @month int,

    @year int

    )

    RETURNS INT

    as

    begin

    declare @day int

    SELECT @day = DAY(DATEADD(day,7+7-DATEPART(dw,(cast(@year as varchar)+'-'+cast(@month as varchar)+'-'+'01')),

    (cast(@year as varchar)+'-'+cast(@month...

  • RE: Simple Oracle Store procedure

    Hi,

    --IN SQL

    CREATE PROC proc1

    @i int

    AS

    BEGIN

    WHILE @i > 0

    BEGIN

    print 'SQL WHILE TESTING'

    SELECT @i = @i-1

    END

    END

    --IN ORACLE

    CREATE OR REPLACE PROCEDURE proc1

    (iv_i IN NUMBER)

    AS

    v_i NUMBER(10,0) :=iv_i;

    BEGIN

    WHILE v_i > 0

    LOOP

    BEGIN

    DBMS_OUTPUT.PUT_LINE('ORACLE WHILE TESTING');

    v_i := v_i...

  • RE: How to get the first day of any month

    HI,

    TRY THIS

    select getdate() + (1 - DAY(getdate()))

    select DATENAME(weekday,(getdate() + 1 - DAY(getdate())))

  • RE: DateDiff Problem

    Hi Leo,

    For the new queries, please put in to the new topic,

    Because lot of voluntaries notice the topic and give their best idea.

  • RE: DateDiff Problem

    Hi,

    Change the year to current year because Birth date comes every year,

    then do the date different

    like

    create table #emp

    (

    ID1 int,

    name1 varchar(10),

    DOB varchar(12))

    insert into #emp

    select 101,'JOHN','27/08/1975'

    union all

    select 102,'JOH','28/09/1975'

    union all

    select 103,'JO','29/10/1975'

    select *,(datediff

    (day,

    getdate(),

    (convert(datetime,replace(DOB,right(DOB,4),(year(getdate()))),103))))AS no_of_days

    ...

  • RE: alternate query for search function

    Hi,

    try with the case when statement

    select * from Store.STIPR,Store.STCategory where

    iprdate = (case when @IPRdate is null then iprdate else @IPRdate end) and

    iprno = (case when @IPRNo is null then iprno...

  • RE: Invalid date format entry

    hi,

    its the varchar column so change& update with the substring

    like

    create table #temp

    ( slno int,

    date1 varchar(15)

    )

    insert into #temp

    select 1,'01/12/2008'

    union all

    select 2,'05/12/2008'

    union all

    select 3,'10/12/2008'

    union all

    select 4,'15/12/2008'

    union all

    select 5,'20/12/2008'

    union all

    select 6,'25/12/2008'

    union all

    select 7,'30/12/2008'

    select...

Viewing 15 posts - 256 through 270 (of 568 total)