Showing posts with label task. Show all posts
Showing posts with label task. Show all posts

Friday, March 23, 2012

Help on INI file

Hi all,
I'm building a DTS package that needs to take parameters from an INI
file. The SQL statement in the Transform task goes something like this:
select * from customer where division in ('D','I','2','3','C')
I need to pass the division 'D','I','2','3','C' part in because there
might be more divisions we need in the future or change of divisions,
we don't want to modifiy the package every time. So I set it in the INI
file like this and read it into a global variable:
[Customer]
Division = 'D','I','2','3','C'
But SQL doesn't recognize the SQL statement "select * from customer
where division in (?), where ? stands for the global variable. I tried
with setting Division = "'D','I','2','3','C'" in INI file, it still
doesn't work. The only way it works is to pass the 5 values as 5
seperate parameters and thus 5 global variables then the SQL statement
is like this:
select * from customer where division in (?,?,?,?,?)
But this defeats the purpose because I can't add another parameter in
the INI file without having to open the package and make changes.
Has anybody run into this before? Any suggestions is appreciated.
Thanks,http://www.sommarskog.se/arrays-in-sql.html

Simon

Monday, March 12, 2012

Help needed regarding the procedure

Hi All

I am new to sqlserver.I got the doubt when i want to perform a task.Need yours advice

In a table i am having a column email with mailids. most of the rows are with the value email@.email.com.
My requirement is i want to change the value email@.email.com as email1@.email.com,email2@.email.com,.....like that
with autoincrement.Here primarykey attribute name is id

Waiting for valuable suggestions

Baba

I take it you don't want to update ALL emails in your table, just the duplicate ones (email@.email.com)?

If so, it depends on whether the number is important or whether you just want to make each value distinct.

To just get distinct values you could just run:

Code Snippet

UPDATE table

SET email = 'email' + CAST(id AS VARCHAR(100)) + '@.email.com'

WHERE email = 'email@.email.com'

If the number is important and you want the values to go sequentially from 1-> n then you'll probably have to use some procedural code, such as a cursor though you'll still need an update statement similar to the one above.


HTH!

|||
Thank u for u r reply.

I applied cursors concept and i updated it.

Thank u

Baba
|||

You might want to show us what you come up with when you are done so that we can verify it for you; it is always a good idea to have another set of eyes to look at something.

|||

There's a way to get the numbers to be sequential without cursors etc:

Code Snippet

UPDATE table

SET email = 'email' + Convert(varchar(100), (select count(*) from table t2 where t2.id < t1.id and t2.email = 'email@.email.com')) + '@.email.com'

FROM table t1

WHERE email = 'email@.email.com'

It's late and I haven't tested it so there may be errors, but hopefully that gives you the general idea.

Sean

Monday, February 27, 2012

Help me with this error wmi task

i set up a WMI Reader Task which works perfectly fine.

But when i Use WMI event watcher i get this error.

if the problem is with access rights how do i need to set or how can i figure out if i have rights..

[WMI Event Watcher Task] Error: Watching for the Wql query caused the following system exception: "Invalid class". Check the query for errors or WMI connection for access rights/permissions.

What is the WQL query you are trying to execute and on what OS/architechture? Some WMI classes are available on Vista, Windows 2003, and not on XP, and vice versa.

Sunday, February 19, 2012

help me in connection

I am using sql server and c# (windows application)>>

the task is to retrieve records from table in the database and view it in page load , with the abilty to choose the records >>

this means that select range >>> e.g. from 3 to 7 (this can done by textbox)

so how can i do this >>

then I shall have two search buttons ( by name and by id) >> how can I implement that >>>

the last thing is to do the validation for every thing i can validate how I can do this >>>

thank u at the beginning for help me

adorer:

I am using sql server and c# (windows application)>>

Since you are writing a Windows application, and these forums are for ASP.NET, you should post your question on theMSDN forums.

|||

SqlConnection cn =

new SqlConnection("User ID=sa;password=;Initial Catalog=Training;Data Source=local");

cn.Open();

DataSet ds =

new DataSet();

SqlDataAdapter da =

new SqlDataAdapter("select * from Students where ID = '"+ textBox1.Text + "'", cn);

da.Fill(ds, "Students");

dataGrid1.DataSource = ds;

cn.Close();

does this do the task