SQL SERVER – Using RAND() in User Defined Functions (UDF)
Here is the question I received in email.
“Pinal,
I am writing a function where we need to generate random password. While writing T-SQL I faced following issue. Everytime I tried to use RAND() function in my User Defined Function I am getting following error:
SQL SERVER – Removing Leading Zeros From Column in Table
Some questions surprises me and make me write code which I have never explored before. Today was similar experience as well. I have always received the question regarding how to reserve leading zeroes in SQL Server while displaying them on the SSMS or another application. I have written articles on this subject over here about leading zeros.
SQL SERVER – Retrieving Random Rows from Table Using NEWID()
SQL SERVER – Function to Round Up Time to Nearest Minute Interval
Though I have written more than 2300 blog posts, I always find things which I have not covered earlier in this blog post. Recently I was asked if I have written a function which rounds up or down the time based on the minute interval passed to it. Well, not earlier, but it is here today about how to create a function to round up time to nearest minute interval.
SQL SERVER – Find First Non-Numeric Character from String
SQL SERVER – Preserve Leading Zero While Coping to Excel from SSMS
Earlier I wrote two articles about how to efficiently copy data from SSMS to Excel. Since I wrote that post there are plenty of interest generated on this subject. There are a few questions I keep on getting over this subject. One of the question is how to get the leading zero preserved while copying the data from SSMS to Excel. Well it is almost the same way as my earlier post SQL SERVER – Excel Losing Decimal Values When Value Pasted from SSMS ResultSet. The key here is in EXCEL and not in SQL Server.