Forum Replies Created

Viewing 15 posts - 2,266 through 2,280 (of 7,191 total)

  • RE: t-sql 2012 trigger

    Or create a unique filtered index to avoid the need for a trigger:CREATE UNIQUE INDEX UQ_CustomStudent_personID_value_attributeID

    ON dbo.CustomStudent (personID,value,attributeID)

    WHERE value = '17'

    AND attributeID = '9875'

    John

  • RE: t-sql 2012 trigger

    You haven't given any examples of exactly what you're trying to prevent, but from your description, it sounds as if you could do all this (except the e-mail) with CHECK...

  • RE: How to get the previous weeks data based on week ending

    NineIron (10/4/2016)


    I don't get how the cross apply is working. My limited experience is using it like a join. I'm using 2008 Express but, I suppose I could download 12.

    The...

  • RE: How to get the previous weeks data based on week ending

    Yes, that's broadly what I had in mind. The reason I thought it more complicated is that my definition of median includes taking the average of the two middle...

  • RE: How to get the previous weeks data based on week ending

    Which bit are you struggling with - the aggregate function and GROUP BY, the CROSS APPLYs, the DATEADD and DATEDIFF, or something else?

    Please confirm that you are indeed using SQL...

  • RE: Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '-'.

    Assuming you're running this in SSMS, you can double-click on the error and it'll take you to the line in the code. In this instance, I think it's the...

  • RE: How to get the previous weeks data based on week ending

    Here you go. If you don't feel comfortable changing DATEFIRST, you can do some modulo magic on DATEPART(dw,RegistrationDateTime) so that you get the right numbers.

    set DATEFIRST 5 -- set...

  • RE: Scheduled Job

    A job can have more than one schedule. It's easier to have multiple schedules than multiple jobs!

    John

  • RE: How to exclude text values and only include numbers in a varchar column

    Careful, though. Add these rows to your table and try again. I'm sure there are other values that might trip you up, as well.

    insert into #Test(ResultValue) values('3E+1')

    insert into...

  • RE: Help with sorting data from two tables

    csb5036 (9/28/2016)


    USE HandsOnOne;

    SELECT CustomerName, City, State

    FROM Customer, Address

    ORDER BY ZipCode ASC, CustomerName ASC

    When I execute this code, my return is 16 items instead of 4. Somehow, each customer is being...

  • RE: Select top ..., with extra conditions

    Alex

    I've no idea what a PLC is, but I think I can answer your question without knowing! If I were you, I'd put all the PLC variables into a...

  • RE: Using a variable as database name

    I've never tried using variables in a RESTORE statement before, but something like this should work:USE master;

    DECLARE

    @DestDB sysname = 'CIFT01'

    ,@BakFile varchar(260) = 'D:\Microsoft SQL Server\MSSQL11.SQL2012\MSSQL\Backup\2016-09-27_19-00_CIFT01.bak'

    ,@LogicalDataFile sysname

    ,@LogicalLogFile sysname;

    SELECT

    @LogicalDataFile = @DestDB

    ,@LogicalLogFile =...

  • RE: Using a variable as database name

    For five databases, I think I'd just write out the RESTORE statement five times and run the whole lot. The database names aren't going to change each time you...

  • RE: Violation of Primary key

    Ansharah (9/28/2016)


    If know clear root cause of this problem. I can avoid in future since its in Prod.

    Like I said, someone reseeded the identity. Since you need sysadmin, db_owner...

  • RE: Violation of Primary key

    It looks as if someone has reseeded the identity at some point. Find out the maximum value of piagam_id, and reseed the identity again to that value plus one.

    John

Viewing 15 posts - 2,266 through 2,280 (of 7,191 total)