Showing posts with label simply. Show all posts
Showing posts with label simply. Show all posts

Wednesday, March 7, 2012

Don't understand the concept behinf RAND

I am trying to generate 15-digit creditcard value (varchar) for testing.
I thought I could simply use the RAND function and extract 15 characters
from the right of the decimal. However this doesn't work, I lose most of th
e
significant digits when I try to conver to a varchar.
So I thought I would generate 15 random numbers and concatenate them
together. However this doesn't work either. When I repeatedly run the
statement below, I get do not get any randomness at all, the same digit
repeats over and over again and will only occasionally change.
SELECT str(10*RAND( (DATEPART(mm, GETDATE()) * 100000 )
+ (DATEPART(ss, GETDATE()) * 1000 )
+ DATEPART(ms, GETDATE()) ))
What don't I understand? Can anyone help me out with this?SELECT RIGHT(RTRIM(CONVERT(DECIMAL(18,17),
10.0*RAND( (DATEPART(mm, GETDATE()) * 100000 )
+ (DATEPART(ss, GETDATE()) * 1000 )
+ DATEPART(ms, GETDATE()) ))),15)
"Dave" <Dave@.discussions.microsoft.com> wrote in message
news:1E08F862-FFFF-4DD0-8EFA-4F714DBD125F@.microsoft.com...
>I am trying to generate 15-digit creditcard value (varchar) for testing.
> I thought I could simply use the RAND function and extract 15 characters
> from the right of the decimal. However this doesn't work, I lose most of
> the
> significant digits when I try to conver to a varchar.
> So I thought I would generate 15 random numbers and concatenate them
> together. However this doesn't work either. When I repeatedly run the
> statement below, I get do not get any randomness at all, the same digit
> repeats over and over again and will only occasionally change.
> SELECT str(10*RAND( (DATEPART(mm, GETDATE()) * 100000 )
> + (DATEPART(ss, GETDATE()) * 1000 )
> + DATEPART(ms, GETDATE()) ))
> What don't I understand? Can anyone help me out with this?
>|||I thought that most credit card numbers were a fixed length of 16
digits, in grouping of 4 digits, with the first grouping being the
issuer and the rest of the number following some rules.
That means that your random numbers are going to fail (well, you might
hit a valid card number by chance every few billion rows). Look at
these websites for some help:
[url]http://www.omnipilot.com/Tip%20of%20the%20W.1768.8848.lasso[/url]
http://www.analysisandsolutions.com...e/ccvs/ccvs.htm|||Dave,
I find CHEKSUM(NEWID()) a good seed for the RAND() function.
Also, keep in mind that RAND() returns a float in the range 0 through 1
inclusive.
With the above in mind, I'd use something like:
select right(cast(rand(checksum(newid())) as decimal(15, 15)), 15)
BG, SQL Server MVP
www.SolidQualityLearning.com
"Dave" <Dave@.discussions.microsoft.com> wrote in message
news:1E08F862-FFFF-4DD0-8EFA-4F714DBD125F@.microsoft.com...
>I am trying to generate 15-digit creditcard value (varchar) for testing.
> I thought I could simply use the RAND function and extract 15 characters
> from the right of the decimal. However this doesn't work, I lose most of
> the
> significant digits when I try to conver to a varchar.
> So I thought I would generate 15 random numbers and concatenate them
> together. However this doesn't work either. When I repeatedly run the
> statement below, I get do not get any randomness at all, the same digit
> repeats over and over again and will only occasionally change.
> SELECT str(10*RAND( (DATEPART(mm, GETDATE()) * 100000 )
> + (DATEPART(ss, GETDATE()) * 1000 )
> + DATEPART(ms, GETDATE()) ))
> What don't I understand? Can anyone help me out with this?
>|||>I thought that most credit card numbers were a fixed length of 16
> digits, in grouping of 4 digits
American Express is 15.|||--CELKO-- wrote:
> I thought that most credit card numbers were a fixed length of 16
> digits, in grouping of 4 digits, with the first grouping being the
> issuer and the rest of the number following some rules.
> That means that your random numbers are going to fail (well, you might
> hit a valid card number by chance every few billion rows). Look at
> these websites for some help:
> [url]http://www.omnipilot.com/Tip%20of%20the%20W.1768.8848.lasso[/url]
> http://www.analysisandsolutions.com...e/ccvs/ccvs.htm
Well, he might generate 15 digits and then calculate the last digit
using luhn, so it should at least pass that check.
On a curiosity side-not - anyone ever implemented luhn as a check
constraint? I'd love to see the beast.
Damien

Sunday, February 19, 2012

Domain and windows authentication

Hi,
We have a application that uses windows authentication to connect to sql
server. We have a domain and simply just create a login in sql server for
each user in the domain.
We have setup this application in the company that doesn't have domain.
We're not going to change the source of the application to accept sql server
authentication.
Can we still use the windows authentication to allow the users to log in?
Suppose that each user logs in his computer as administrator of that
computer. Can we prefix these administrators with the name of their
computers to create login in sql server and still use windows
authentication?
Any help would be greatly appreciated.
Amin
Microsoft SQL Server support only Domain Authentification, no Machine
Account Authentification (except the local machine of the sql server),
because Workgroups are not trustable.
Hope this helps,
Jens Smeyer
"Amin Sobati" <amins@.morva.net> schrieb im Newsbeitrag
news:%23ahXq45gEHA.1764@.TK2MSFTNGP10.phx.gbl...
> Hi,
> We have a application that uses windows authentication to connect to sql
> server. We have a domain and simply just create a login in sql server for
> each user in the domain.
> We have setup this application in the company that doesn't have domain.
> We're not going to change the source of the application to accept sql
server
> authentication.
> Can we still use the windows authentication to allow the users to log in?
> Suppose that each user logs in his computer as administrator of that
> computer. Can we prefix these administrators with the name of their
> computers to create login in sql server and still use windows
> authentication?
> Any help would be greatly appreciated.
> Amin
>
|||Jens,
Therefore in workgroups there's no other solution except using sql server
authentication?
"Jens Smeyer" <MrIgel[RejectSpam|RemoveBracket]@.gmx.de> wrote in message
news:OCvmQg7gEHA.2764@.TK2MSFTNGP11.phx.gbl...[vbcol=seagreen]
> Microsoft SQL Server support only Domain Authentification, no Machine
> Account Authentification (except the local machine of the sql server),
> because Workgroups are not trustable.
> Hope this helps,
> Jens Smeyer
>
> "Amin Sobati" <amins@.morva.net> schrieb im Newsbeitrag
> news:%23ahXq45gEHA.1764@.TK2MSFTNGP10.phx.gbl...
for[vbcol=seagreen]
> server
in?
>
|||You should be able to use NT authentication by doing the following:
1. Create a local account on the SQL Server machine that matches each
individual users local machine account. Make sure the password is the same
for both accounts.
2. Create a login within SQL Server for each of these logins.
3. NT authentication should now work.
This could be difficult to administer becaues each time a user changes his
local opassword the pasword has to be changed at the SQL Server machine as
well.
Rand
This posting is provided "as is" with no warranties and confers no rights.
|||Rand,
What if users log into their computer with administrator account?
Necessarily they must use different user names?
Amin
"Rand Boyd [MSFT]" <rboyd@.onlinemicrosoft.com> wrote in message
news:Qxq9sH9gEHA.3340@.cpmsftngxa06.phx.gbl...
> You should be able to use NT authentication by doing the following:
> 1. Create a local account on the SQL Server machine that matches each
> individual users local machine account. Make sure the password is the same
> for both accounts.
> 2. Create a login within SQL Server for each of these logins.
> 3. NT authentication should now work.
> This could be difficult to administer becaues each time a user changes his
> local opassword the pasword has to be changed at the SQL Server machine as
> well.
> Rand
>
> This posting is provided "as is" with no warranties and confers no rights.
>

Domain and windows authentication

Hi,
We have a application that uses windows authentication to connect to sql
server. We have a domain and simply just create a login in sql server for
each user in the domain.
We have setup this application in the company that doesn't have domain.
We're not going to change the source of the application to accept sql server
authentication.
Can we still use the windows authentication to allow the users to log in?
Suppose that each user logs in his computer as administrator of that
computer. Can we prefix these administrators with the name of their
computers to create login in sql server and still use windows
authentication?
Any help would be greatly appreciated.
AminMicrosoft SQL Server support only Domain Authentification, no Machine
Account Authentification (except the local machine of the sql server),
because Workgroups are not trustable.
Hope this helps,
Jens Süßmeyer
"Amin Sobati" <amins@.morva.net> schrieb im Newsbeitrag
news:%23ahXq45gEHA.1764@.TK2MSFTNGP10.phx.gbl...
> Hi,
> We have a application that uses windows authentication to connect to sql
> server. We have a domain and simply just create a login in sql server for
> each user in the domain.
> We have setup this application in the company that doesn't have domain.
> We're not going to change the source of the application to accept sql
server
> authentication.
> Can we still use the windows authentication to allow the users to log in?
> Suppose that each user logs in his computer as administrator of that
> computer. Can we prefix these administrators with the name of their
> computers to create login in sql server and still use windows
> authentication?
> Any help would be greatly appreciated.
> Amin
>|||Jens,
Therefore in workgroups there's no other solution except using sql server
authentication?
"Jens Süßmeyer" <MrIgel[RejectSpam|RemoveBracket]@.gmx.de> wrote in message
news:OCvmQg7gEHA.2764@.TK2MSFTNGP11.phx.gbl...
> Microsoft SQL Server support only Domain Authentification, no Machine
> Account Authentification (except the local machine of the sql server),
> because Workgroups are not trustable.
> Hope this helps,
> Jens Süßmeyer
>
> "Amin Sobati" <amins@.morva.net> schrieb im Newsbeitrag
> news:%23ahXq45gEHA.1764@.TK2MSFTNGP10.phx.gbl...
> > Hi,
> > We have a application that uses windows authentication to connect to sql
> > server. We have a domain and simply just create a login in sql server
for
> > each user in the domain.
> > We have setup this application in the company that doesn't have domain.
> > We're not going to change the source of the application to accept sql
> server
> > authentication.
> > Can we still use the windows authentication to allow the users to log
in?
> > Suppose that each user logs in his computer as administrator of that
> > computer. Can we prefix these administrators with the name of their
> > computers to create login in sql server and still use windows
> > authentication?
> > Any help would be greatly appreciated.
> > Amin
> >
> >
>|||You should be able to use NT authentication by doing the following:
1. Create a local account on the SQL Server machine that matches each
individual users local machine account. Make sure the password is the same
for both accounts.
2. Create a login within SQL Server for each of these logins.
3. NT authentication should now work.
This could be difficult to administer becaues each time a user changes his
local opassword the pasword has to be changed at the SQL Server machine as
well.
Rand
This posting is provided "as is" with no warranties and confers no rights.|||Rand,
What if users log into their computer with administrator account?
Necessarily they must use different user names?
Amin
"Rand Boyd [MSFT]" <rboyd@.onlinemicrosoft.com> wrote in message
news:Qxq9sH9gEHA.3340@.cpmsftngxa06.phx.gbl...
> You should be able to use NT authentication by doing the following:
> 1. Create a local account on the SQL Server machine that matches each
> individual users local machine account. Make sure the password is the same
> for both accounts.
> 2. Create a login within SQL Server for each of these logins.
> 3. NT authentication should now work.
> This could be difficult to administer becaues each time a user changes his
> local opassword the pasword has to be changed at the SQL Server machine as
> well.
> Rand
>
> This posting is provided "as is" with no warranties and confers no rights.
>

Domain and windows authentication

Hi,
We have a application that uses windows authentication to connect to sql
server. We have a domain and simply just create a login in sql server for
each user in the domain.
We have setup this application in the company that doesn't have domain.
We're not going to change the source of the application to accept sql server
authentication.
Can we still use the windows authentication to allow the users to log in?
Suppose that each user logs in his computer as administrator of that
computer. Can we prefix these administrators with the name of their
computers to create login in sql server and still use windows
authentication?
Any help would be greatly appreciated.
AminMicrosoft SQL Server support only Domain Authentification, no Machine
Account Authentification (except the local machine of the sql server),
because Workgroups are not trustable.
Hope this helps,
Jens Smeyer
"Amin Sobati" <amins@.morva.net> schrieb im Newsbeitrag
news:%23ahXq45gEHA.1764@.TK2MSFTNGP10.phx.gbl...
> Hi,
> We have a application that uses windows authentication to connect to sql
> server. We have a domain and simply just create a login in sql server for
> each user in the domain.
> We have setup this application in the company that doesn't have domain.
> We're not going to change the source of the application to accept sql
server
> authentication.
> Can we still use the windows authentication to allow the users to log in?
> Suppose that each user logs in his computer as administrator of that
> computer. Can we prefix these administrators with the name of their
> computers to create login in sql server and still use windows
> authentication?
> Any help would be greatly appreciated.
> Amin
>|||Jens,
Therefore in workgroups there's no other solution except using sql server
authentication?
"Jens Smeyer" <MrIgel[RejectSpam|RemoveBracket]@.gmx.de> wrote in messa
ge
news:OCvmQg7gEHA.2764@.TK2MSFTNGP11.phx.gbl...
> Microsoft SQL Server support only Domain Authentification, no Machine
> Account Authentification (except the local machine of the sql server),
> because Workgroups are not trustable.
> Hope this helps,
> Jens Smeyer
>
> "Amin Sobati" <amins@.morva.net> schrieb im Newsbeitrag
> news:%23ahXq45gEHA.1764@.TK2MSFTNGP10.phx.gbl...
for[vbcol=seagreen]
> server
in?[vbcol=seagreen]
>|||You should be able to use NT authentication by doing the following:
1. Create a local account on the SQL Server machine that matches each
individual users local machine account. Make sure the password is the same
for both accounts.
2. Create a login within SQL Server for each of these logins.
3. NT authentication should now work.
This could be difficult to administer becaues each time a user changes his
local opassword the pasword has to be changed at the SQL Server machine as
well.
Rand
This posting is provided "as is" with no warranties and confers no rights.|||Rand,
What if users log into their computer with administrator account?
Necessarily they must use different user names?
Amin
"Rand Boyd [MSFT]" <rboyd@.onlinemicrosoft.com> wrote in message
news:Qxq9sH9gEHA.3340@.cpmsftngxa06.phx.gbl...
> You should be able to use NT authentication by doing the following:
> 1. Create a local account on the SQL Server machine that matches each
> individual users local machine account. Make sure the password is the same
> for both accounts.
> 2. Create a login within SQL Server for each of these logins.
> 3. NT authentication should now work.
> This could be difficult to administer becaues each time a user changes his
> local opassword the pasword has to be changed at the SQL Server machine as
> well.
> Rand
>
> This posting is provided "as is" with no warranties and confers no rights.
>