Sql server
identity set:
DBCC CHECKIDENT('Admin', RESEED, 0)
check db mails status:
use msdb
select * from sysmail_allitems order by 1 desc
Remove all constraints of a table and then delete the data of table
exec sp_MSforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
exec sp_MSforeachtable 'ALTER TABLE ? DISABLE TRIGGER ALL'
exec sp_MSforeachtable 'DELETE FROM ?'
exec sp_MSforeachtable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
exec sp_MSforeachtable 'ALTER TABLE ? ENABLE TRIGGER ALL'
exec sp_MSforeachtable 'IF NOT EXISTS (SELECT *
FROM SYS.IDENTITY_COLUMNS
JOIN SYS.TABLES ON SYS.IDENTITY_COLUMNS.Object_ID = SYS.TABLES.Object_ID
WHERE SYS.TABLES.Object_ID = OBJECT_ID(''?'') AND SYS.IDENTITY_COLUMNS.Last_Value IS NULL)
AND OBJECTPROPERTY(OBJECT_ID(''?''), ''TableHasIdentity'') = 1
DBCC CHECKIDENT (''?'', RESEED, 0) WITH NO_INFOMSGS'
Cursor Declaration
DECLARE @MyCursor CURSOR
SET @MyCursor = CURSOR FAST_FORWARD
FOR
SELECT UserID,EmailID
FROM UserInfo where isnull(EmailID,'')!=''
OPEN @MyCursor
FETCH NEXT FROM @MyCursor
INTO @UserId,@Toemail
WHILE @@FETCH_STATUS = 0
BEGIN
select @EmailNotif=EmailNotifiaction from NotificationSettings where UserID=@UserId and NotificationTypeID=3
if(@EmailNotif=1)
begin
EXEC msdb.dbo.sp_send_dbmail
@recipients =@Toemail ,
@profile_name ='KaiserAdmin',
@subject ='Bulletin Board',
@body = @tableHTML,
@body_format = 'HTML';
end
FETCH NEXT FROM @MyCursor
INTO @UserId,@Toemail
END
CLOSE @MyCursor
DEALLOCATE @MyCursor
No comments:
Post a Comment