Forum Replies Created

Viewing 15 posts - 286 through 300 (of 921 total)

  • RE: Days of the week.

    Perhaps something like this?

    
    
    CREATE PROC p_weeks @mo tinyint, @yr smallint AS
    SET NOCOUNT ON
    SELECT CONVERT(char(8),MIN(CAST(dt AS datetime)),1) + ' - ' + CONVERT(char(8),MAX(cast(dt AS datetime)),1)
    FROM
    (SELECT CAST(@yr AS...
  • RE: SQL QUERY

    
    
    SELECT o.Trck#, o.Pol#
    FROM Chawra O JOIN
    (SELECT Trck#
    FROM
    (SELECT DISTINCT Trck#, Pol#
    FROM Chawra) c
    GROUP BY Trck#
    HAVING COUNT(*) > 1) x ON x.Trck# = o.Trck#

    --Jonathan

  • RE: Date Format

    Why not just use CONVERT with Type 112 (ISO)?

    SELECT CONVERT(char(8),GETDATE(),112)

    --Jonathan

  • RE: Generate Sequence Number Safely

    I know I've posted this before...

    
    
    CREATE PROC p_NextID @SeqType char(2), @NextID int OUTPUT AS
    SET NOCOUNT ON
    UPDATE Sequences
    SET @NextID = LastID = LastID...
  • RE: Deterministic/Nondeterministic Functions

    Because, unlike the other string functions, they can return different results dependent upon the database compatibility level.

    --Jonathan

  • RE: FK Constraints across database

    USE Northwind
    
    go
    CREATE FUNCTION dbo.f_CheckPub(@pubid char(4))
    RETURNS bit BEGIN
    DECLARE @ret bit
    IF EXISTS
    (SELECT *
    FROM pubs.dbo.Publishers
    WHERE Pub_Id = @pubid) SET @ret = 1
    ELSE SET @ret = 0
    RETURN @ret...
  • RE: SQL on NAS

    It was only in the last year that Microsoft grudgingly allowed this at all (I believe because they are now in the NAS software business and were asked by their...

  • RE: How to select distinct month- year order by month-

    
    
    SELECT MonthYr
    FROM
    (SELECT DISTINCT DATENAME(m,ProductionDate) + '-' + DATENAME(yy,ProductionDate) MonthYr, CONVERT(char(7),ProductionDate,120) MoYr
    FROM MyTable) d
    ORDER BY MoYr

    --Jonathan

  • RE: vb and sql server

    This could be the known problem where you need to put SET NOCOUNT ON in the stored procedure.

    --Jonathan

  • RE: Cursor not working

    You don't need a cursor to do this, of course. It's easy enough to do as just one update statement.

    --Jonathan

  • RE: HardQuery

    quote:


    Won't this work?

    Update Product

    set P2.Account = Case when C2.Account is not null then C2.Account

    else (select C1.Account from Product as P1...

  • RE: String Aggregate Function

    Or, if you can stand yet another way:

    
    
    CREATE FUNCTION dbo.f_ListTemp(@id int)
    RETURNS varchar(8000) BEGIN
    DECLARE @list varchar(8000)
    SELECT @list = ISNULL(@list + ',','') + Name
    FROM Temp
    WHERE Id = @id
    RETURN...
  • RE: LastUpdated < LastApplied

    Assuming these columns are datetimes, you could convert using style 120. The real issue may be that you have insert processes that have a separate update statement following the...

  • RE: FK Constraints across database

    If this is SQL Server 2000, you can use a UDF in a check constraint.

    --Jonathan

  • RE: Validating all published databases

    quote:


    Hi!

    I am trying to run a validation procedure on all articles for all published databases on the server. Because...

Viewing 15 posts - 286 through 300 (of 921 total)