|
Sounds like a school question. All data and schemas are deleted, however views won't be removed, you may get a warning however and the delete won't work if you have SCHEMABINDING in your views. Constraints will stop the delete working too, so they'll need to be removed from other questions.
Try deleting a table, that's the easiest way to find out.
|
|
|
|
|
Hi,
I have a couple of VBA modules I need to convert to a SQL 2005 udf (or a C# class if that is abetter place for it!).
The VBA code is below:
Function RMSBetaDist(x, alpha, beta, rate)
'Main function where the cumulative Beta distribution is assembled
datasize = Range("Datsize")
Dim bt() As Double
Dim RMSBeta() As Double
Dim i As Integer
ReDim bt(datasize)
ReDim RMSBeta(datasize)
For i = 1 To datasize
If x(i, 1) < 0 Or x(i, 1) > 1 Then
'Error = MsgBox("There is a problem with the x value of the beta function", vbOKOnly)
'GoTo Abend
x(i, 1) = 1
End If
If x(i, 1) = 0 Then
bt(i) = 0
RMSBeta(i) = 0
GoTo Nextarray
ElseIf x(i, 1) = 1 Then
bt(i) = 0
RMSBeta(i) = 1
GoTo Nextarray
Else
bt(i) = Exp(RMSGammaln(alpha(i, 1) + beta(i, 1)) - RMSGammaln(alpha(i, 1)) - RMSGammaln(beta(i, 1)) + alpha(i, 1) * Log(x(i, 1)) + beta(i, 1) * Log(1 - x(i, 1)))
End If
If x(i, 1) < (alpha(i, 1) + 1) / (alpha(i, 1) + beta(i, 1) + 2) Then
RMSBeta(i) = bt(i) * RMSBetaCF(x(i, 1), alpha(i, 1), beta(i, 1)) / alpha(i, 1)
Else 'symmetry relation I(a,b)=1-I(b,a) where I() is the incomplete beta function
RMSBeta(i) = 1 - bt(i) * RMSBetaCF(1 - x(i, 1), beta(i, 1), alpha(i, 1)) / beta(i, 1)
End If
Nextarray:
RMSBetaDist = RMSBetaDist + rate(i) * (1 - RMSBeta(i))
Next i
Abend:
End Function
Function RMSGammaln(xg) 'Lanczos gamma approximation
'Used in the Beta distribution approximation
Dim y, temp, serial, PI, small As Double
Dim coeff(6) As Double
Dim j As Integer
PI = 3.14159265358979
coeff(0) = 76.18009173
coeff(1) = -86.50532033
coeff(2) = 24.01409822
coeff(3) = -1.231739516
coeff(4) = 0.00120858003
coeff(5) = -0.00000536382
small = 0
If xg < 1 Then
small = xg
y = xg - 1
Else
y = xg - 1
End If
temp = y + 5.5
temp = temp - (y + 0.5) * Log(temp)
serial = 1
For j = 0 To 5
y = y + 1
serial = serial + coeff(j) / y
Next j
If small <> 0 Then 'formula for values of x < 1
RMSGammaln = -temp + Log(Sqr(2 * PI) * serial)
Else
RMSGammaln = -temp + Log(Sqr(2 * PI) * serial)
End If
End Function
Function RMSBetaCF(x2, alpha2, beta2)
'Used to approximate the integral portion of the cumulative Beta distribution
Dim errorf As Double
Dim qap, qam, qab, em, temp, d As Double
Dim bz, bm, bp, bpp As Double
Dim az, am, ap, app, aold As Double
Dim m, MaxIterations As Integer
errorf = 0.0000001
MaxIterations = 1000
bm = 1
az = 1
am = 1
qab = alpha2 + beta2
qap = alpha2 + 1
qam = alpha2 - 1
bz = 1 - qab * x2 / qap
For m = 1 To MaxIterations
em = m
temp = em + em
d = em * (beta2 - em) * x2 / ((qam + temp) * (alpha2 + temp))
ap = az + d * am
bp = bz + d * bm
d = -(alpha2 + em) * (qab + em) * x2 / ((qap + temp) * (alpha2 + temp))
app = ap + d * az
bpp = bp + d * bz
aold = az
am = ap / bpp
bm = bp / bpp
az = app / bpp
bz = 1
If Abs(az - aold) < errorf * Abs(az) Then
GoTo FinalStep
End If
Next m
ErrorStep:
'Error = MsgBox("Either alpha or beta is too big or the maximum iterations are too small for convergence", vbOKOnly, "Problem in RMSBetaCF function")
RMSBetaCF = 1
GoTo Abend
FinalStep:
RMSBetaCF = az
Abend:
'Msg = MsgBox(m & " iterations ", vbOKOnly)
End Function
Any help with this would be greatly appreciated!
Thanks,
Guytz72
|
|
|
|
|
Hi every one,
I'm programming with C# (visual studio 2005) and I have a variable that it's data type is byte array (for example byte[] MyVar),
I have a table in sql server 2005 and it has a field and I'd like to insert MyVar into this field but I don't know what data type should I select in database for this field (for example varbinary,sql_variant ,...)
I mean for insert and retrieve byte[] data type from C# in sql server which data type should I define?do I need any conver in C#?
Please Help me.
Yours Sincerely.
Orchid
|
|
|
|
|
|
what is the deferunt between login and user
|
|
|
|
|
The login is for authentication, the user is for authorization.
|
|
|
|
|
I'm wondering if someone could help me with the SQL I'd need to accomplish the following: I have a db with a number of text fields and what I want to do is have a search box in my program that will search all fields for the text entered. For example I have first_name, last_name, alias, etc. and let's say I enter "Jim" in the search field. I want to be able to search all the fields (first_name, last_name, etc) for that term. Is this possible? I'd also like to use the LIKE operator so the text doesn't have to be exact.
Thanks!
- Aaron
|
|
|
|
|
Maybe something like this:
Select * from table where first_name like '%searchString%' or last_name like '%searchString%' or ....
Or
Select * from table where first_name + last_name + .... like '%searchString%'
--
Don't take life seriously because you can't come out of it alive.
-Warren Miller
|
|
|
|
|
That seems to work quite well. Wondering if you could help with another question...how would I make the search string dynamic, as in I want to be able to pass in the value as a paramter...can I do this, if so what's the syntax?
Thanks very much for the help.
- Aaron
|
|
|
|
|
I did not get it. Could you explain a little more about what you want to do?
--
Don't take life seriously because you can't come out of it alive.
-Warren Miller
|
|
|
|
|
Sure. This is basically what my T-SQL looks like:
SELECT * FROM dbo.Books
WHERE title LIKE '%search%' OR author LIKE '%search%' What I want to do is be able to pass in "search" as a parameter. I'm not sure how to do this though because if I remove the quotes around the search sting and add the @ in front of it, I get a syntax error. I hope that's clearer.
Thanks again for the help.
- Aaron
|
|
|
|
|
Maybe something like this:
Declare @a varchar(50)<br />
<br />
SELECT * FROM dbo.Books<br />
WHERE title LIKE '%' + @a + '%' OR author LIKE '%' + @a + '%'
--
Don't take life seriously because you can't come out of it alive.
-Warren Miller
|
|
|
|
|
Hello! I have been using Datasets and DataAdapters by dragging and dropping on my form. Now I have created a public class and created a dataset by code and filled it wit a Dataadapter. Dataset contains one table "DEPARTMENT" with columns "D_ID" and "D_NAME". Dataset is filled and contains data but when in windows form i tried to bind a combobox to that table it creates problems.
1) dim ClassObj as new DSClass
2)CobmoBox1.datasource = ClassObj.Dataset1.Tables("DEPARTMENT")
3)CobmoBox1.DisplayMember = ?????????????????????????
4)CobmoBox1.DisplayMember = ?????????????????????????
Lines 3,4 creates problems, Please guide me
as900197
|
|
|
|
|
One should be DisplayMember (the column that you want displayed in your combo), the other should be ValueMember (the column that represents the data you want to store).
For example, if you have a table with columns ID and Description, you could set your DisplayMember to 'ID' and your ValueMember to 'Description'.
On your form, you will see the value in the Description displayed in your combo but you will actually store the corresponding ID when updating your DataSet.
CobmoBox1.DisplayMember = "ID"
CobmoBox1.ValueMember = "Description"
Steve
|
|
|
|
|
Thanks Steve!
It was so little mistake and i get so depressed....
Thank you
as900197
|
|
|
|
|
You are welcome.
Upon reading my answer again, I actually got the values the wrong way round!
You would normally have the DisplayMember = "Description" and the ValueMember = "ID".
Steve
|
|
|
|
|
MS ACCESS HELP Listing -> "If the DataType property is set to Text, enter a number from 0 to 255. "
Anybody know how to deal whit this, to make it higher than 255?
Or maybe how to set Memo type at least?
Regards!
|
|
|
|
|
Access' text datatype (Varchar in oledb terms) is limited to 255 characters (unicode).
the 'memo' field type (LongVarChar) holds up to 63,999 characters.
You set the field datatype when you create the table. Some databases allow the type to be changed
with "Alter table". There are restrictions on what changes can be made whithout losing data, not sure what access supports.
|
|
|
|
|
Rob Graham wrote: You set the field datatype when you create the table.
It's obvious;)
Rob Graham wrote: There are restrictions on what changes can be made whithout losing data
There is no data in table, and the goal is, how to set the memo datatype?
There is no option to choose memo, so how to do it?
Aby ideas?
Regards
|
|
|
|
|
eMtek wrote: There is no option to choose memo, so how to do it?
In the Table Designer, next to the Field Name is a Data Type column. Click in it, and you will have a drop down arrow on the right side. Click it, and choose Memo. It's obvious.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
EricDV wrote: Click it, and choose Memo.
Yeah I know it's obvious;P
But..., the problem was with translation (in mine Access "memo" is as a "note") used in Access. Datatype's name in any way points to memo datatype for me. So, I was confused, but now I konow.
Thanks
|
|
|
|
|
Hi guys,
Heres my problem, i created a stored procedure that takes a person's ID number as a parameter
and says if the id number is Valid or Invalid. So basically after it has done the necessary calculation, i just state at the end to get an output:
If @CalcID = @ControlDigit
Select 'Valid'
Else
Select 'IN-Valid'
Now, in another sql script, i have a select statement to get all members, display the fields i need where where the members id's are invalid, basically like this :
Select Name,Email,Phone
from Members
Where ValidateIDNum Members.IDNum = 'IN-Valid'
ValidateIDNum is the procedure i stated above.
but kept getting errors, complaining about incorrect syntax near ValidateIDNum
Is this the right way, to do this type of work, also i tried the same work around using functions but still to no avail.
please help.
Thank You In Advance.
-- modified at 8:53 Wednesday 13th September, 2006
|
|
|
|
|
Why not do it without the function
Select Name,Email,Phone
from Members
Where Members.IDNum = @ControlDigit
only two letters away from being an asset
|
|
|
|
|
well i dont think that will work,
because, the control digit is calculated from the ID Number by a twenty step process, and this calculation should equal the last digit of the ID Number.
I want to break this process up, since we will probably be using it alot.
Im just trying to change the whole thing without procedures and with a cursor loop.
|
|
|
|
|
Use a function, and put parenthesis around the parameters you are sending in.
Select Name,Email,Phone
from Members
Where ValidateIDNum<code><big>(</big></code>Members.IDNum<code><big>)</big></code> = 'IN-Valid'
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|