
If you have the need of a piece of SQL code to generate a password you can use this one:
declare @pw varchar(8)
declare @count int
declare @characterpool varchar(50)
set @characterpool = 'abcdefghijkmnpqrstuvwxyz0123456789'
set @count = 0
set @pw = ''
while @count <= 8
begin
set @pw = @pw + SUBSTRING(@characterpool,
CAST(ABS(CHECKSUM(NEWID()))*RAND(@count) as int)%LEN(@characterpool)+1,1)
set @count = @count + 1
end
This generates an eight digit password using the characters a-z and numbers. If you want you can change the length of the password by changing the ’8′ to the desired number in the lines:
declare @pw varchar(8)
while @count <= 8
Hope you find this useful.
Thanks to GM for the code.
|
Posted by
whit3kr0w |
Categories:
Programming | Tagged:
code,
generate,
password,
SQL |
Quick SQL tip that I find useful. If you want just the date part of a datetime value, the following neat expression yields it:
SELECT DATEADD(d, 0, DATEDIFF(d, 0, datetime_column))
This is useful for comparing dates. Alternative approaches include casting to string, and comparing the date parts (day, month, year) separately. The context determines which is most appropriate.
Gently provided by SK.
|
Posted by
whit3kr0w |
Categories:
Programming | Tagged:
SQL,
tip |

Some time ago I was quite interested in programming languages but that interest wore off because I found a bit hard to get a job on that area. Of course, things have changed and now it’s quite easy to get a job on that specific area. You can even choose what language you want to use. But now, and because I’m part of a Development team, although I’m not developing anything, the “bug” has returned and I feel like experimenting with new technologies out there.
I’ve been reading a bit about WPF and XAML. It seems like this is the future, or at least that’s what most people are saying. The first time I heard someone talking about that my question was “what the hell is that?”. Simply put XAML is very similar to XML and it stands for eXtensible Application Markup Language. WPF stands for Windows Presentation Foundation (complicated name). I am not going to explain what those things are and what you can do about it. The purpose of this article is to share, with someone also interested in learning a bit more about it (like me), a website that contains a nice bunch of tutorials that I found very interesting.
If someone knows about any interesting reading about these subjects drop me a line. Don’t forget I’m learning. Also need to spend some time looking at C# or VB. It’s been a long time without look at it.
You can check these in here: http://joshsmithonwpf.wordpress.com/a-guided-tour-of-wpf/