Simple function to return time from datetime value
Since SQL Server stores time as a full datetime value, I use this script to return just the time part formatted as hh:mm:ss.Usage:Select mydb.dbo.udfHHMMSS(Getdate())
2002-02-11
935 reads
Since SQL Server stores time as a full datetime value, I use this script to return just the time part formatted as hh:mm:ss.Usage:Select mydb.dbo.udfHHMMSS(Getdate())
2002-02-11
935 reads
This script provides the DDL required to unconstrain and then reconstrain a table so that in between you can modify the tables contents without being hampered by referential integrity constraints a long the way.Typical call:- utl_UnConstrain 'MyTable'
2002-02-11
264 reads
If you need to check that the tape back of your database backup files was successful, you would generally read the errorlog for the backup software.If you are just interested in today's results or a particular day's log it can be a pain to get. You could have a shortcut on the desktop or you […]
2002-02-10
408 reads
This is an updated scripts with some useful modification for the script submitted by Seshu Kanuri
2002-02-07
745 reads
I use the following script to find out what was running at around the time something of interest happens on our SQL Server. I haven't got around to making this a stored procedure, but it is easy enough to change the date and time interval.
2002-02-06
729 reads
This stored procedure implements a kind of SELECT NEXT x TOP y Columns FROM Table WHERE Condition ORDER BY Order. It works on any table that has a unique id column and it works with any WHERE clause and any ORDER BY condition. The only drawback is its very poor performance on large tables. This […]
2002-02-06
1,246 reads
In SQL 7 you had no way to convert local time to GMT (UTC time) which was added in SQL 2K as GETUTCDATE() which will output the current date you would get with GETDATE() but a it's GMT counterpart. Although this was a great improvement I work with data on another server that's front end […]
2002-02-05
686 reads
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'
2002-02-05
994 reads
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 […]
2002-02-05
646 reads
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.
2002-02-05
1,221 reads
When I put together the invitation for T-SQL Tuesday #202, I wasn't sure what...
By Steve Jones
My life has some crazy travel stretches for sure. Between speaking, office visits, customer...
In Part 1, we saw how ‘Vamana’ represents vectors as nodes, connects them with...
Comments posted to this topic are about the item Server-Level Table sizes
Comments posted to this topic are about the item Optional Parameter Plan Optimization in...
There is a table tmp_tab:
CREATE TABLE tmp_tab ( id int, val int );
INSERT INTO tmp_tab VALUES (1, 1), (2, NULL), (3, 3), (4, 4), (5, 5);You want to order the rows ids by the following expression:
ISNULL(val, id) + 1Which of the following queries produces the expected ordering and why? (Select all correct) See possible answers