Forum Replies Created

Viewing 15 posts - 166 through 180 (of 907 total)

  • RE: Select Range Of Date

    Not really sure you even need to use the quarter table, provided you have normal quarter boundaries. If you have normal boundaries then I might use something like this...

  • RE: Calling a DTS from a stored procedure

    One thing worth considering when deciding whether to run your package via a SQL Agent job, or via xp_cmdshell is timing of when the sp executes the statement after staring...

  • RE: Date conversion

    Sorry, I made that calculation do a lot more work then it needed to. Here is one with less math:

    select convert(char(10),

    dateadd(day,cast(substring(@jdate,5,7) as int)-1,cast(substring(@jdate,1,4) + '-01-01' as datetime))

    , 101)

    Gregory Larsen,...

  • RE: Date conversion

    Try something like this:

    declare @jdate char(7)

    set @jdate = '2003226'

    select convert(char(10),dateadd(day,1,datediff(day,1,substring(@jdate,1,4) + '-01-01')+

    datediff(day,1,cast(substring(@jdate,5,7) as int))), 101)

    Gregory Larsen, DBA

    If you looking for SQL Server...

  • RE: automating query output to a file

    Here I put the code into an SP (see below).

    Place this command in a sql server agent job step:

    osql -E -S<yourserver> -Q"dba.dbo.usp_get_dbinfo" -oc:\\temp\dbinfo.txt

    CREATE PROCEDURE usp_get_dbinfo

    AS

    /*******************************************************************/

    --Name ...

  • RE: Generate SQl Script

    You can also use scptxfr.exe to script. This can be found in the upgrade directory. If you want to do it via t-sql then execute this via xp_cmdshell.

    c:\mssql\upgrade\scptxfr.exe...

  • RE: Changing sort order SQL 7.0

    Here is a couple of articles that might help regarding collation and changing the collation settings.

    http://www.sqlservercentral.com/columnists/glarsen/collate_part1.asp

    http://www.sqlservercentral.com/columnists/glarsen/collate_part2_1.asp

    Gregory Larsen, DBA

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

  • RE: How do i get result of a query to a SP variable?

    Interesting way to do that with a temporary SP. Here is another way using sp_executesql:

    Declare @tablename sysname

    declare @tablecount int

    declare @strsql nvarchar(4000)

    set @tablename = 'pubs.dbo.authors'

    set @strsql = 'select @tablecount=count(*) from...

  • RE: Given a date Find the Stored Procedures Updated

    one note. If you just alter a sp then the schema_ver number is incremented in the sysobjects table. If you knew the schema_ver number for all object prior...

  • RE: sp results into a variable

    Try something like this:

    set nocount on

    go

    create table tableA (

    col1char(5) not null,

    col2int not null,

    col3smallint not null,

    col4char(80),

    col5char(20),

    constraint pk_tableA primary key nonclustered (col1, col2, col3))

    go

    create table sp_out (

    TABLE_QUALIFIER varchar(128),

    TABLE_OWNER varchar(128), ...

  • RE: brain teaser

    You might try something like this

    update indate_count

    set MonthEndInd = 'z'

    where in_date in (select max(in_date) from indate_count

    group by datepart(yy,in_date),datepart(mm,in_date))

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out...

  • RE: 7.0 to 2000 Migration

    You might run into problems if you have different collation setting between SQL Server 2000 and 7.0. This normally happens when doing cross-database joins/compares. Basically the SQL 7.0 collation is...

  • RE: DUPLICATE RECORDS

    You can also add an identity column to the table to help with deleting duplicates. Here is an example of some code to do that:

    alter table dup_table

    ...

  • RE: Where condition based on multiple rows

    Possibly something here might work for you:

    set nocount on

    declare @test-2 table (studentid int, specialcodeid int, specialcodevalue varchar(100))

    insert into @test-2 values (111 ,10 ,'abc')

    insert into @test-2 values (111 ,11 ,'5')

    insert into...

  • RE: Comparing two tables

    leitera - Good way to remove those duplicate rows first before comparing the two tables. Although there still are issues with the union option. Here table B has...

Viewing 15 posts - 166 through 180 (of 907 total)