Scripts

Technical Article

Date/Time formatting function

T-SQL analog for Visual Basic FORMAT function. Created for MSSQL 2000. Works regardless of language settins on server or client side! fn_format('YYYY/DD/MM HH:MI','2002-03-13 12:00') = '2002/13/03 12:00' fn_format('DD.MM.YY','2002-03-13 12:00:00') = '13.03.02' fn_format('HH:MI:SS','2002-03-13 12:00:00') = '12:00:00'

You rated this post out of 5. Change rating

2002-02-05

966 reads

Technical Article

Run a blackbox trace

There is a script for setting up a blackbox trace on SQL 2000 described by Kalen Delaney in "Inside SQL Server 2000". Since I can never remember where to look it up I wrote this simple stored procedure to run the blackbox trace when I need it. This should be used with caution as it […]

You rated this post out of 5. Change rating

2002-02-05

619 reads

Technical Article

Splitting string of values to table

This function can convert string with separated values to table. Exclusive feature: items inside quotes will not be splitted! Now you can easily perform joins on CSV strings! For expample: fn_split('1, 2, ''3, 4'', 5',',')= 1 2 3, 4 5 First parameter - string with values, second - delimiter character.

5 (1)

You rated this post out of 5. Change rating

2002-02-05

1,173 reads

Technical Article

Auditing Solution - Generate Triggers automatically

The procedure looks at the table you want to be audited and writes the INS, UPD, and DEL triggers automatically required for the auditing to work. The auditing requires a table called Progress to hold the audit information in so have provided the DDL for this as well. Typically you would write a cursor to […]

You rated this post out of 5. Change rating

2002-02-04

476 reads

Technical Article

Procedure Search by Keyword(s)

Searches SysComments for occurances of entered keywords and returns a list of procedures that contain the keywords. eg1) To find all procedures with 'nMyColumn' in EXEC utl_ProcSearch 'nMyColumn' eg2) To find all procedures with 'nMyColumn' in and 'nMyColumn2' in EXEC utl_ProcSearch 'nMyColumn', 'nMyColumn2' eg3) To find all procedures with temporary tables in... EXEC utl_ProcSearch '#' […]

You rated this post out of 5. Change rating

2002-02-04

196 reads

Technical Article

Get list of files from dir and put in table

This stored procedure reads the file names from a directory and stores just the names in a given table. It returns also the number of files present. The sp uses xp_cmdshell and so permissions are restricted to sysadmins and SQLAgentCmdExec. You can test with the following: Create Table ##tmp2 ( fldx nvarchar(255) ) Declare @FilePath […]

1 (1)

You rated this post out of 5. Change rating

2002-02-01

1,934 reads

Technical Article

Stored procedure to expose information for a file

I wanted to be able to use info about an operating system file in TSQL. So I wrote this stored procedure that uses the special stored procedures xp_fileexist and xp_getfiledetails. This can tell if a file or folder exists, and if it is a file what is its size, created date and time, last written […]

You rated this post out of 5. Change rating

2002-02-01

1,210 reads

Technical Article

SP to import to a file

Is a SP that imports a table to a file. You just put the table name, the path and the sa password and then you have it. It is important that it parse the table inserted (pubs.dbo.sales for example) and checks that the db, the table with the owner exists

You rated this post out of 5. Change rating

2002-01-28

1,675 reads

Blogs

Attacking the Weakest Link

By

When I look at a system and think about its security model, the first...

Webinar – Microsoft Fabric for Dummies

By

On Wednesday May 15th 2024 I will give a free webinar on MSSQLTips.com about...

Migrate datetime data to datetimeoffset with AT TIME ZONE

By

I recently reviewed, worked on, and added a similar example to the DATETIMEOFFSET Microsoft...

Read the latest Blogs

Forums

Extend Event with sqlserver.login

By Ken McKelvey

My knowledge of Extended Events is limited, but I am trying to capture some...

ghost backups processed 0 pages

By Snargables

I've got something I'm not aware of performing backups of my dbs at random...

Stored Procedures - passed string than variable length

By Arthur Kirchner

Dear all, I was just wondering: Can you change the default behaviour as illustrated...

Visit the forum

Question of the Day

The Backup File Extension

I run this command in SQL Server 2022. What is the extension of the backup file?

BACKUP DATABASE HerdofTwo TO DISK = 'HerdOfTwo_20240501'

See possible answers