Forum Replies Created

Viewing 15 posts - 181 through 195 (of 907 total)

  • RE: Remove Leading Zeros

    Gee I don't know what I was thinking. A sole replace is not going to do it. But multiple replaces with a ltrim will:

    replace(ltrim(replace(<value with leading zeroes>,'0',' ')),' ',0)

    Gregory...

  • RE: Selecting the top two for a group.

    Here is a query that would work for you, but is slow on large sets if no index is available. I would create a composite index on group, qty,...

  • RE: Remove Leading Zeros

    Try using the replace something like:

    declare @lz varchar(10)

    set @lz = '000001'

    select @lz

    select replace(@lz,'0','')

    Gregory Larsen, DBA

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

  • RE: Where to get Enterprise Manager

    The evaluation copy is a great idea, but why not own your very own copy of SQL Server. The price of buying the developer edition of SQL Server...

  • RE: top 20 amounts by a area

    I think if you would have created the following clustered, or nonclusted index on you test table like below, then ran the update command I supplied you would find that...

  • RE: Comparing two tables

    Now, since the UNION statement removes duplicates the UNION example will only work if there are no duplicate records in table A and B. Here is an example where...

  • RE: Comparing two tables

    Nice way to use the UNION statement to determine if two sets are equal.

    Gregory Larsen, DBA

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

  • RE: top 20 amounts by a area

    I would expect this to be a CPU bound process that might cause your CPU to spike, but I'm not sure how you are came up with the 7,540,000 number....

  • RE: top 20 amounts by a area

    You probably caught my typo. These query should have been:

    select * from test a

    where disamount in (select top 20 disamount from test where area = a.area order by...

  • RE: top 20 amounts by a area

    Think something like this might work for you:

    select * from test a

    where disamount in (select top 20 disamount from testz where area = a.area order by disamount desc)

    Gregory Larsen,...

  • RE: Comparing two tables

    You could write yourself some code that does that, like:

    create table a (a int primary key, b int)

    create table b (a int primary key, b int)

    insert into a values(1,1)

    insert into...

  • RE: Select INTO using Query

    Try something like:

    SELECT * INTO #temp

    from Select * from TBL_test

    or

    SELECT * INTO #temp2

    from Select * from TBL_test where col1 = 'abc'

    Gregory Larsen, DBA

    If you looking for...

  • RE: Quering Table Attributes

    You might also try:

    select * from information_schema.columns where table_name = '<yourtable>'

    Gregory Larsen, DBA

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

  • RE: Finding & removing a space from a string

    I have to admit Calvin Lawson is correct the while loop is much easier to read and understandable, but I had to see for myself which performed better. ...

  • RE: Finding & removing a space from a string

    The real solution is on my website. You just need two more replace statements like so to handle all cases. Also if you want an inline solution a...

Viewing 15 posts - 181 through 195 (of 907 total)