Running Total on Single query
This query calculates the running Total on Table without using cursors or variables.
2003-04-22
378 reads
This query calculates the running Total on Table without using cursors or variables.
2003-04-22
378 reads
For security and auditing purpose, in some cases there would be a need of tracking transaction detail on a table.The following script achive this using Triggers. The auditedevents will be stored in a separate table.
2003-04-19
262 reads
This procedure is just another approach for getting a list of tables defined in a database, ordered by dependency on other tables based on foreign key relationship.I used it for a deployment process, where the TABLE create scripts must be executed in the correct order,because the foreign key constraints are specified in the create script […]
2003-04-18
372 reads
It is a painful experience for all us administrators to truncate logs regularly. I just created a job to executesp_msforeachdb "use ?; backup log ? with truncate_only ; dbcc shrinkfile(2,5)"on all the servers at frequent intervals. It has saved me a lot of time. hope it helps you too.n.b: I assume that file id 2 […]
2003-04-18
318 reads
This vbscript will generate the sql to recreate all the jobs running on a given SQL server. I wrote this because the last time we migrated a SQL server, I ended up re-creating all the jobs, steps and schedules by hand using the Enterprise Manager. It was the slowest, dullest and most error-prone part of […]
2003-04-17
831 reads
Using this technique you can do error handling in SQL Server using the same way you do in Visual Basic (most of it). Just put your SQL Statement in exec('SQL Command') and make use of @@Error to get error information and put your error handling code in If block.Mohit NayyarMCP (.Net), MCSD, MCDBA
2003-04-17
954 reads
If you ever have been put in a situation where your database has a lot of objects and some of those do not have primary keys, trying to find feels like needle in the haystack. I have modified the script contributed by Mr.Tandrei and Mr.Rahul sharma. The following script gives all the tables that do […]
2003-04-17
140 reads
This query will give you the table name and column name on which you have defined the primary key. You can use this to get columns on which the primary key is based. I find it very useful when i need to define the FK relationship for other tables in PowerDesigner. Try to do the […]
2003-04-16
1,654 reads
Copies the permissions from an existing database user to a new database user.Usage:exec copy_permissions_for_database 'From_User', 'To_User'* From_User must exist in the database.* To_User must not exist in the database.* To_User must exist as a login on the server.I used http://www.sqlservercentral.com/columnists/awarren/sqlpermissionspublicrole_2.asp as a starting point.
2003-04-14
1,872 reads
Use this script to get Insert, Update and Delete trigger for all the tables. This script will give you just the first level of triggers. So if you have more than 1 insert trigger, it will give you the first one.Mohit NayyarMCP (.Net), MCSD, MCDBA
2003-04-14
269 reads
By James Serra
There are three Azure SQL products with so many different deployment options, service tiers,...
By Steve Jones
I hosted this month’s T-SQL Tuesday party with my invitation asking about tracking permissions....
By Steve Jones
I was asked to do some a little thinking and brainstorming recently. Rather than...
Hi, Does anyone have experience with MEMORYBROKER_FOR_RESERVE ? when suddenly there is somehow constantly...
I just learned that my database was created on my C:\ drive in the...
I am needing to migrate a MSSQL db to MySQL, on a different server...
I have a complex database with a few filegroups and files. Can I run a backup command like this? (assume file/filegroup names are valid).
BACKUP DATABASE [complex] FILE = N'thirdone' , FILE = N'thirdtwo' , FILEGROUP = N'second' TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL16.SQL2022\MSSQL\Backup\complex.bak' WITH NOFORMAT, NOINIT, NAME = N'complex-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10 GOSee possible answers