Assign Expression Value Using Code

Feb 7, 2007

I am trying to use a variable to set an attribute value of an SSIS task but I keep running into the 4000 character limit of the string variable. Not sure why the variable which is of .NET type String has this limit when it doesn't when you are in a .NET environment. Regardless, can anyone provide some sample code that I could use to do this in a script task? I am trying to set the QueryString property of the Data Mining Query Task. All help would be appreciated.

Thank you in advance.

View 5 Replies


ADVERTISEMENT

How To Assign An Expression With A Ssis Variable?

Jul 19, 2007

Hi all of you,



That's an easy one. I've got a Send Mail task which might send a message in plain text along with a SSIS variable.



Something like that:



'La tabla "' + SUBSTRING( @[System:ackageName], 3,20) + "' se ha cargado correctamente'



TIA for that,



View 1 Replies View Related

Sort Expression - Custom Code

Apr 28, 2008

Hi,
I have a report that needs sorting on a column that is calculated. however, the calculation is so complex (iterative calculations) i've had to do that within my custom code. I am getting the results back well and good but i cannot perform a sort based on that.
My problem is: how do i write a custom sort expression function that will direct the column to sort my table based on say the value(s) returned from that function. I want for example:




Code Snippet
Public Function mySortExpression(byVal myIDorWhatever as Something) as CustomSortableExpression

' Perform some calculation
' Return some value(s)/array or anything that the column can appreciate and sort the table accordingly with
End Function




then in say the Interactive Sort Sort Expression, i'll have the code:



Code Snippet
=code.MyClass.mySortExpression(myID)


I hope i've made myself clear enough.
Cheers

View 3 Replies View Related

Changing Code Page Property Using Property Expression Doesn't Work

Jun 16, 2006

I am having problems exporting data into a flat file using specific code page. My application has a variable "User::CodePage" that stores code page value (936, 950, 1252, etc) based on the data source. This variable is assigned to the CodePage property of desitnation file connection using Property expression.

But, when I execute the package, the CodePage property of the Destination file connection defaults to the initial value that was set for "User:CodePage" variable in design mode. I checked the value within the variable during runtime and it changes correctly for each data source. But, the property of the destinatin file connection doesn't change and results in an error.

[Flat File Destination [473]] Error: Data conversion failed. The data conversion for column "Column01" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".

[DTS.Pipeline] Error: The ProcessInput method on component "Flat File Destination" (473) failed with error code 0xC02020A0. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.

If I manually update the variable with correct code page and re-run the ETL, everything works fine. Just that it doesn't work during run-time mode.

Can someone please help me resolve this.

Thanks much.

View 5 Replies View Related

URGENT - My Error Or Bug? The Result Of The Expression Cannot Be Written To The Property. The Expression Was Evaluated, But

Feb 8, 2007

Error 3 Error loading MLS_AZ_PHX.dtsx: The result of the expression ""C:\sql_working_directory\MLS\AZ\Phoenix\Docs\Armls_Schema Updated 020107.xls"" on property "ConnectionString" cannot be written to the property. The expression was evaluated, but cannot be set on the property. c:documents and settingsviewmastermy documentsvisual studio 2005projectsm l sMLS_AZ_PHX.dtsx 1 1


"C:\sql_working_directory\MLS\AZ\Phoenix\Docs\Armls_Schema Updated 020107.xls"

Directly using C:sql_working_directoryMLSAZPhoenixDocsArmls_Schema Updated 020107.xls
as connectionString works

However - I'm trying to deploy the package - and trying to use expression:
@[User::DIR_WORKING] + "\Docs\Armls_Schema Updated 020107.xls"
which causes the same error to occur

(Same error with other Excel source also:
Error 5 Error loading MLS_AZ_PHX.dtsx: The result of the expression "@[User::DIR_WORKING] + "\Docs\Armls_SchoolCodesJuly06.xls"" on property "ConnectionString" cannot be written to the property. The expression was evaluated, but cannot be set on the property. c:documents and settingsviewmastermy documentsvisual studio 2005projectsm l sMLS_AZ_PHX.dtsx 1 1
)

View 4 Replies View Related

Reporting Services :: Running Value Expression Within Lookup Expression In SSRS?

Oct 28, 2015

I have created 1 report with 2 datasets. This report is attached to the 1st dataset.For example,1st one is "Smallappliances", 2nd is "Largeappliances".

I created a tablix and, the 1st column extracts Total sales per Sales person between 2 dates from 1st dataset (Small appliances). I used running values expression and it works fine.

Now, I would like to add another column that extracts Total sales per sales person between 2 dates from 2nd dataset (Large appliances). I am aware that I need to use Lookup expression and it is giving me the single sales value rather than the total sales values. So, I wanted to use RunningValue expression within lookup table to get total sales for large appliances.

This is the lookup expression that I added for the 2nd column.

=Lookup(Fields!salesperson.Value,Fields!sales_person.Value,RunningValue(Fields!sales_amount.Value,
sum, " sales_person"),
"Largeappliances").

I get this error when I preview the report.An error occurred during local report processing.The definition of the report is invalid.An unexpected error occurred in report processing.

(processing): (SortExpression ++ m_context.ExpressionType)

View 7 Replies View Related

Help With Converting Code: VB Code In SQL Server 2000-&&>Visual Studio BI 2005

Jul 27, 2006

Hi all--I'm trying to convert a function which I inherited from a SQL Server 2000 DTS package to something usable in an SSIS package in SQL Server 2005. Given the original code here:
Function Main()
on error resume next
dim cn, i, rs, sSQL
Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=sqloledb;Server=<server_name>;Database=<db_name>;User ID=<sysadmin_user>;Password=<password>"
set rs = CreateObject("ADODB.Recordset")
set rs = DTSGlobalVariables("SQLstring").value

for i = 1 to rs.RecordCount
sSQL = rs.Fields(0).value
cn.Execute sSQL, , 128 'adExecuteNoRecords option for faster execution
rs.MoveNext
Next

Main = DTSTaskExecResult_Success

End Function

This code was originally programmed in the SQL Server ActiveX Task type in a DTS package designed to take an open-ended number of SQL statements generated by another task as input, then execute each SQL statement sequentially. Upon this code's success, move on to the next step. (Of course, there was no additional documentation with this code. :-)

Based on other postings, I attempted to push this code into a Visual Studio BI 2005 Script Task with the following change:

public Sub Main()

...

Dts.TaskResult = Dts.Results.Success

End Class

I get the following error when I attempt to compile this:

Error 30209: Option Strict On requires all variable declarations to have an 'As' clause.

I am new to Visual Basic, so I'm on a learning curve here. From what I know of this script:
- The variables here violate the new Option Strict On requirement in VS 2005 to declare what type of object your variable is supposed to use.

- I need to explicitly declare each object, unless I turn off the Option Strict On (which didn't seem recommended, based on what I read).

Given this statement:

dim cn, i, rs, sSQL

I'm looking at "i" as type Integer; rs and sSQL are open-ended arrays, but can't quite figure out how to read the code here:

Set cn = CreateObject("ADODB.Connection")

cn.Open "Provider=sqloledb;Server=<server_name>;Database=<db_name>;User ID=<sysadmin_user>;Password=<password>"

set rs = CreateObject("ADODB.Recordset")

This code seems to create an instance of a COM component, then pass provider information and create the recordset being passed in by the previous task, but am not sure whether this syntax is correct for VS 2005 or what data type declaration to make here. Any ideas/help on how to rewrite this code would be greatly appreciated!

View 7 Replies View Related

How To Show Description In Report Instead Of Code (Desc For Code Is In Master Table)

Mar 28, 2007

Dear Friends,



I am having 2 Tables.

Table 1: AddressBook
Fields --> User Name, Address, CountryCode



Table 2: Country
Fields --> Country Code, Country Name


Step 1 : I have created a Cube with these two tables using SSAS.



Step 2 : I have created a report in SSRS showing Address list.

The Column in the report are User Name, Address, Country Name



But I have no idea, how to convert this Country Code to Country name.

I am generating the report using the Layout tab. ( Data | Layout | Preview ) Report1.rdl [Design]



Anyone help me to solve this issue. Because, in our project most of the transaction tables have Code and Code description in master table. I need to convert all code into corresponding description in all my reports.




Thanks in advance.





Regards
Ramakrishnan
Singapore
28 March 2007

View 4 Replies View Related

How To Assign A Value To A Parameter?

Nov 17, 2006

Hello everyone,
i have the parameter in my stored procedure that i am using as a sqldatasource.
 
Now in one of the events, i need to assign a value to the parameter. How can i do that?
Microsoft is changing the syntax so often, all solutions i found on this forum just don't work anymore, like:
SqlDataSource1.SelectParameters["@CompareInteger"].value= "1"
OR
SqlDataSource1.SelectParameters["@CompareInteger"].DefaultValue= "1"
 
I guess the SelectParameter - became 'ReadOnly'..But how to assign value to a parameter now?!?
Thanks for any help
 
 

View 5 Replies View Related

Assign Variable Within SP

Nov 23, 2006

I use SQL Server 2005 and in a Stored Procedure I want to execute a sql statement and assign the result to a variable. How can I do that?The name of the column I want to retreive the value from is "UserID"Here's my SP so far:
ALTER PROCEDURE [dbo].[spUnregisterUser]
@UserCode int
AS
BEGIN
SET NOCOUNT ON;
declare @uid uniqueidentifier
--get userid
SELECT @uid=UserID FROM tblUserData WHERE UserCode=@UserCode
-- Delete user
UPDATE tblUserData SET IsDeleted='True' WHERE UserCode=@UserCode
END

View 1 Replies View Related

Assign A Resutset

Nov 11, 2000

Hi

How can I assigne a value that return from a stored procedure into a variable?
Example:

if I execute this:

declare @szquery as nvarchar(256)
declare @icount as int

--I must pass a string query because the name of the field and the table are ---the variable that i passed

set @szquery='Select count(reckey) as dummy from table1 '

exec sp_executesql @szquery

the result is:

dummy
-----------
15770

(1 row(s) affected)
declare @b as int

I want assigned 'dummy' into a variable

set @icount= ???

if I ecexute this:

print @icount

the result :

15770


please help me out in this issue and i'd appreciate that.

tanks
Emiliano

View 1 Replies View Related

HELP!!! How To Assign An Int Value Using A String??

May 23, 2002

hi, can somebody help me to solve this problem?

first, declare 2 variables

declare @num int
declare @str varchar(255)

then set the varchar variable to '100/10'
set @str = '100/10'

is there anyway to assign a value to @num using @str, so that @num has a value 10??
set @num = @str ????????

View 1 Replies View Related

Assign Value To Variable

Oct 6, 2015

How to make it workable code..

declare @i int=1
declare @numweek int=2
declare @a int=35
declare @b int=29
declare @Wkstr1 date,@Wkstr2 date

[Code] .....

View 7 Replies View Related

How To Assign 0 To A Null

Apr 22, 2008

I have this query and I tried this but am getting the error for the case statement when I assign the nulls to a 0:

The error is they data types of the result expression of a CASE expression are not compatible.

SELECT
'C' as account,
FUND_dim.fund_cde as FUND,
case when sum(BRKGRPTT.daily_brkg_fact.accum_unit_cnt) is null then '0' else sum(BRKGRPTT.daily_brkg_fact.accum_unit_cnt) end as Units_Purchased
FROMFUND_DIM
left outer join BRKGRPTT.daily_brkg_fact
on FUND_DIM.FUND_ID_NUM = BRKGRPTT.daily_brkg_fact.FUND_ID_NUM
and BRKGRPTT.daily_brkg_fact.SEP_ACCT_ID_NUM <> 1
left outer join SEP_ACCOUNT_DIM
on BRKGRPTT.daily_brkg_fact.sep_acct_id_num = SEP_ACCOUNT_DIM.sep_acct_id_num
group by BRKGRPTT.sep_account_dim.sep_acct_cde, BRKGRPTT.fund_dim.fund_cde
order by FUND_dim.fund_cde

View 4 Replies View Related

Assign XML To Variable

Jul 12, 2006

How do I assign XmlDocument results to a variable (so that I can pass it to a sp)?

I know that the following code works....

select * from tblUsers where userId = 1225 for XML raw

It returns "<row UserId="1225" LastName="Evans" FirstName="Stephanie" MiddleInitial=...."), which is what I want. But when I try to assign it, I get an error "Incorrect syntax near 'XML'."

declare @strXml nvarchar(1000)

set @strXml = (select * from tblUsers where userId = 1225 for XML raw)

Ideas?

View 1 Replies View Related

Assign Name To The DB Users.

Oct 20, 2006

I'm developing a vb 2005 application and I€™m creating the users directly to the database. I want to assign them names.
 
I want to do something like this:
CREATE TABLE admin.db_users (
id INT CONSTRAINT db_user_pk PRIMARY KEY,
[name] VARCHAR(50) CONSTRAINT db_user_name_nn NOT NULL,
authentication VARCHAR(25) CONSTRAINT db_user_authentication_nn NOT NULL,
CONSTRAINT db_user_fk FOREIGN KEY(id)
REFERENCES sys.database_principals (principal_id)
ON UPDATE CASCADE
ON DELETE CASCADE
);
GO
 
This is the error that i'm getting:
Msg 1767, Level 16, State 0, Line 1
Foreign key 'db_user_fk' references invalid table 'sys.database_principals'.
Msg 1750, Level 16, State 0, Line 1
Could not create constraint. See previous errors.
 
How do I solve this problem or how can I do something similar.

View 5 Replies View Related

How To Assign SQL Query To Button In Asp.net 2.0

May 24, 2007

Hi
                  My webpage contain three dropdown box and one button. One dropdown to choose hospital_id, second dropdown to choose project_id and third dropdown to choose version_no .After choosing these three and when the button is clicked i want to run this sql query
INSERT INTO  version(project_id,hospital_id,date_created,comments) SELECT project_id,hospital_id,date_created,comments FROM version where version_no=@version_no and project_id=@project_id and hospital_id=@hospital_id.
Just i need the code in asp.net 2.0 , VB , when the button is clicked the above query should run and the parameters (values) should take from dropdown box.
Could anyone please send the solution for the above problem.

View 1 Replies View Related

Assign A Foreign Key As A Parameter

Oct 15, 2007

hi everybody
I have the following asp.net2.0 codeSelectCommand = "Select IDEmp, FirstName,MiddleName,LastName, Date,HoursNumber, Description
From Employee, WorkOnCategory , CatDesignItemReference
where IDEmp =IDEmplWork AND FirstName = @FirstName AND Category = @AnyCategory AND ">
 
<SelectParameters>
<asp:ControlParameter ControlID="txtEmployeeName" DefaultValue="" Name="FirstName" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="DropDownList1" DefaultValue="" Name="AnyCategory" PropertyName = "SelectedValue" Type="String" />
</SelectParameters>
 
</asp:SqlDataSource>
 
The problem is that the AnyCategory in my DropDownList1 refers to a key but unfortunalely my code understand it as string so it assigns
 Category = @AnyCategory  as if Category ='AnyCategory ' not as Category = AnyCategory 
 So what should I do
Thanks

View 2 Replies View Related

What Property Should I Assign To My Sqlcommand ?

Apr 2, 2008

what property should i assign to myPuzzleCmd2 ? 
 
myConnection.Open()
 Dim myPuzzleCmd2 As New SqlCommand("GetRandomCode", myConnection)
 
myPuzzleCmd2.CommandType = CommandType.StoredProcedure
 Dim retLengthParam As New SqlParameter("@Length", SqlDbType.TinyInt, 6)
retLengthParam.Direction = ParameterDirection.Input
 
myPuzzleCmd2.Parameters.Add(retLengthParam)
 Dim retRandomCode As New SqlParameter("@RandomCode", SqlDbType.VarChar, 30)
 
retRandomCode.Direction = ParameterDirection.Output
 
myPuzzleCmd2.Parameters.Add(retRandomCode)
 
Try
 Dim reader As SqlDataReader = myPuzzleCmd2.ExecuteReader()
myPuzzleCmd.ExecuteNonQuery()Catch ex As Exception
 
myPuzzleCmd2 = Nothing
 Session.Remove("RandomCode")
 HttpContext.Current.Session("RandomCode") = myPuzzleCmd2("@RandomCode")        <  ---------       Over here
 Finally
myConnection.Close()
End Try

View 7 Replies View Related

How To Assign Password And User Id

May 8, 2008

Hi
I have add one new database mdf file in my project by --->  add new  Item in to project.
But This database.mdf file is in windows authetication mode.
So there is no password assign to this.
I want to assign use id and password to this database or I want to give sql server authetication mode.
I have tried Modfy Connection property of database but that is not working. what is the default username of this conncetion?????
REply.....

View 3 Replies View Related

How To Assign The @@IDENTITY To A Variable

Feb 24, 2005

Hi,

HOW can I assign the value of @@IDENTITY to the any variable in SQL SERVER .

Thanks,

View 1 Replies View Related

How To Assign Logins To A Group

Oct 18, 2013

I have created a program that allow the user to register account as new user to sql. I do not want everyone use the same account (default sa).Now i want to group those users into one group which easy for management.But I cant find way to create new login group.I search over net, they said need to done under computer management--local user and group, but my computer do not have local user and group..

View 3 Replies View Related

Assign Sequential Numbers

Mar 17, 2004

I am trying to automatically insert records into my existing customer table. Is there a way when I insert these new records and assign the customer number that it can sequentially pick the next available unique customer number for each record that is inserted? for example the first record would be customer number 100, the next 101, and so on? Please advise.

View 4 Replies View Related

Randomly Assign To Group

Oct 23, 2014

My issue is that I have 10 accounts that were assigned to 5 agents with each agent receiving 2 accounts. I would know like to randomly reassign the accounts with the only criteria being that the random allocation not reassign to the same agency and each agent gets 2 accounts again.

Data looks like below and I want to populate the randomly assigned agent in the "Second_Agent" column.

Account,First_Agent,Second_Agent
B1,1,
B2,1,
B3,2,
B4,2,
B5,3,
B6,3,
B7,4,
B8,4,
B9,5,
B10,5,

How to most effectively achieve this using SQL?

View 9 Replies View Related

ASSIGN Record Equal

Mar 31, 2006

Good day!

I have the qry, which is suppose to assigned records to active user (almost 15 users) equal, but it doesn’t- sometime it assigned more to some users and less to others. How could I modify my qry to make sure it assigns the records equals to each user? Please, see the qry below. I will appreciate any help

Thk


UPDATE
TBLFRAUDFINDER
SET
DATE_ASSIGNED=GETDATE(),
FRAUDANALYSTASSIGNED=@FRAUDANALYST
WHERE
FRAUDID=@FRAUDID OR
(FRAUDANALYSTASSIGNED IS NULL AND
((INQUIRY_GOVT_NUMBER=@INQUIRY_GOVT_NUMBER) OR
(CUST_NM=@CUST_NM) OR
(ALERT_IDENTIFIER=@ALERT_IDENTIFIER) OR
(ACCT IN (SELECT
ACCT
FROM
TBLFRAUDFINDER
WHERE
INQUIRY_GOVT_NUMBER=@INQUIRY_GOVT_NUMBER OR
CUST_NM=@CUST_NM OR
ALERT_IDENTIFIER=@ALERT_IDENTIFIER))

View 1 Replies View Related

Assign Function To Table Var??

Sep 19, 2007

I keep getting a declare error on this:
DECLARE @SplitTable TABLE(Idx BIGINT IDENTITY(1,1), SplitData VARCHAR(20), Size INT)
SET @SplitTable = dbo.SplitToTable('|', '1|One|0:26:20|541|abc|xxx|6:26:33|21705')

All I want to do is assign the table that my function returns to a variable. Should be easy, but I tried the above and assigning with 'as':

select * from dbo.SplitToTable('|','1|One|0:26:20|541|abc|xxx|6:26:33|21705') as Split

that didn't work either.

Also tried:
DECLARE @SplitTable TABLE(Idx BIGINT IDENTITY(1,1), SplitData VARCHAR(20), Size INT)
select @SplitTable= from dbo.SplitToTable('|','1|One|0:26:20|541|abc|xxx|6:26:33|21705')

what am I missing?

--PhB

View 3 Replies View Related

Assign Records To Analysts

Jul 20, 2005

Here is my issue. I have a list of merchants (generated daily) and Ineed to assign them eually to a set of analysts. Both the merchantlist and analyst list can change daily. I want to assign each merchantwith an analyst daily and need help to write out a stored procedurefor this (do not want to use VB).Here is relevant code for the tables:CREATE TABLE MerchList (MerchListID int IDENTITY (1, 1) NOT NULL ,FileDate datetime NOT NULL ,MerchID int NOT NULL ,AnalystID int NOT NULL ,)CREATE TABLE tblAnalyst (AnalystID int IDENTITY (1, 1) NOT NULL ,AnalystName varchar(100) NOT NULL)there will be about 10000 records in table MerchList and around 25records in table tblAnalyst.This will be used to assign work to analysts on a daily basis.Thanks for all your help!Vishal

View 5 Replies View Related

Assign A Value To A Variable Without Using SQL Task

Nov 30, 2006

Greetings once again,



I am trying to achieve a seemingly simple task of assigning datetime value to a user variable at the point my package starts running. How can I do this without using a SQL Script Task? Should I be using a script task for this or is there a simpler way to achieving the same thing?

Thanks in advance.

View 5 Replies View Related

How To Assign The View To A User?

Oct 29, 2006

im using the Northwind database, i use T-SQL commands to create a view that restricts users from seeing the address, city for all employees.
i dont know how to assign the view to a user in the database using Enterprise manager.
pls help me, im really needing a answer.
thanks!

View 5 Replies View Related

Assign Cluster # To Customers

Dec 31, 2007



I deployed a clustering project. As a result, I got 10 clusters. Is there an automatic way to create a table with the customer ID and the cluster # that each customer was assigned to?

Thanks!

Ezes

View 4 Replies View Related

Conditional Split - Assign To Value

Jun 13, 2007

Hello,



When you´re comparing values in the Condition of the Conditional split, can you assign a value to a variable?



If so, how can you accomplish this?



Thank you.

View 1 Replies View Related

Assign Null Value To Variable

Sep 5, 2007

I have a column with int data type.. i am trying to assign this column to a variable ( int) in For Each Loop..but it keeps giving me an erro

The type of the value being assigned to variable "User:ubcontractor_Key" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.


Am i getting this error becasue the column has NULL value?. how can I resove this probelm?

View 4 Replies View Related

Assign Role Of SQLAgentOperatorRole

Jun 13, 2007

Hi there,



How can I assign a user role of SQLAgentOperatorRole.

I tried with sp_addsrvrolemember but failed.



Thanks

Rahul

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved