Showing posts with label create. Show all posts
Showing posts with label create. Show all posts

Friday, March 30, 2012

HELP!!!

please help me create the table for the data in the following data lines
after this
i am out of my wits to thing for what data type to use. because for
everything i tried i got the error below the column name will be for the
table i appreciate a lot if someone can help me .
column 1 column 2 column 3
OMIM_Name No.of av Description
100650 .0001 ALCOHOL INTOLERANCE, ACUTE ACETALDEHYDE DEHYDROGENASE 2, ALLELE
2, INCLUDED; ALDH2*2, INCLUDED ALDH2, GLU487LYS The ALDH2*2-encoded protein
has a change from glutamic acid (glutamate) to lysine at residue 487 (Yoshid
a
et al., 1984). Hempel et al. (1985) and Hsu et al. (1985) also showed that
the catalytic deficiency in mitochondrial ALDH in Orientals can be traced to
a structural point mutation at amino acid position 487 of the polypeptide. A
substitution of lysine for glutamic acid results from a transition of G-C to
A-T. To study the mechanism by which the ALDH2*2 allele exerts its dominant
effect in decreasing ALDH2 activity in liver extracts and producing cutaneou
s
flushing when the subject drinks alcohol, Xiao et al. (1995) cloned ALDH2*1
cDNA and generated the ALDH2*2 allele by site-directed mutagenesis. These
cDNAs were transduced using retroviral vectors into HeLa and CV1 cells, whic
h
do not express ALDH2. The normal allele directed synthesis of immunoreactive
ALDH2 protein with the expected isoelectric point and increased aldehyde
dehydrogenase activity. The ALDH2*2 allele directed synthesis of mRNA and
immunoreactive protein, but the protein lacked enzymatic activity. When
ALDH2*1-expressing cells were transduced with ALDH2*2 vectors, both mRNAs
were expressed and immunoreactive proteins with isoelectric points ranging
between those of the 2 gene products were present, indicating that the
subunits formed heteromers. ALDH2 activity in these cells was reduced below
that of the parental ALDH2*1-expressing cells. Thus, the authors concluded
that ALDH2*2 allele is sufficient to cause ALDH2 deficiency in vitro. Xiao e
t
al. (1996) referred to the ALDH2 enzyme encoded by the ALDH2*1 allele (the
wildtype form) as ALDH2E and the enzyme subunit encoded by ALDH2*2 as ALDH2K
.
They found that the ALDH2E enzyme was very stable, with a half-life of at
least 22 hours. ALDH2K, on the other hand, had an enzyme half-life of only 1
4
hours. In cells expressing both subunits, most of the subunits assemble as
heterotetramers, and these enzymes had a half-life of 13 hours. Thus, the
effect of ALDH2K on enzyme turnover is dominant. Their studies indicated tha
t
ALDH2*2 exerts its dominant effect both by interfering with the catalytic
activity of the enzyme and by increasing its turnover. Because genetic
epidemiologic studies have suggested a mechanism by which homozygosity for
the ALDH2*2 allele inhibits the development of alcoholism in Asians, Peng et
al. (1999) recruited 18 adult Han Chinese men, matched by age, body-mass
index, nutritional state, and homozygosity at the ALDH2 gene loci from a
population of 273 men. Six individuals were chosen for each of the 3 ALDH2
allotypes, i.e., 2 homozygotes and 1 heterozygote. Following a low dose of
ethanol, homozygous ALDH2*2 individuals were found to be strikingly
responsive with pronounced cardiovascular hemodynamic effects as well as
subjective perception of general discomfort for as long as 2 hours following
ingestion. Among 71 Japanese nondrinkers and 268 drinkers of alcohol, Liu et
al. (2005) found that drinkers had a significantly higher frequency of the
487glu allele. Individuals with the 487lys allele had an increased risk of
alcohol-induced flushing (odds ratio of 33.0)
100690 .0001 MYASTHENIC SYNDROME, CONGENITAL, SLOW-CHANNEL CHRNA1, ASN217LYS
In a 30-year-old woman with slow-channel congenital myasthenic syndrome
(601462), Engel et al. (1996) identified a heterozygous 651C-G transversion
in exon 6 of the CHRNA1 gene, resulting in an asn217-to-lys (N217K)
substitution at a conserved residue in the M1 transmembrane domain. The
mutation cosegregated with the disease through 3 generations. Functional
expression studies showed that the N217K mutation slowed the rate of AChR
channel closure, increased the apparent affinity for ACh, and enhanced
desensitization. Cationic overload of the postsynaptic region caused an
endplate myopathy
100690 .0002 MYASTHENIC SYNDROME, CONGENITAL, SLOW-CHANNEL CHRNA1, VAL156MET
In a patient with SCCMS (601462), Croxen et al. (1997) identified a
heterozygous 466G-A transition in the CHRNA1 gene, resulting in a
val156-to-met (V156M) substitution in a putative ACh-binding region of the
protein. Functional studies suggested that the V156M mutation stabilizes the
open state of the AChR channel
100690 .0003 MYASTHENIC SYNDROME, CONGENITAL, SLOW-CHANNEL CHRNA1, THR254ILE
In a 60-year-old woman whose myasthenic syndrome (SCCMS; 601462) had first
become symptomatic at the age of 16, Croxen et al. (1997) identified a
heterozygous 761C-T transition in the CHRNA1 gene, resulting in a
thr254-to-ile (T254I) substitution in the M2 transmembrane domain which line
s
the AChR channel pore. The patient was previously reported by Chauplannaz an
d
Bady (1994). Functional expression studies suggested that the T254I mutation
stabilized the open state of the AChR channel
C:\Disease_Database_TongBoon_Dec2005_Mar
ch2006\Results>bcp OMIM.dbo.av in
AVoutp
ut_less_then_100.txt -c -T
Starting copy...
SQLState = 22001, NativeError = 0
Error = [Microsoft][SQL Native Client]String data, right truncation
SQLState = 22001, NativeError = 0
Error = [Microsoft][SQL Native Client]String data, right truncation
SQLState = 22001, NativeError = 0
Error = [Microsoft][SQL Native Client]String data, right truncation
SQLState = 22001, NativeError = 0
Error = [Microsoft][SQL Native Client]String data, right truncation
SQLState = 22001, NativeError = 0
Error = [Microsoft][SQL Native Client]String data, right truncation
SQLState = 22001, NativeError = 0
Error = [Microsoft][SQL Native Client]String data, right truncation
SQLState = 22001, NativeError = 0
Error = [Microsoft][SQL Native Client]String data, right truncation
SQLState = 22001, NativeError = 0
Error = [Microsoft][SQL Native Client]String data, right truncation
SQLState = 22001, NativeError = 0
Error = [Microsoft][SQL Native Client]String data, right truncation
SQLState = 22001, NativeError = 0
Error = [Microsoft][SQL Native Client]String data, right truncation
BCP copy in failedGood god! Please post a description of the source data, rather than posting
a
big blob. Also see http://www.aspfaq.com/etiquette.asp?id=5006 for some
pointers.
How are you importing this? Where are you importing it to? Where is it from?
What is the structure of the source, and what of the destination?
ML
http://milambda.blogspot.com/|||What vesrion are you using?
"urgent" <urgent@.discussions.microsoft.com> wrote in message
news:89CCAC1D-8F47-4D01-A35D-25254C26BD9B@.microsoft.com...
> please help me create the table for the data in the following data lines
> after this
> i am out of my wits to thing for what data type to use. because for
> everything i tried i got the error below the column name will be for the
> table i appreciate a lot if someone can help me .
>
> column 1 column 2 column 3
> OMIM_Name No.of av Description
> 100650 .0001 ALCOHOL INTOLERANCE, ACUTE ACETALDEHYDE DEHYDROGENASE 2,
> ALLELE
> 2, INCLUDED; ALDH2*2, INCLUDED ALDH2, GLU487LYS The ALDH2*2-encoded
> protein
> has a change from glutamic acid (glutamate) to lysine at residue 487
> (Yoshida
> et al., 1984). Hempel et al. (1985) and Hsu et al. (1985) also showed that
> the catalytic deficiency in mitochondrial ALDH in Orientals can be traced
> to
> a structural point mutation at amino acid position 487 of the polypeptide.
> A
> substitution of lysine for glutamic acid results from a transition of G-C
> to
> A-T. To study the mechanism by which the ALDH2*2 allele exerts its
> dominant
> effect in decreasing ALDH2 activity in liver extracts and producing
> cutaneous
> flushing when the subject drinks alcohol, Xiao et al. (1995) cloned
> ALDH2*1
> cDNA and generated the ALDH2*2 allele by site-directed mutagenesis. These
> cDNAs were transduced using retroviral vectors into HeLa and CV1 cells,
> which
> do not express ALDH2. The normal allele directed synthesis of
> immunoreactive
> ALDH2 protein with the expected isoelectric point and increased aldehyde
> dehydrogenase activity. The ALDH2*2 allele directed synthesis of mRNA and
> immunoreactive protein, but the protein lacked enzymatic activity. When
> ALDH2*1-expressing cells were transduced with ALDH2*2 vectors, both mRNAs
> were expressed and immunoreactive proteins with isoelectric points ranging
> between those of the 2 gene products were present, indicating that the
> subunits formed heteromers. ALDH2 activity in these cells was reduced
> below
> that of the parental ALDH2*1-expressing cells. Thus, the authors concluded
> that ALDH2*2 allele is sufficient to cause ALDH2 deficiency in vitro. Xiao
> et
> al. (1996) referred to the ALDH2 enzyme encoded by the ALDH2*1 allele (the
> wildtype form) as ALDH2E and the enzyme subunit encoded by ALDH2*2 as
> ALDH2K.
> They found that the ALDH2E enzyme was very stable, with a half-life of at
> least 22 hours. ALDH2K, on the other hand, had an enzyme half-life of only
> 14
> hours. In cells expressing both subunits, most of the subunits assemble as
> heterotetramers, and these enzymes had a half-life of 13 hours. Thus, the
> effect of ALDH2K on enzyme turnover is dominant. Their studies indicated
> that
> ALDH2*2 exerts its dominant effect both by interfering with the catalytic
> activity of the enzyme and by increasing its turnover. Because genetic
> epidemiologic studies have suggested a mechanism by which homozygosity for
> the ALDH2*2 allele inhibits the development of alcoholism in Asians, Peng
> et
> al. (1999) recruited 18 adult Han Chinese men, matched by age, body-mass
> index, nutritional state, and homozygosity at the ALDH2 gene loci from a
> population of 273 men. Six individuals were chosen for each of the 3 ALDH2
> allotypes, i.e., 2 homozygotes and 1 heterozygote. Following a low dose of
> ethanol, homozygous ALDH2*2 individuals were found to be strikingly
> responsive with pronounced cardiovascular hemodynamic effects as well as
> subjective perception of general discomfort for as long as 2 hours
> following
> ingestion. Among 71 Japanese nondrinkers and 268 drinkers of alcohol, Liu
> et
> al. (2005) found that drinkers had a significantly higher frequency of the
> 487glu allele. Individuals with the 487lys allele had an increased risk of
> alcohol-induced flushing (odds ratio of 33.0)
> 100690 .0001 MYASTHENIC SYNDROME, CONGENITAL, SLOW-CHANNEL CHRNA1,
> ASN217LYS
> In a 30-year-old woman with slow-channel congenital myasthenic syndrome
> (601462), Engel et al. (1996) identified a heterozygous 651C-G
> transversion
> in exon 6 of the CHRNA1 gene, resulting in an asn217-to-lys (N217K)
> substitution at a conserved residue in the M1 transmembrane domain. The
> mutation cosegregated with the disease through 3 generations. Functional
> expression studies showed that the N217K mutation slowed the rate of AChR
> channel closure, increased the apparent affinity for ACh, and enhanced
> desensitization. Cationic overload of the postsynaptic region caused an
> endplate myopathy
> 100690 .0002 MYASTHENIC SYNDROME, CONGENITAL, SLOW-CHANNEL CHRNA1,
> VAL156MET
> In a patient with SCCMS (601462), Croxen et al. (1997) identified a
> heterozygous 466G-A transition in the CHRNA1 gene, resulting in a
> val156-to-met (V156M) substitution in a putative ACh-binding region of the
> protein. Functional studies suggested that the V156M mutation stabilizes
> the
> open state of the AChR channel
> 100690 .0003 MYASTHENIC SYNDROME, CONGENITAL, SLOW-CHANNEL CHRNA1,
> THR254ILE
> In a 60-year-old woman whose myasthenic syndrome (SCCMS; 601462) had first
> become symptomatic at the age of 16, Croxen et al. (1997) identified a
> heterozygous 761C-T transition in the CHRNA1 gene, resulting in a
> thr254-to-ile (T254I) substitution in the M2 transmembrane domain which
> lines
> the AChR channel pore. The patient was previously reported by Chauplannaz
> and
> Bady (1994). Functional expression studies suggested that the T254I
> mutation
> stabilized the open state of the AChR channel
>
> C:\Disease_Database_TongBoon_Dec2005_Mar
ch2006\Results>bcp OMIM.dbo.av in
> AVoutp
> ut_less_then_100.txt -c -T
> Starting copy...
> SQLState = 22001, NativeError = 0
> Error = [Microsoft][SQL Native Client]String data, right truncation
> SQLState = 22001, NativeError = 0
> Error = [Microsoft][SQL Native Client]String data, right truncation
> SQLState = 22001, NativeError = 0
> Error = [Microsoft][SQL Native Client]String data, right truncation
> SQLState = 22001, NativeError = 0
> Error = [Microsoft][SQL Native Client]String data, right truncation
> SQLState = 22001, NativeError = 0
> Error = [Microsoft][SQL Native Client]String data, right truncation
> SQLState = 22001, NativeError = 0
> Error = [Microsoft][SQL Native Client]String data, right truncation
> SQLState = 22001, NativeError = 0
> Error = [Microsoft][SQL Native Client]String data, right truncation
> SQLState = 22001, NativeError = 0
> Error = [Microsoft][SQL Native Client]String data, right truncation
> SQLState = 22001, NativeError = 0
> Error = [Microsoft][SQL Native Client]String data, right truncation
> SQLState = 22001, NativeError = 0
> Error = [Microsoft][SQL Native Client]String data, right truncation
> BCP copy in failed
>|||
this is my new nick i am urgen log in with another email thi post is being
transfer to another title call trouble with bcp ....2005

help!! Filter !! Somone has to know!

Am I just not explaining myself or does nobody use SSRS 2005 or if so not create very complex filtering requirements out there yet? Can I get some responses hopefully? I can't find anything out on the net about how to do what I'm trying to do here:

HERE IS A PRINT SCREEN OF THE FILTER TAB WHERE i WANT THIS ALL TO HAPPEN...PROPERTIES OF MY TABLE:

http://www.photopizzaz.biz/filtertab_ssrs2005table.jpg

essentially I want this check to filter records on my table...match to this criteria from my dataset:

In SSRS 2005, how can I add this check (what do I have to put in the Expression, operator, and value in filters tab of table properties) to my table filter to bringin only customers that match one of the 2 main OR statements?

essentially I want this check to filter records on my table...match to this criteria from my dataset:

(Fields!Branch.Value = '00002' and
Fields!CustomerNumber.Value = '0000002' or
Fields!CustomerNumber.Value = '0000003' or
Fields!CustomerNumber.Value = '0000004' or
Fields!CustomerNumber.Value = '0000155' or
Fields!CustomerNumber.Value = '0000156' or
Fields!CustomerNumber.Value = '0000159' or
Fields!CustomerNumber.Value = '0000160' or
Fields!CustomerNumber.Value = '0000161' or
Fields!CustomerNumber.Value = '0000118' or
Fields!CustomerNumber.Value = '0000153' or
Fields!CustomerNumber.Value = '0000152' or
Fields!CustomerNumber.Value = '0000108' or
Fields!CustomerNumber.Value = '0000158' or
Fields!CustomerNumber.Value = '0000133')

OR

(Fields!Branch.Value <> '00002' and
Fields!CustomerNumber.Value = '0000053' or
Fields!CustomerNumber.Value = '0000058' or
Fields!CustomerNumber.Value = '0000072' or
Fields!CustomerNumber.Value = '0000073' or
Fields!CustomerNumber.Value = '0000079' or
Fields!CustomerNumber.Value = '0000080' or
Fields!CustomerNumber.Value = '0000143' or
Fields!CustomerNumber.Value = '0000146' or
Fields!CustomerNumber.Value = '0000157' or
Fields!CustomerNumber.Value = '0000135')

See the post from Robert Bruckner (MSFT) titled Answer Re: And/or filter field not enabled in the group filter tab: http://forums.microsoft.com/msdn/showpost.aspx?postid=227116

This post was very helpful to me in building some complex "and/or" filtering on tables and groups, describing what values to put in the expression, type, and value fields.

Good luck...

-Chris

Wednesday, March 28, 2012

Help! Trying to create a trigger in SQL 2000...

Hello All!

I am trying to create a trigger that upon insertion into my table an email will be sent to that that recipeinent with a image attached ( like a coupon)That comes from a different table, problem is, It will not allow me to send the email ( using xp_sendmail) with the coupon attached. I am using varbinary for the coupon and nvarchar for the rest to be sent, I get an error that Invaild operator for data type. operator equals add, type equals varchar.

Looks basically like this(This is my test tables):

CREATE TRIGGER EileenTest ON OrgCouponTestMain
FOR Insert
AS
declare @.emailaddress varchar(50)
declare @.body varchar(300)
declare @.fname varchar(50)
declare @.coupon varbinary(4000)

if update(emailaddress)
begin

Select
@.emailaddress=(select EmailAddress from OrgCouponTestMain as str),
@.fname=(select EmailAddress from OrgCouponTestMain as str)
@.Coupon=(select OrgCoupon1 from OrgCouponTest2 as image)

SET @.body= 'Thank you' +' '+ @.fname +' '+ ',Here is the coupon you requested' +' ' + @.coupon
exec master.dbo.xp_sendmail
@.recipients = @.emailaddress,
@.subject = 'Coupon',
@.message = @.body
END

Hello my friend,

Try the following: -

SET @.body = 'Thank you ' + @.fname + ', Here is the coupon you requested ' + CAST(@.coupon AS VARCHAR(8000))

Kind regards

Scotty

|||

Hi there,

I've recently developed a functionality at my work place that is very similar to the one you need.

My suggestion is that you make things other way (very much simpler i think):

Instead of coding in T-SQL, you can develop your application in any .NET language. I suggest you to develop a Web Service or an ASP.NET page that retrieves the "destinations" from the SQL Server, loads the coupon and sends it to them.

Then you just have to develop a very simple COM Class that the ONLY thing it does is calling the Web Service (our ASP.NET page) you developed. There is many documentation on the Web on how to call a COM Class from an SQL Trigger / Job.

It's a bit tricky at the beggining but when you figure it out, it's easy as a walk in the park. And remember, when you need to change your application, you just have to change the .NET Web Service that it's called by the COM Class (much more friendly than coding in T-SQL).

Even if this isn't a web server, you can always create a website on localhost to host the service/page.

Hope I've helped you out!

gonzzas

|||

Thank you both for your input, Ask scotty, it didn't work, got the email out but no image, and of course there is that other option, which unless i can figure this out i will be doing instead. Thank you!

|||

So anyone else have an idea? This is what comes up in the email message, notice the symbols instead of the image...

Thank you Eileen, Here is the coupon you requested /

|||

Anyone else have a suggestion? Here is what comes in the email , notice the symbols instead of the image:

Thank you Eileen, Here is the coupon you requested /

|||

Hi,

The problem is focused on how to display the image which saved as Image Data type in database. Because what you get from database directly is binary steam of the image, it can't be displayed in your email directly. What I suggest is pass the steam (and other information ) from Stored Procedure to .NET, and use SqlDataReader to read the image and send the mail to your customer.

HOW to Retrieve an image from sql server and display it in ASP.net using "imagemap or image" ?https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=531518&SiteID=1

Hope it can helps. Thanks.

sql

Help! this is so basic for some of you!

HI! i am a college student and i need help with my PL/SQL project. we have to create a package with subprograms (1 private and 1 public).

the public function will accept a SSN as a parameter and return a formatted SSN (###-##-####) or an error message that identifies what test failed and why the SSN was not good, no testing will occur in the public function.

the public function will call a private function/procedure in the same package. the private program unit will test a parameter that is passed in by the public function:
--the parameter passed in may not contain any alphas
--may not contain all the same numbers (111-11-1111)
--will accept only the following values as good:
123456789
123-45-6789
123-456789
12345-6789

create a table called Test_SSN with one column (varchar2(11)). create a database trigger that calls your packaged function to test the SSN before inserting it in the table.

If you have ANY suggestions, PLEASE RESPOND!!! My teacher gave me a hint to use counter:=counter + 1. HELP HELP HELP!!!Post what you have managed to do yourself, and people can offer suggestions and corrections. There is no educational value in subcontracting your homework to others!|||Sorry, i wasnt trying to get someone to do it for me, ok, i have made a couple of tests, they are anonymous blocks right now, but they will be part of my functions in my package..

DECLARE
SSN VARCHAR(100) := '123-45-6789';
BEGIN
IF LENGTH(SSN) <9 OR LENGTH(SSN) >11 THEN
RAISE_APPLICATION_ERROR(-20001,'SSN MUST BE BETWEEN 9 AND 11 CHARACTERS');
ELSE
IF LENGTH(SSN) = 11 AND
SUBSTR(SSN, '-') = 4 AND
SUBSTR(SSN, '-',2) =7 THEN
DSMS_OUTPUT.PUT_LINE('SSN FORMAT CORRECT');
ELSE
IF LENGTH (SSN) = 10 AND
SUBSTR(SSN, '-') = 4 OR
SUBSTR(SSN, '-') = 6 THEN
DBMS_OUTPUT.PUT_LINE('SSN FORMAT CORRECT');
ELSE
IF LENGTH = 9 AND
SSN NOT LIKE '%-%' THEN
DBMS_OUTPUT.PUT_LINE('SSN FORMAT CORRECT');
ELSE RAISE_APPLICATION_ERROR(-20001,'HYPHEN ENTERED
INCORRECTLY');
END IF;
END IF;
END IF;
END IF;
END;
/

To test to make sure the SSN does not contain any alphas, must i repeatedly continue on like this : SSN NOT LIKE '%a%' AND SSN NOT LIKE '%b%' ...... and so on? Any help will be Extremely Appreciated!!|||Originally posted by oraculous
To test to make sure the SSN does not contain any alphas, must i repeatedly continue on like this : SSN NOT LIKE '%a%' AND SSN NOT LIKE '%b%' ...... and so on? Any help will be Extremely Appreciated!!
The TRANSLATE function will be helpful here:

TRANSLATE( ssn, 'x0123456789-', 'x' )

This will translate all digits and '-' to NULL, leaving behind any other (invalid) characters. So if the result is NOT NULL that means there were some invalid characters in the string.

The 'x' is just there as a dummy, to prevent the 3rd argument being '', which doesn't work. It gets translated to 'x', so doesn't affect the result.

You could test and display the invalid chars like this:

v_invalid VARCHAR2(11);
...
v_invalid := TRANSLATE( ssn, 'x0123456789-', 'x' );
if v_invalid is not null then
raise_application_error(-20001,'Invalid chars in SSN: '||v_invalid);
end if;|||thank you so much!! i didnt even think about translate...you are a great help...it is appreciated!!|||Does anyone know how i can use a loop if i use something like TEMP_SSN VARCHAR2 := SUBSTR(SSN,1,3)||SUBSTR(SSN,5,2)||SUBSTR(SSN,8,4) and then use a counter:=counter + 1...??

does anyone know how i could use this or if it would work here instead of using all those [SUBSTR(SSN,1) <> '-' AND].....???

CREATE PROCEDURE SSN_PROC (SSN VARCHAR2)
-- SSN VARCHAR(100) := '123-45-6789';
SSN_INVALID VARCHAR2 (11):=TRANSLATE(SSN,'x0123456789-','x');
TEMP_SSN VARCHAR2;
BEGIN
IF LENGTH(SSN) <9 OR LENGTH(SSN) >11 THEN
RAISE_APPLICATION_ERROR(-20001,'SSN Must Be Between 9 And 11 Characters');
ELSE
IF LENGTH(SSN) = 11 AND
INSTR(SSN, '-') = 4 AND
INSTR(SSN, '-',1,2) =7 AND
SUBSTR(SSN,1) <> '-' AND
SUBSTR(SSN,2) <> '-' AND
SUBSTR(SSN,3) <> '-' AND
SUBSTR(SSN,5) <> '-' AND
SUBSTR(SSN,6) <> '-' AND
SUBSTR(SSN,8) <> '-' AND
SUBSTR(SSN,9) <> '-' AND
SUBSTR(SSN,10) <> '-' AND
SUBSTR(SSN,11) <> '-' THEN
DBMS_OUTPUT.PUT_LINE('SSN Entered Correctly');
ELSE
IF LENGTH (SSN) = 10 AND
INSTR(SSN, '-') = 4 OR
INSTR(SSN, '-') = 6 THEN
DBMS_OUTPUT.PUT_LINE('SSN Entered Correctly');
ELSE
IF LENGTH = 9 AND
SSN NOT LIKE '%-%' THEN
DBMS_OUTPUT.PUT_LINE('SSN Entered Correctly');
ELSE RAISE_APPLICATION_ERROR(-20001,'Hyphen Entered Incorrectly');
IF SSN_INVALID IS NOT NULL THEN
RAISE_APPLICATION_ERROR(-20001,'Invalid Characters In SSN:'||SSN_INVALID);
END IF;
END IF;
END IF;
END IF;
END IF;
END;
/|||You can use a FOR loop:

FOR i IN 1..11 LOOP
IF i NOT IN (4,7) AND SUBSTR(SSN,i,1) = '-' THEN
RAISE_APPLICATION_ERROR(-20001,'Hyphen Entered Incorrectly');
END IF;
END LOOP;

Note the 3rd parameter to SUBSTR, i.e. the length of the substring required. You had SUBSTR(SSN,1) which is the substring from 1 to end of SSN, i.e. is equal to SSN.|||oooOOHH thanks man, you are a great help!!sql

Friday, March 23, 2012

help! question about hardware request for SQL Server and Analysis Services

I built a database with a huge table which has 18 billion lines for 6(or 7) columns.

And in the Analysis Services the table is used to create a dimention and a measure.

One of the other two dimentions is made form a 4000 line table,and the other is

made from a 3 million line table(time dimension table).

The specification of my Server is Windows Server 2003 with Xeon Intel Cpu 5160 @.3.00GHz,

2.99GHz,4.00G RAM.

The problem comes out when i start the processing of Analysis Services.

the "time out" error comes out after 1 hour, however, the performance i need

is completing the Processing for one cube within 10 munites.

I want to know the hardware request to reach my needs and how to speed the

processing of Analysis Services.

Thank you

So, to be clear, you have an 18 billion row fact table, you have built a cube on top of it and you want a full process to complete in 10 minutes?

Chris

|||

Dear Mr

yes! I wanna a full process within 10 minutes.

Can it be done?

thanks in advance

tomigisi

|||

The short answer is no, not if you're using MOLAP storage for your measure group. The best throughput I've ever seen for cube processing with MOLAP storage is around 200000 rows per second, and that was a maximum rather than something that could be consistently achieved throughout the whole process; you should be happy with 60-70000 rows per second if you've got a top-end server and a properly-tuned relational datasource.

I would experiment with using ROLAP or HOLAP storage, or with pre-aggregating your fact table in some way to reduce the overall number of rows.

Sorry,

Chris

|||

We have a monster server: 8 - 3.2GHZ processors, a disk frame that reads/writes 400 MB/sec, 32 GB of ram, etc and we couldn't even process 18 Billion rows that fast. The slowdown is reading rows from the DB, and most likely not the server (unless you have slow disks).

sql

Monday, March 19, 2012

Help! How do I create an SQL database on my machine? + Access -> SQL ?

According to my technical support for web hosting, for database format they only use "MS SQL" operating on a windows system, usualy clients create they're sites on their local machines using "MS SQL".

I'm just wondering....

Is 'MS SQL' free? where can I get it?

I also have the option of creating the site round an access databse but I'm worried about the security issues,

do you think it would be wise to use access?

Is it easy to convert a site written in ASP.NET&ACCESS into a site using ASP.NET&"ms sql"?

because then I could code a site in the former on my machine and then change the code to link to an sql server.when my suport persons talking about "MS SQL" does he actually mean "msde"?

I've been having some trouble with that too:

http://www.gotdotnet.com/Community/MessageBoard/Thread.aspx?id=181961&Page=1#183129|||'MS SQL Server' is not free. The good news are that MS has released a scaled down version of MS Sql Server which is. It's called MSDE (MS Desktop Edition) and is ideal for developing on your local machine, as well as OK for low traffic production servers. Download ithere.|||thanks for the reply andre,

that last post went up before I read your replied,

MSDE wont install because it says I need a strong SA password but I have no idea how to set one up for my account.|||more info, I think i downloaded the wrong package file before "sql2kdesksp3" I'm now downloading sql2ksp3 is that the right onw? is the other stuff I need to download to?|||downloading msde2000a now aswell|||its still having the same SAPWD option,

Is there a detailed explanation anywhere on using the SAPWD switch or have I goy my wires crossed.

Monday, March 12, 2012

Help! Dates and SQL

Hi
I would like to create a SP where it will populate TableA based from TableB.
TableB will be populated on a monthly basis using a DTS and within that I
would like to run the SP to populate TableA.

Can someone here please help me create the sql statements as a starting
point.

TIA!
Bob

TableB (source)
from_date to_date curr_code ex_rate
1/1/2004 1/10/2004 CAD .75000
1/11/2004 1/16/2004 CAD .74321
1/17/2004 2/4/2004 CAD .72222
2/5/2004 2/20/2004 CAD .71111
2/21/2004 2/28/2004 CAD .77888
3/1/2004 3/3/2004 CAD .79002
3/4/2004 3/14/2004 CAD .76803
3/15/2004 3/23/2004 CAD .70022
3/24/2004 4/2/2004 CAD .73365
etc...

TableA (destination):
date curr_code ex_rate
1/2004 CAD 0.738477 calculation:(.75000+
..74321+.72222) / 3
2/2004 CAD 0.737403
(.72222+.71111+.77888) / 3
3/2004 CAD 0.74798
(.79002+.76803+.70022+.73365) / 4
etc.."B" <no_spam@.no_spam.com> wrote in message
news:8bWdnSP-M6T0E_HcRVn-ig@.rcn.net...
> Hi
> I would like to create a SP where it will populate TableA based from
> TableB.
> TableB will be populated on a monthly basis using a DTS and within that I
> would like to run the SP to populate TableA.
> Can someone here please help me create the sql statements as a starting
> point.
> TIA!
> Bob
>
> TableB (source)
> from_date to_date curr_code ex_rate
> 1/1/2004 1/10/2004 CAD .75000
> 1/11/2004 1/16/2004 CAD .74321
> 1/17/2004 2/4/2004 CAD .72222
> 2/5/2004 2/20/2004 CAD .71111
> 2/21/2004 2/28/2004 CAD .77888
> 3/1/2004 3/3/2004 CAD .79002
> 3/4/2004 3/14/2004 CAD .76803
> 3/15/2004 3/23/2004 CAD .70022
> 3/24/2004 4/2/2004 CAD .73365
> etc...
> TableA (destination):
> date curr_code ex_rate
> 1/2004 CAD 0.738477 calculation:(.75000+
> .74321+.72222) / 3
> 2/2004 CAD 0.737403
> (.72222+.71111+.77888) / 3
> 3/2004 CAD 0.74798
> (.79002+.76803+.70022+.73365) / 4
> etc..
>

Here's one possible solution. In future, please post CREATE TABLE and INSERT
statements for your tables and data - other people can then simply cut and
paste into Query Analyzer, and we don't have to guess about data types,
keys, constraints etc.:

http://www.aspfaq.com/etiquette.asp?id=5006

Note that 'date' is a reserved keyword, so you should avoid using it as a
column name - I've used start_of_month instead. See "Reserved Keywords" in
Books Online.

Simon

create table b (
from_date datetime not null,
to_date datetime not null,
curr_code char(3) not null,
ex_rate decimal(6,5) not null,
constraint pk_b primary key (from_date, to_date, curr_code)
)
go
insert into b (from_date, to_date, curr_code, ex_rate)
values ('20040101', '20040110', 'CAD', 0.75000)
insert into b (from_date, to_date, curr_code, ex_rate)
values ('20040111', '20040116', 'CAD', 0.74321)
insert into b (from_date, to_date, curr_code, ex_rate)
values ('20040117', '20040204', 'CAD', 0.72222)
insert into b (from_date, to_date, curr_code, ex_rate)
values ('20040205', '20040220', 'CAD', 0.71111)
insert into b (from_date, to_date, curr_code, ex_rate)
values ('20040221', '20040228', 'CAD', 0.77888)
insert into b (from_date, to_date, curr_code, ex_rate)
values ('20040301', '20040303', 'CAD', 0.79002)
insert into b (from_date, to_date, curr_code, ex_rate)
values ('20040304', '20040314', 'CAD', 0.76803)
insert into b (from_date, to_date, curr_code, ex_rate)
values ('20040315', '20040323', 'CAD', 0.70022)
insert into b (from_date, to_date, curr_code, ex_rate)
values ('20040324', '20040402', 'CAD', 0.73365)
go

select dt.start_of_month, max(b.curr_code) as 'curr_code', avg(b.ex_rate) as
'ex_rate'
from
(
select cast(convert(char(6), from_date, 112) + '01' as datetime) as
'start_of_month', count(*) as 'num'
from b
group by cast(convert(char(6), from_date, 112) + '01' as datetime)
) dt
join b
on dt.start_of_month = cast(convert(char(6), b.from_date, 112) + '01' as
datetime)
or dt.start_of_month = cast(convert(char(6), b.to_date, 112) + '01' as
datetime)
group by dt.start_of_month
go

drop table b
go|||"Simon Hayes" <sql@.hayes.ch> wrote in message
news:416d1418$1_1@.news.bluewin.ch...
> "B" <no_spam@.no_spam.com> wrote in message
> news:8bWdnSP-M6T0E_HcRVn-ig@.rcn.net...
>> Hi
>> I would like to create a SP where it will populate TableA based from
>> TableB.
>> TableB will be populated on a monthly basis using a DTS and within that I
>> would like to run the SP to populate TableA.
>>
>> Can someone here please help me create the sql statements as a starting
>> point.
>>
>> TIA!
>> Bob
>>
>>
>> TableB (source)
>> from_date to_date curr_code ex_rate
>> 1/1/2004 1/10/2004 CAD .75000
>> 1/11/2004 1/16/2004 CAD .74321
>> 1/17/2004 2/4/2004 CAD .72222
>> 2/5/2004 2/20/2004 CAD .71111
>> 2/21/2004 2/28/2004 CAD .77888
>> 3/1/2004 3/3/2004 CAD .79002
>> 3/4/2004 3/14/2004 CAD .76803
>> 3/15/2004 3/23/2004 CAD .70022
>> 3/24/2004 4/2/2004 CAD .73365
>> etc...
>>
>> TableA (destination):
>> date curr_code ex_rate
>> 1/2004 CAD 0.738477 calculation:(.75000+
>> .74321+.72222) / 3
>> 2/2004 CAD 0.737403
>> (.72222+.71111+.77888) / 3
>> 3/2004 CAD 0.74798
>> (.79002+.76803+.70022+.73365) / 4
>> etc..
>>
>>
>>
>>
> Here's one possible solution. In future, please post CREATE TABLE and
> INSERT statements for your tables and data - other people can then simply
> cut and paste into Query Analyzer, and we don't have to guess about data
> types, keys, constraints etc.:
> http://www.aspfaq.com/etiquette.asp?id=5006
> Note that 'date' is a reserved keyword, so you should avoid using it as a
> column name - I've used start_of_month instead. See "Reserved Keywords" in
> Books Online.
> Simon
> create table b (
> from_date datetime not null,
> to_date datetime not null,
> curr_code char(3) not null,
> ex_rate decimal(6,5) not null,
> constraint pk_b primary key (from_date, to_date, curr_code)
> )
> go
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040101', '20040110', 'CAD', 0.75000)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040111', '20040116', 'CAD', 0.74321)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040117', '20040204', 'CAD', 0.72222)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040205', '20040220', 'CAD', 0.71111)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040221', '20040228', 'CAD', 0.77888)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040301', '20040303', 'CAD', 0.79002)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040304', '20040314', 'CAD', 0.76803)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040315', '20040323', 'CAD', 0.70022)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040324', '20040402', 'CAD', 0.73365)
> go

<snip
Oops - the query I posted before won't handle multiple currencies correctly.
This version should.

select dt.start_of_month, dt.curr_code, avg(b.ex_rate) as 'ex_rate'
from
(
select cast(convert(char(6), from_date, 112) + '01' as datetime) as
'start_of_month', curr_code, count(*) as 'num'
from b
group by cast(convert(char(6), from_date, 112) + '01' as datetime),
curr_code
) dt
join b
on dt.curr_code = b.curr_code and
(
dt.start_of_month = cast(convert(char(6), b.from_date, 112) + '01' as
datetime)
or dt.start_of_month = cast(convert(char(6), b.to_date, 112) + '01' as
datetime)
)
group by dt.start_of_month, dt.curr_code

Simon|||The solution you recently posted is exactly what I am looking for.

And I am aware that "date" is a reserved word, i quickly sent the original
post out of haste.

Many thanks for your time!
Bob

"Simon Hayes" <sql@.hayes.ch> wrote in message
news:416d1418$1_1@.news.bluewin.ch...
> "B" <no_spam@.no_spam.com> wrote in message
> news:8bWdnSP-M6T0E_HcRVn-ig@.rcn.net...
> > Hi
> > I would like to create a SP where it will populate TableA based from
> > TableB.
> > TableB will be populated on a monthly basis using a DTS and within that
I
> > would like to run the SP to populate TableA.
> > Can someone here please help me create the sql statements as a starting
> > point.
> > TIA!
> > Bob
> > TableB (source)
> > from_date to_date curr_code ex_rate
> > 1/1/2004 1/10/2004 CAD .75000
> > 1/11/2004 1/16/2004 CAD .74321
> > 1/17/2004 2/4/2004 CAD .72222
> > 2/5/2004 2/20/2004 CAD .71111
> > 2/21/2004 2/28/2004 CAD .77888
> > 3/1/2004 3/3/2004 CAD .79002
> > 3/4/2004 3/14/2004 CAD .76803
> > 3/15/2004 3/23/2004 CAD .70022
> > 3/24/2004 4/2/2004 CAD .73365
> > etc...
> > TableA (destination):
> > date curr_code ex_rate
> > 1/2004 CAD 0.738477 calculation:(.75000+
> > .74321+.72222) / 3
> > 2/2004 CAD 0.737403
> > (.72222+.71111+.77888) / 3
> > 3/2004 CAD 0.74798
> > (.79002+.76803+.70022+.73365) / 4
> > etc..
> Here's one possible solution. In future, please post CREATE TABLE and
INSERT
> statements for your tables and data - other people can then simply cut and
> paste into Query Analyzer, and we don't have to guess about data types,
> keys, constraints etc.:
> http://www.aspfaq.com/etiquette.asp?id=5006
> Note that 'date' is a reserved keyword, so you should avoid using it as a
> column name - I've used start_of_month instead. See "Reserved Keywords" in
> Books Online.
> Simon
> create table b (
> from_date datetime not null,
> to_date datetime not null,
> curr_code char(3) not null,
> ex_rate decimal(6,5) not null,
> constraint pk_b primary key (from_date, to_date, curr_code)
> )
> go
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040101', '20040110', 'CAD', 0.75000)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040111', '20040116', 'CAD', 0.74321)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040117', '20040204', 'CAD', 0.72222)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040205', '20040220', 'CAD', 0.71111)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040221', '20040228', 'CAD', 0.77888)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040301', '20040303', 'CAD', 0.79002)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040304', '20040314', 'CAD', 0.76803)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040315', '20040323', 'CAD', 0.70022)
> insert into b (from_date, to_date, curr_code, ex_rate)
> values ('20040324', '20040402', 'CAD', 0.73365)
> go
> select dt.start_of_month, max(b.curr_code) as 'curr_code', avg(b.ex_rate)
as
> 'ex_rate'
> from
> (
> select cast(convert(char(6), from_date, 112) + '01' as datetime) as
> 'start_of_month', count(*) as 'num'
> from b
> group by cast(convert(char(6), from_date, 112) + '01' as datetime)
> ) dt
> join b
> on dt.start_of_month = cast(convert(char(6), b.from_date, 112) + '01' as
> datetime)
> or dt.start_of_month = cast(convert(char(6), b.to_date, 112) + '01' as
> datetime)
> group by dt.start_of_month
> go
> drop table b
> go

Help! Creating Custom Data Flow Task

I'm trying to create a custom data flow destination, and it has a custom property that needs to get value from variable(similar to the FileNameVariable property of Raw File Destination), how can I do that?

Create a propery of type string. Store the name of a variable in that property. Use the property value to locate the variable in the variables collection at run-time, lock and read the variable's value.

What are you asking? How to create a property? How to store a string in a property, the string being a variable name? How to read a string value from a property and get the matching varible and it's value at runtime?

You should also validate the value of the property during Validate of course, and check tht it is a valid variable name.

|||

DarrenSQLIS wrote:

Create a propery of type string. Store the name of a variable in that property. Use the property value to locate the variable in the variables collection at run-time, lock and read the variable's value.

What are you asking? How to create a property? How to store a string in a property, the string being a variable name? How to read a string value from a property and get the matching varible and it's value at runtime?

You should also validate the value of the property during Validate of course, and check tht it is a valid variable name.

So provide a custom IDTSCustomProperty90 in ProvideComponentProperties() and let users type in the variable name is enough(of course, I should also follow what you said)?

I wanted to make it behave the same way as the FileNameVariable property of Raw File Destination, that is: users don't type in the variable name, instead, they select from all available variable names.
|||

DarrenSQLIS wrote:

Create a propery of type string. Store the name of a variable in that property. Use the property value to locate the variable in the variables collection at run-time, lock and read the variable's value.

What are you asking? How to create a property? How to store a string in a property, the string being a variable name? How to read a string value from a property and get the matching varible and it's value at runtime?

You should also validate the value of the property during Validate of course, and check tht it is a valid variable name.

How can I get the matching variable and it's value at runtime? And generally in which method should I do that? Thanks.
|||

Here's a sample from a component I developed to raise custom events from a package's control flow; the same basic technique should work for you in data flow as well.

First, create a property that stores the variable name. This will be set by the package developer at design time.

Code Snippet

private string variableName;

///

/// This property gets or sets the name of the variable in which the

/// event text is stored.

///

[Browsable(true)]

[Category("Custom")]

[Description("Gets or sets the name of the variable in which the event text is stored.")]

public string VariableName

{

get

{

return variableName;

}

set

{

if (value.IndexOf("::") == -1)

{

variableName = "User::" + value;

}

else

{

variableName = value;

}

}

}

(The set accessor for the property is simply explicitly adding the User namespace to the specified variable name unless a namespace is already specified. I've yet to add a drop-down so the package developer can pick from a list of available variables.)

Then, you can use the component's VariableDispenser object (which is passed in a parameter to many of the methods you overload when developing your component) to lock and work with the package variable identified by the property. Here's a sample from the Validate method in my component:

Code Snippet

Variables vars = null;

DTSExecResult result;

variableDispenser.LockOneForRead(variableName, ref vars);

if (vars[variableName].DataType != TypeCode.String)

{

// The variable is accessable, but is not the correct data type

componentEvents.FireError(0, SubComponent(variableDispenser),

string.Format("Variable '{0}' is not a String variable", variableName), "", 0);

result = DTSExecResult.Failure;

}

else

{

result = DTSExecResult.Success;

}

vars.Unlock();

return result;

The key thing here is that you're using the variableDispenser to lock the specific variable identified by the component's property, working with it, and then unlocking it when you're done.

(The SubComponent method which is referenced in the code sample above is just a little helper routine that returns a string in a standard format to identify where an error or event is coming from. I need this type of string in many places, so I have a function that can be reused, but it's not really relevant to your question...)

Hope this helps!

Help! Create index with substring

Good day!

We had decided to migrate from Oracle to SQL Server, so faced some problems. Using Oracle we could create indexes like that

create index obj_id_cnum on obj_id (substr(cnum,1,2))

But Microsoft SQL Server doesn't allow this code. How can we do the same using SQL Server. Thanks you.

dynamic sql...

declare @.SQL nvarchar(100)

set @.SQL = 'create index [obj_id_cnum] on object_id(' + substring(cnum,1,2) + ')'

exec sp_executesql @.SQL

|||

Is obj_id a table, I am assuming? If so, then you are right, you cannot apply an index on a function directly. Two ways you can approach this:

1. If using enterprise edition, you can index a view and it will be used:

create view obj_id_indexed
as
select obj_id_key, cnum, substring(cnum,1,2) as cnumSub,
from obj_id

create unique clustered index on obj_id_cnum(obj_id_key, cnumSub)

Now your queries will see this index on the the view and apply it just like the

2. You can however add a computed column to your table and then index it:

alter table obj_id
add cnumSub as substring(cnum,1,2)

I would suggest that all of these techniques are probably the "wrong" way to go about this sort of thing. Almost any time you need to use a substring on a value in a SQL table there is a problem with normalization. Better would be to break the column into two parts, and then you have a much better chance of making the indexes work for you.

|||Thanks you very much! I do appreciate your help!|||

Derek Comingore - RSC wrote:

dynamic sql...

declare @.SQL nvarchar(100)

set @.SQL = 'create index [obj_id_cnum] on object_id(' + substring(cnum,1,2) + ')'

exec sp_executesql @.SQL

set @.SQL = 'create index [obj_id_cnum] on object_id(' + substring(cnum,1,2) + ')' gives an error 'Invalid column name 'cnum'.

|||Note that we are considering adding function / expression based indexes for a future version of SQL Server. For now, the easiest workaround is to use an indexed computed column.

Friday, March 9, 2012

HELP! Cannot pass GUID's through variables?

I have a project that uses GUID's througout and I'm completely stumped.

1) I create a "batch" GUID to batch the records I'm about to process.

2) I call a web service on a remote machine, and reserve the batch records by inserting the batch GUID into a string works fine

3)I call another web service that returns the rows that I just reserved as XML objects and insert into a string variable

4)I need to use the "batch"GUID variable which is typed as a string (DT_WSTR) as an added column so in a Data Flow Task I do the following:

a) use the XML string variable as the source of a XML Source Task -- works (now that I'm passing custom objects and not a dataset -- curious as to why I can't consume a dataset but thats a different question)

This is where things get tricky:
I've tried to add the BatchGUID as a derived column, as a datatype of DT_WSTR (unicode string) and convert it to uniqueidentifier in the Data Conversion task error, cannot convert unicode to uniqueidentifier (I know I can in C# and SQL Server so why not here).

I've tried to CAST the BatchGUID as a uniqueidentifier and pass that to the datasource -- again conversion error.

I've tried using the type Object and Casting to anything and that doesn't work either.

I've tried to pass the unicode all the way to the SQL Server Destination -- and insert into UniqueIdentifier field... again no go.

All help would be appreciated, at this point I can't see any way of using a UniqueIdentifier as a key field, and maintaining it through the package...
Is this a bug?

Oh and if you want to have some real fun, try returning the type of UniqueIdentifier as an output parameter using a ADO.NET connection.

Thanks!

Maybe a parameterized insert using the SQL Task and a property expression on the query to exchange the value of the GUID ID variable into the insert statement? Have you tried that?

Kirk Haselden
Author "SQL Server Integration Services"

|||

Could you elaborate more on how to implement the property expression in the query? I am doing exqactly as you said using a SQL task and trying to insert into custom logging tables via a sp call. I am using parameter mapping to map system variables to parameters in my sql call, however in my sp I am defining the guids as uniqueidentifiers but ssis system variable guids are strings. What is the easiest way to handle this and convert so it works?

Thanks!

|||

There's some examples here:

Using dynamic SQL in an OLE DB Source component
http://blogs.conchango.com/jamiethomson/archive/2005/12/09/2480.aspx

Setting Expressions
http://blogs.conchango.com/jamiethomson/archive/2006/03/11/3063.aspx

Dynamic modification of SSIS packages
http://blogs.conchango.com/jamiethomson/archive/2005/02/28/1085.aspx

-Jamie

Wednesday, March 7, 2012

Help! "Remove files older than 1 week" is not there!

Help!
When I use the Enterprise Manager and create a Database Maintenance Plan
there is an option which will allow me to "Remove files older than 'X'
days".
The only problem is that the drop-down box that is supposed to let me choose
"days, hours, weeks" etc is completely blank! This means that this function
is unavailable to me, thus my hard drive keeps filling up! Please help!
How can I fix this?
I have included a screen shot of this problem.
Michaaael
begin 666 EnterpriseManager.jpg
M_]C_X `02D9)1@.`!`0```0`!``#_VP!#``8$!08%! 8&!08'!P8("A *"@.D)
M"A0.#PP0%Q08&!<4%A8:'24?&ALC'!86("P@.(R8G*2HI&1\M, "TH,"4H*2C_
MVP!#`0<'!PH("A,*"A,H&A8:*"@.H*"@.H*"@.H*"@.H*"@.H*"@.H* "@.H*"@.H*"@.H
M*"@.H*"@.H*"@.H*"@.H*"@.H*"@.H*"@.H*"C_P `1" &)`?@.#`2(``A$!`Q$!_\0`
M'0`!``(#`0$!`0````````````4&`P0'" D"`?_$`&$0``$#`P("! @.)!P<(
M!0D)`0$"`P0`!1$&$A,A!Q0BE146,4%35I32%R,R4515M-'3-T)A=I*3U#-2
M<76#D>0D-#9S=*2SPP@.E@.;&R.$-(5V)RH\+A)D1&8X*$H;7PP?_$`!L!`0$!
M``,!`0`````````````!`@.,$!08'_\0`-!$!``$"! ,&! 4$`P````````$"
M$0,$$E$%$R$6,4%289$&<8&Q%2.AP=$B4V+P,C/Q_]H`# ,!``(1`Q$`/P"V
MV^QI595W*ZZ@.BVN'"="0XZ\%-ME1!!"PK"23_1SQ\]8<Z9ZSUGX2K%UCTO6A
MN\F/+NSY.52G_2%LEJL/0UJ.+8[9!ML9:XCBFH<=#*%++X!40D 9P ,_H%<"
MU=T3,6FY:GM-FOSERO6GHR)\N,]!$9#D8H2M;C3G$6"4!:,I4$DY.W<1@.^KD
M<C@.YBC5B5S$WF.[:W\PQ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.OJEP+@.XXE WF0]%CS2H-I_.<4MAL)&3V]PW$[B:NM*#D
M]WM.JI!9A3I$A7 =BOK>A[W$[WYT5PE&])2K@.*9E8W [&E,YSE=9+BSJ")>I
M<.$;TJSQEN("N(\ZHQBJVK=VN$E:U[53=A!+@.[24<T@.#JE*7' .(MG%UU%:>
MO4S-F;B3DAR2X\RZH%<0A'$5A]*2M*U#>I*R4* ):P#O%BXW.Q='TV[-2S+8
MD1Y5PV)4TXAQ45U!*D(P0.*X@.*3C`!5N&P*Q>:4%!T)X2\(PN L^%^-X/5X:Z
M[QN%U[+6W@.\3L;<]9_D/B\;...LJ.U!!GSY%\86W?GF$RXLAWM.)

Monday, February 27, 2012

HELP!

Using SQL 2000 with SP1 installed, Just doing some examples with northwind, when I try to create a report with the images stored in the Categories table, I get the red X's that show when there isn't a valid image. When I pull the data into access and view the pics they show. Any advice?You'd have to convert the image to Base64 encoding. Try this:
=System.Convert.FromBase64String(Mid(System.Convert.ToBase64String(Fields!Pi
cture.Value), 105))
--
Ravi Mumulla (Microsoft)
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Brian B" <Brian B@.discussions.microsoft.com> wrote in message
news:4292B678-BED0-4BCE-9B3B-923B1684A02F@.microsoft.com...
> Using SQL 2000 with SP1 installed, Just doing some examples with
northwind, when I try to create a report with the images stored in the
Categories table, I get the red X's that show when there isn't a valid
image. When I pull the data into access and view the pics they show. Any
advice?

Friday, February 24, 2012

Help with writing Triggers

I have no experience with Triggers and need help to create 2. My goal is to
generate the average and Stard Devation for 2 values when they are inserted
or updated. In the first field I insert a count that I need to calculate th
e
mean and StdDev based on the values of the past 30 days. The other is the
same with the addition of the past 30 days based on wdays or wends.
I currently am doing this with a batch but it would be simpler to manage if
the rows values were calculated when the values are inserted or updated.
Below are the table design and the batch statement.
-- ========================================
===============================
CREATE TABLE [dbo].[RollingRecordCount] (
[CDATE] [varchar] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[NCOUNT] [bigint] NOT NULL ,
[RCOUNT] [bigint] NOT NULL ,
[IsWday] AS (convert(char(1),case when ((datepart(wday,[CDATE]) = 7
or datepart(wday,[CDATE]) = 1)) then 'N' else 'Y' end)) ,
[MeanNc] [float] NULL ,
[StdDevNc] [float] NULL ,
[MeanRc] [float] NULL ,
[StdDevRc] [float] NULL ,
[InsertModDate] [datetime] NULL
) ON [PRIMARY]
GO
========================================
====================================
======
UPDATE RollingRecordCount
SET MeanNc = (SELECT AVG(NCOUNT)
FROM RollingRecordCount
WHERE CDATE BETWEEN (@.startdate) AND (@.enddate)),
StdDevNc = (SELECT STDEVP(NCOUNT)
FROM RollingRecordCount
WHERE CDATE BETWEEN (@.startdate) AND (@.enddate)),
MeanRc = CASE
WHEN IsWday = 'Y'
THEN (SELECT AVG(RCOUNT)
FROM RollingRecordCount
WHERE ISWday = 'Y' AND
CDATE BETWEEN (@.startdate) AND (@.enddate))
ELSE (SELECT AVG(RCOUNT)
FROM RollingRecordCount
WHERE ISWday = 'N' AND
CDATE BETWEEN (@.startdate) AND (@.enddate))
END,
StdDevRc = CASE
WHEN IsWday = 'Y'
THEN(SELECT STDEVP(RCOUNT)
FROM RollingRecordCount
WHERE IsWday = 'Y' AND
CDATE BETWEEN (@.startdate) AND (@.enddate))
ELSE (SELECT STDEVP(RCOUNT)
FROM RollingRecordCount
WHERE IsWday = 'N' AND
CDATE BETWEEN (@.startdate) AND (@.enddate))
END
FROM RollingRecordCount
WHERE CDATE = @.enddateJim Abel (JimAbel@.discussions.microsoft.com) writes:
> I have no experience with Triggers and need help to create 2. My goal
> is to generate the average and Stard Devation for 2 values when they are
> inserted or updated. In the first field I insert a count that I need to
> calculate the mean and StdDev based on the values of the past 30 days.
> The other is the same with the addition of the past 30 days based on
> wdays or wends. I currently am doing this with a batch but it
> would be simpler to manage if the rows values were calculated when the
> values are inserted or updated. Below are the table design and the batch
> statement.
Hm, I'm not that this is good for a trigger. As I understand it,
you want the values to reflect the last 30 days. But what if nothing
happens during a day? The values should still change, shouldn't they?
Of course, it may be a fair assumption that data is inserted everyday.
But how often? Recalculating everytime may be expensive?
(Basically, I say this, because I'm just about to leave, and don't
have the time to compose a trigger right now.)
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||I agree with Erland. A view could be used here. But it really is difficult t
o
be 100% sure without seeing the DDL and some sample data.
ML
http://milambda.blogspot.com/|||Sorry for the lack of details with this request. Here is some more
information. The 2 fields NCOUNT and RCOUNT are inserted once esch day. On
rare ocasions the counts that are entered had been calculated incorrectly at
the datasource and I need to manually edit the particular row and change the
value for one or both counts and then recalculate the means and StdDev of
that row based on the previous 30 days of that rows date. The other message
suggested using a view and that may work as well. I'm just trying to develo
p
something that takes as little management as possible, the goal being that I
need only to enter the NCOUNT and/or the RCOUNT and the mean and StdDev
columns can be autimatically generated without me needing to pull up a batch
script.
"Erland Sommarskog" wrote:

> Jim Abel (JimAbel@.discussions.microsoft.com) writes:
> Hm, I'm not that this is good for a trigger. As I understand it,
> you want the values to reflect the last 30 days. But what if nothing
> happens during a day? The values should still change, shouldn't they?
> Of course, it may be a fair assumption that data is inserted everyday.
> But how often? Recalculating everytime may be expensive?
> (Basically, I say this, because I'm just about to leave, and don't
> have the time to compose a trigger right now.)
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx
>|||I added some more detail to Erlands message in a reply. I thought that the
script under my 2nd ====== line was the ddl of the existing batch less the
declaration of the Start and en date parameters. the end date is set by
getting the Max date after the dauly insert occurs and the start date is 30
days less. In the case of a manual update to a previously entered row the
end date is the CDATE value and the Start date is 30 days less.
If I am ubderstanding your suggestion to use a view the mean and StdDev
fields would be calculated in the view design and they would not be necessar
y
in the underlyung table, is this chat you're suggesting?
"ML" wrote:

> I agree with Erland. A view could be used here. But it really is difficult
to
> be 100% sure without seeing the DDL and some sample data.
>
> ML
> --
> http://milambda.blogspot.com/|||Exactly. But to be certain we'd have to see more DDL (table definition) and
sample data.
ML
http://milambda.blogspot.com/|||Jim Abel (JimAbel@.discussions.microsoft.com) writes:
> Sorry for the lack of details with this request. Here is some more
> information. The 2 fields NCOUNT and RCOUNT are inserted once esch day.
> On rare ocasions the counts that are entered had been calculated
> incorrectly at the datasource and I need to manually edit the particular
> row and change the value for one or both counts and then recalculate the
> means and StdDev of that row based on the previous 30 days of that rows
> date. The other message suggested using a view and that may work as
> well. I'm just trying to develop something that takes as little
> management as possible, the goal being that I need only to enter the
> NCOUNT and/or the RCOUNT and the mean and StdDev columns can be
> autimatically generated without me needing to pull up a batch script.
If rows are inserted once per day, it makes more sense. I assume then
that CDATE is the primary key in RollingRecordCount? Wittout a primary
key, it gets difficult.
Below is a trigger. Some remarks: I've replaced the sub-selects with
joins to a derived table. This is a proprietary syntax and not very
portable. On the other hand, on SQL Server this syntax usuaally gives
better performance. I did not include the computation of StdDevRc, but
left that as an exercise. :-) You can use MeanRc as a pattern. I also
added 1E0* in some places to force a conversion to float. It's meaningless
to store the means as float, if the result is integer only. (Which it is
if you say AVG(NCOUNT) without any conversion.
CREATE TRIGGER rolling_tri FOR INSERT, UPDATE AS
UPDATE RollingRecordCount
SET MeanNc = R1.MeanNc,
StdDevNc = R1.StdDevNc,
MeanRc = CASE IsWday
WHEN 'Y' THEN R1.MeanWDay
ELSE R1.MeanWEnd
END
FROM RollingRecordCount R
JOIN (SELECT i.CDATE, MeanNc = AVG(1E0 * R.NCOUNT),
STDEVP(1E0 * R.NCOUNT
MeanWDay = SUM(1E0 * R.RCOUNT) /
SUM(CASE R.ISWday WHEN 'Y' THEN 1 ELSE 0 END),
MeanWEnd = SUM(1E0 * R.RCOUNT) /
SUM(CASE R.ISWday WHEN 'N' THEN 1 ELSE 0 END)
FROM inserted i
JOIN RolleingRecordCount ON R.CDATE
BETWEEN i.CDATE - 30 AND i.CDATE
GROUP BY i.CDATE) AS R1 ON R.CDate = R1.CDate
In lieu of sample data, the code is untested.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Sunday, February 19, 2012

Help with user accounts

Is there a way to filter at the server level what data is returned to
clients by user? I know that I can create a user account and assign what
columns/tables the user account has access to, but what if I want them to
have full access to a table, but only certain records in that table. Any
ideas?To add more clarification:
Lets assume I have the following tables:
CUSTOMER:
ID CUSTOMER_NAME COMPANY
========================================
=============================
1 Customer 1 1
2 Customer 2 1
3 Customer 3 1
4 Customer 4 2
5 Customer 5 2
6 Customer 6 2
7 Customer 7 1
8 Customer 8 2
9 Customer 9 2
10 Customer 10 2
USERS:
ID USER_NAME
=======================================
1 User 1
2 User 2
3 User 3
4 User 4
COMPANY:
ID COMPANY_NAME
========================================
==
1 Company 1
2 Company 2
SECURITY:
USERID COMPANY_ID
========================================
1 1
1 2
2 1
3 2
4 1
4 2
Ok the application would know that if User 4 is pulling a list from the
CUSTOMER table to show the customers for both companies. Likewise if User 2
preformed the same action they should only see customers from Company 1.
My question is how to I get this same functionality from say Query Analyzer?
"John Harbison" <JohnH@.desertmicro.net> wrote in message
news:eZH9VUcwEHA.3528@.tk2msftngp13.phx.gbl...
> Is there a way to filter at the server level what data is returned to
> clients by user? I know that I can create a user account and assign what
> columns/tables the user account has access to, but what if I want them to
> have full access to a table, but only certain records in that table. Any
> ideas?
>|||Check
http://vyaskn.tripod.com/ row_level...s
es.htm.
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com
"John Harbison" <JohnH@.desertmicro.net> wrote in message
news:%231TwA$cwEHA.2908@.tk2msftngp13.phx.gbl...
> To add more clarification:
> Lets assume I have the following tables:
> CUSTOMER:
> ID CUSTOMER_NAME COMPANY
> ========================================
=============================
> 1 Customer 1 1
> 2 Customer 2 1
> 3 Customer 3 1
> 4 Customer 4 2
> 5 Customer 5 2
> 6 Customer 6 2
> 7 Customer 7 1
> 8 Customer 8 2
> 9 Customer 9 2
> 10 Customer 10 2
>
> USERS:
> ID USER_NAME
> =======================================
> 1 User 1
> 2 User 2
> 3 User 3
> 4 User 4
>
> COMPANY:
> ID COMPANY_NAME
> ========================================
==
> 1 Company 1
> 2 Company 2
>
> SECURITY:
> USERID COMPANY_ID
> ========================================
> 1 1
> 1 2
> 2 1
> 3 2
> 4 1
> 4 2
>
> Ok the application would know that if User 4 is pulling a list from the
> CUSTOMER table to show the customers for both companies. Likewise if User
2
> preformed the same action they should only see customers from Company 1.
> My question is how to I get this same functionality from say Query
Analyzer?
>
> "John Harbison" <JohnH@.desertmicro.net> wrote in message
> news:eZH9VUcwEHA.3528@.tk2msftngp13.phx.gbl...
what[vbcol=seagreen]
to[vbcol=seagreen]
Any[vbcol=seagreen]
>

Help with Update Query command Problem

Hi all,

I have this store procedure as follows:

Create Proc UpdateProblem
@.ProblemID int,
@.CompanyName varchar (50),
@.Firstname varchar (50),
@.Lastname Varchar (50),
@.Address varchar (50),
@.Postcode varchar (50),
@.City varchar (50),
@.Phone varchar (50),
@.Cutype varchar (50),
@.ProDescript varchar (50),
@.Sol varchar (50),
@.Email varchar (50)

as Update Problem
set CompanyName = @.CompanyName,
Firstname = @.Firstname,
Lastname = @.Lastname,
Address = @.Address,
PostCode = @.Postcode,
City = @.City,
Phone = @.Phone,
Cutype = @.Cutype,
ProDescript = @.ProDescript,
Sol = @.Sol,
Email = @.Email


where ProblemID = @.ProblemID

when I test the querry

exec UpdateProblem
10004, 'Toro AS','Mike','Tullas','Togo Street','G34 5TT','New York','06582531','Private','Machine is dead','Replace motherboard','goo@.ht.com'

what happen is that when I ran the querry instead of updating the specifc row of 1004 the querry will just update the whole rows in the table with the same data.

Please help. I have set the ProblemID as the Primary key.

When you do a SELECT * FROM Problem WHERE PRoblemID = 10004 , do you get 1 row or multiple rows?|||Only 1 row when I run : SELECT * FROM Problem WHERE PRoblemID = 10004|||

Find out the error. where ProblemID = @.ProblemID --> wrong

where @.ProblemID = ProblemID -- Right

cheers

|||I dont think so. They are both same. There's something else that happened. ...WHERE ProblemID = @.ProblemID should work just fine. Thats the way most queries are written.|||Hi Justnew, is the ProblemID column defined as int type? Can you post some sample data so that we can repro your issue?

Help with update forms

Hey Guys
Still very new to asp/sql but trying to learn stuff as I go along.
I'm trying to create an update form where it pulls in an existing record, I
can update it, then submit the changes.
The problem i'm having is when i click to update the record I get this error
message
Cannot update identity column 'id'
In the update form, the ID column is hidden, so i'm not trying to change
that.
How do I get around it?
Thanks for your help.
RichHow are you performing the update? Can you post the actual SQL Statement?
You can't update an IDENTITY column.
David Portas
SQL Server MVP
--|||Hi David
Here's the statement - it was done through dreamweaver, so the code probably
isn't as neat as it should be.
' *** Update Record: set variables
If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <>
"") Then
MM_editConnection = MM_musicone_STRING
MM_editTable = "dbo.m1_web_content"
MM_editColumn = "id"
MM_recordId = "" + Request.Form("MM_recordId") + ""
MM_editRedirectUrl = "articleupdated.asp"
MM_fieldsStr =
" id|value|Publish_Date|value|Section|valu
e|Section_Type|value|Title|value|In
tro|value|Full_Text|value|LiveDate|value
|HyperLink|value|ImageSrc|value|Live
|value"
MM_columnsStr =
" id|none,none,NULL|Publish_Date|',none,NU
LL|Section|',none,''|Section_Type|'
,none,''|Title|',none,''|Intro|',none,''
|Full_Text|',none,''|LiveDate|',none
,NULL|HyperLink|',none,''|ImageSrc|',non
e,''|Live|none,1,0"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And
Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "")
Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " &
MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
Any advice would be appreciated!
Thanks
Rich
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:zOKdnaCOHNU1EQ7fRVn-gA@.giganews.com...
> How are you performing the update? Can you post the actual SQL Statement?
> You can't update an IDENTITY column.
> --
> David Portas
> SQL Server MVP
> --
>|||It looks like your UPDATE statement is attempting to update every column (in
the FOR loop). Aside from the specific problem you are having this seems
like a very error-prone and inefficient implementation. In general, avoid
generating SQL dynamically in code. Put your data access code in stored
procs and pass parameters from ASP to the proc. I'm not an ASP expert but
here's someone who is and has some tips and examples of good practices in
ASP:
http://www.aspfaq.com/show.asp?id=2201
http://www.aspfaq.com/show.asp?id=2424
David Portas
SQL Server MVP
--|||Thanks David, some really useful info that - much appreciated.
Richard
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:vaqdnR2tCdwjAg7fRVn-gA@.giganews.com...
> It looks like your UPDATE statement is attempting to update every column
> (in the FOR loop). Aside from the specific problem you are having this
> seems like a very error-prone and inefficient implementation. In general,
> avoid generating SQL dynamically in code. Put your data access code in
> stored procs and pass parameters from ASP to the proc. I'm not an ASP
> expert but here's someone who is and has some tips and examples of good
> practices in ASP:
> http://www.aspfaq.com/show.asp?id=2201
> http://www.aspfaq.com/show.asp?id=2424
> --
> David Portas
> SQL Server MVP
> --
>