Showing posts with label specify. Show all posts
Showing posts with label specify. Show all posts

Monday, March 19, 2012

Case - Sensitive field

I want to specify the data in columns are both upper & lower case(i.e. one column data having all lowercase data or uppercase data ).

Ex:- if i have one column - col1 and its

1st value is RAKESH JHA

2nd value is rakesh jha

then how i can find that, how much row are in upper case. respectively lower case

Use UPPER and LOWER functions. Like:
select * from MyTable where UPPER(fCOL1)=fCOL1

|||

Have a look at

http://vyaskn.tripod.com/case_sensitive_search_in_sql_server.htm

Sunday, March 11, 2012

Cascading Deletes

When I setup a relationship in Access I can specify that Primary Key deletes cascade down to the Forgien Key. So when I delete an Order Header it cleans up all the items in the Order Details table for me automatically.

Can I get this same functionality in SQL Server 7 without having to write triggers or are triggers the only way?

thanks
dogNo, trigger is not the only way: you could create a procedure that does this for you or, when you create the table or add the constraint specify the on delete option to cascade (see BOL, create table).|||What!?!?!?

SQL Server has cascading deletes! The easiest way to manage them is through the Relationships tab of the Properties dialog box in the Enterprise Manager table design form.

Triggers are NOT necessary for standard cascading.|||Cascade? Like a waterfall?

Has anyone scanned the landscape for a merry-go-round?

:D

Wholly disconnected ramblings bart man...

Seriously...be careful with cascading...should be no need...

I never liked messing with keys...

damn surrogates...

To me, if a key changes, then it's a new entity...or the key is defined improperly...

You lose all history...|||Well, you certainly aren't alone in your aversion to cascading relationships, but I've never had a problem with them.

Disconneted ramblings...

...many...non-sequiturs...

Wish I had a key for elipsis so I didn't have to hit the period key three times...

Must...complete...sentence.... damn!|||Seriously...be careful with cascading...should be no need...

pretty dogmatic Mr. Kaiser, what's your solution to my previous example, if in fact I don't care about history? Say I have OrderNumber as the Primary key in the OrderHeader table and OrderNumber as a Foreign key in the OrderDetails table, how is this a misconfigured key arrangement?|||Wow...dogmatic...

Cool...

You want to cascade...knock yourself out...|||SQL Server has cascading deletes! The easiest way to manage them is through the Relationships tab of the Properties dialog box in the Enterprise Manager table design form.
That seems to be the logical place for it, however the only options I have are:
Check existing data on creation
Enable relationship for INSERT and UPDATE
Enable relationship for replication

maybe a version difference :confused:|||You want to cascade...knock yourself out...
That's your solution?

WOW......
COOL DUDE.......
THANKS FOR THE MOST RIGHTOUS EXPLAINATION.....................
ATS AWESOME................|||Enable relationship for INSERT and UPDATE

Seems the SQL Server developers were too lazy to say "Enable relationship for INSERT, UPDATE and DELETE. My bad, I read the help screen and found that DELETE is included with this option, however, it doesn't give me the desired result. It actually disables Primary key deletion if Forgein key dependants exist.

Again, do I need to write triggers to accomplish my goal here :confused:

I want all Forgein keys associated with a Primary key to be deleted when I delete the PK record :D|||See attached screenshot.|||Yup, must be an update that I don't have in my v7 version, guess I'll find out what it means to be trigger happy. Thanks blindman.|||'bout time to upgrade, isn't it?|||cascade update\delete is "New" to sql 2000 v :eek:

and you dont have to create database devices anymore.. :D

Sunday, February 12, 2012

Can't use Package Variable to specify the filename for a Connection

I'm attempting to modify a flatfile import package so that I can reuse it to import several other files into the same table. I was unable to use package variables (containing the import filename) in the Flat File Connection Manager file name field. What is the proper way to solve this kind of problem in SSIS?Have you looked up property expressions in BOL? Give that a look.
http://sqljunkies.com/WebLog/knight_reign/archive/2005/02/12/7750.aspx
Thanks,
K|||

I setup a ForEach Loop Container to do this.

Create a Package Variable, for example, "varFileName", for the FileName. Then edit the ForEach Loop container. Select "Variable Mappings". Select the drop-down under the "Variable" column and select your "User: varFileName" variable. The index column should read "0". Save the object. Now add a Data Flow task and double-click to edit.

In the Data Flow window, create a Source Script transformation. Define your output columns on the "Inputs and Outputs" option. Click "Script" and add your variable "varFileName" to the property "ReadOnlyVariables". Now click the "Design Script" button, which opens up another window for scripting.

Add "Imports System.IO" to the top so you can read the flat file.

Read the file with the following code:

Dim strRecord as String
Dim objFlatFile As StreamReader = File.OpenText(Variables.varFileName)
Do Until objFlatFile.Peek = -1
strRecord = objFlatFile.ReadLine
[OutputBuffer].AddRow()
[OutputBuffer].[Column1] = Mid$(stRecord,1,4)
... etc.
Loop

Let me know if this helps...