Forum Replies Created

Viewing 15 posts - 646 through 660 (of 683 total)

  • RE: Get Curent Users PC Name / IP Address

    Running the line below gives you various ip config details:

    exec master..xp_cmdshell 'ipconfig'

    ...so you just need to strip out what you want:

    declare @ip_row varchar(255)

    declare @ip_address varchar(20)

    set...

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • RE: creating a trigger on a thread

    Hi Oren,

    The documentation says 'A view can be referenced only by an INSTEAD OF trigger.':

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_create2_7eeq.asp

    So try:

    create trigger test

    on testview

    instead of update

    as

    begin

            doing...

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • RE: Sort By Date??

    Have you tried it Jeff?  That doesn't seem to work for me...

     

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • RE: Sort By Date??

    Oops... datetime, rather than date...

    ...order by cast(tl.Date as datetime) asc 

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • RE: Sort By Date??

    2 things which work (although they're not entirely satisfactory) are:

    1. Use a different alias:

    select SUBSTRING(CAST(tl.Date as nvarchar), 0, 12) as 'MyDate'...

    2. Cast it back to a date:

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • RE: Counting the records

    Erm, how about:

    select count(*) from (select A from table_name group by A) a

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • RE: Counting the records

    Or this:

    select count(distinct A) from table_name

    It returns: 3

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • RE: Sql query for displaying multidimensional data.

    Hi Subhash,

    If you get your data into a SQL table, you can do something like the following (this SQL is safe to run):

    create table #t (DocNumber int, c706000...

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • RE: selecting a effective date from a table

    Hi Naveed,

    I think the code below does the trick.  It is safe to run the whole thing.

    I usually find it easier to manage this kind of historical data if an...

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • RE: Banker''''s rounding in T-SQL (like Math.Round in .NET)

    Jeff - I think that may not work for the 3.445657545 example (which should go to 3.45).

    Here's an alternative (non-looping) solution:

    CREATE FUNCTION dbo.RoundBanker (@x money, @DecimalPlaces tinyint)...

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • RE: stripping numeric text out of a field

    You can do the same kind of thing:

    --select between position 4 and the first number after position 4

    Declare @TestData varchar(20)

    Set @TestData = 'U2-GED 34039'

    Select...

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • RE: Query all the primary keys of a table

    Here's the full answer, I think - again using the INFORMATION_SCHEMA.  I've built it up a bit at a time (using table variables) so it's easier to understand.

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • RE: Per instance temporary tables?

    Take out the "CONSTRAINT [PK_RP_Temp]" bit of your query, and I think it should all work fine.

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • RE: View from pivoted data

    How's this?

    CREATE TABLE #T1 (

    l_id char(3) not null,

    v_id char (12) not null,

    diag_code char (5) not null,

    diag_desc varchar (10) null,

    seq_nbr char (2) not null,

    c_id char (12) not null,

    createdate...

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • RE: creating a copy of a table programmatically

    Take a look at this article that I wrote a few years ago...

    http://www.sqlservercentral.com/columnists/rrandall/creatingascriptfromastoredprocedure.asp

    The full title was originally 'Creating a 'Create Table' script from a stored procedure', but it got...

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

Viewing 15 posts - 646 through 660 (of 683 total)