Forum Replies Created

Viewing 15 posts - 241 through 255 (of 267 total)

  • RE: Need Date function...

    Hi,

    The following is pretty efficient...

    FYI there are 52178 mondays in this millenium ( <3 sec to calculate ).

    declare @yr int, @mth int

    select @yr = 2004, @mth = 5

    declare @startday datetime, @endday...

  • RE: How to check how many users are connected to a SQL Server

    You could elaborate on the following ( 3 examples ):

     

    select @@servername as server, count(distinct usr) as users, count(*) as processes from

    ( select sp.loginame as usr, sd.name as db

     from sysprocesses sp join...

  • RE: Version Differences...

    EM uses xp_msver to rerieve some server metadata.

    See if xp_msver and @@version returns different results in QA ?

    /rockmoose

  • RE: Transforming rows to name value pairs

    I think you would be helped by a code generation tool.

    Either write some TSql ( or other ) code that will generate the desired Name - Value pairs for You....

  • RE: can any one suggest me how to page the results of an SQL

    Another way to do this with just sending in two parameters ( pagenbr, pagesize ).

    Would be. ( example from Pubs )

    SET NOCOUNT ON

    DECLARE @pagenbr INT,

     @pagesize INT,

     @rows_skipped INT

    SET @pagenbr = 2

    SET...

  • RE: list of tables with identity field.

    Some MetaData from INFORMATION_SCHEMA.COLUMNS in case You don't want to select from systables..

    /rockmoose

    SELECT

     ic.ORDINAL_POSITION,

     ic.COLUMN_NAME,

     ic.DATA_TYPE,

     ic.CHARACTER_MAXIMUM_LENGTH,

     ic.NUMERIC_PRECISION,

     ic.NUMERIC_SCALE,

     IS_IDENTITY = COLUMNPROPERTY ( OBJECT_ID( ic.TABLE_CATALOG + '.' + ic.TABLE_SCHEMA + '.' + ic.TABLE_NAME ) , ic.COLUMN_NAME ,...

  • RE: Using Information Schema to retrive columns - require help

    To filter the user tables in your sql

    SELECT TABLE_NAME, COLUMN_NAME,

    DATA_TYPE, CHARACTER_MAXIMUM_LENGTH,

    ORDINAL_POSITION

    FROM INFORMATION_SCHEMA.columns

    WHERE OBJECTPROPERTY( OBJECT_ID(TABLE_CATALOG + '..' + TABLE_NAME), 'IsMsShipped' ) = 0

    ORDER BY TABLE_NAME, ORDINAL_POSITION

     

    /rockmoose

  • RE: Using Information Schema to retrive columns - require help

    This Link will get you started retrieving metadata from sql server:

     

    http://www.dbazine.com/sharma4.shtml

     

    /rockmoose

  • RE: Calculating days in a month

    Or given a Date:

    DECLARE @DATE DATETIME

    SET @DATE = GETDATE()

    SELECT CAST(

     -- First day of next month

     DATEADD(MONTH,DATEDIFF(MONTH,0,@DATE)+1,0)

     -

     -- First day of current month

     DATEADD(MONTH,DATEDIFF(MONTH,0,@DATE),0)

     AS INT )

     

    /rockmoose

  • RE: Users From Hell

    Really nice, made me laugh.

    Once had a project involving Crystal Reports. And I told a user that the reports could be exported to excel. But it didn't work the user...

  • RE: Query Help

    1. Gain basic SQL knowledge.

    You may "copy" data from one table to another using the INSERT statement or perhaps use SELECT INTO.

    2. In SQL Server you may also use DTS...

  • RE: Design

     

    Much of the performance and scaling issue is the number of Concurrent users on the system. ie how many will use the system at the same time ( 4...

  • RE: Mutually Exclusive NULL

    If it is XOR you are after, you could modify alzdba constriant to:

    alter table t_muteNULL

    add constraint chkMuteNULL check ((case when col2 is null then 1 else 0 end) ^...

  • RE: sql server merge into

    No, You would have to do the work in 2 sql batches UPDATE - INSERT

    Something like...

    UPDATE employee SET

            salary = et.salary,

            bonus = et.bonus,

            comm = et.comm

    FROM

            emp_temp et

    WHERE

            employee.empno...

  • RE: Getting users domain name

    Hi,

    Maybe using suser_sname(), and formatting result:

    select 

            name as sql_user,

            suser_sname(sid) as login,

            left( suser_sname(sid), charindex('\', suser_sname(sid))-1 ) as domain,

            substring( suser_sname(sid), charindex('\', suser_sname(sid))+1, len(suser_sname(sid)) ) as domain_user,

            sid

    from

            sysusers

    where

            isntuser...

Viewing 15 posts - 241 through 255 (of 267 total)