Setting Datetime Variable W/ Mm/dd/yyyy

Jul 19, 2007

I am having the wrost trouble with this today for some dumb reason...
Please don't suggest any alternates; this is just a quick example, full code is more elaberate.

Today is 07/19/2007
Declare @StartDate DateTime
@StartDate = CONVERT(VARCHAR(10), Month(GetDate()) & "/22/" & Year(GetDate()), 101)

So I want @StartDate = '07/22/2007'

What I need is CDate

View 6 Replies


ADVERTISEMENT

Datetime Format Setting --&&> Mm-dd-yyyy Instead Of Dd-MM-yyyy In SQL Server 2005 / Expre(is It With Sql Server Login Language ??)

Aug 26, 2007

I€™m getting a datetime format problem(mm-dd-yyyy for dd-MM-yyyy), when I install SQL Server 2005 Express. {The exception is: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.}
My windows Regional and Language options €“ English (United Kingdom), Sort date format is dd-MM-yyyy.
When converting the date time in Sql server is using the mm-dd-yyyy format. But I€™m supplying the dd-mm-yyyy format date time.

I tried number of things none of them worked for me


1. Tried changing the default language and get the date time format
- exec sp_configure 'default language', 2057
reconfigure
- did not work
EXEC sp_defaultlanguage 'my user name', 'British'
- did not work
(Ref: http://www.cactushop.com/support/UKUS-date-format-issues-with-MS-SQL---conversion-errors-or-blank-pages__592__.htm)

2. Tried a registry hack by opening regedit, and get the following 3 language keys and change it to decimal 2057:
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL Server90ToolsClientSetupCurrentVersion]
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL Server90ToolsSetup
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL ServerMSSQL.1Setup]
(Ref: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=62891)
- did not work

3. Every thing in the Regional and Language options to UK and British with the date time format input language keyboard and every think else I could think of, which could link to US English or US date format --------- Did not work

4. even went into the extend of modifying the date format on a Windows machine for new users account by editing the HKEY_USERS registry key and creating a new user - Did not work
(Ref: http://www.windowsitpro.com/Article/ArticleID/39407/39407.html )


5. Uninstall and reinstall SQL server express several time and did the steps 1 €“ 4 where applicable €“ did not work€¦.

If anyone has any idea of what I have to do to change the date time format in the SQL Server 2005 to use the dd-mm-yyyy format for dates....
Please help me or point me in the direction in which I have to look for an answer.
Thank you very much€¦.

View 9 Replies View Related

Datetime To Dd/MM/yyyy For Inserting Into DB

Jul 1, 2007

hi there, i have a calendar that i put into a string ilke this
string str = Calendar1.SelectedDate.ToShortDateString();
the result is dd/mm/yyyy date which is great, but for inserting into my DB (MSSQL) it needs to be a datetime field, however when i convert it
Datetime dtDate = Convert.ToDateTime(str);
it takes my date and adds 00:00:00 onto the end and this is not what i want! i just want the dd/mm/yyy how do i do this, it has to be simple but i have been searching for hours and cant find anything, i am using ASP.NET 2 and C#
Thanks

View 3 Replies View Related

DATETIME To Format Mm/dd/yyyy Hh:mm Am/pm

Aug 8, 2007



I have a column in a database set as a DATETIME datatype, when I select it, I want to return it as:


mm/dd/yyyy hh:mm am or pm.

How in the world can I do this? I looked at the function CONVERT() and it doesnt seem to have this format as a valid type. This is causing me to lose my hair, in MySQL it is just so much easier. .

At any rate, currently when I select the value without any convert() it returns as:

June 1 2007 12:23AM

Which is close, but I want it as:

06/01/2007 12:23AM

Thanks!

View 11 Replies View Related

How To Convert A Varchar To A Yyyy-mm-dd Datetime?

May 27, 2008

Hi All,

I have a table called Table1 with a field Date (varchar type). The records are like this;

05/21/08
07/02/08
06/04/08
06/10/08


I want to convert the above into datetime (yyyy-mm-dd format)....in the above example my output should be;

2008-05-21
2008-07-02
2008-06-04
2008-06-10

How can i do this?

Please help.

Zee...

View 2 Replies View Related

How To Stored A Date Having Dd/MM/yyyy Into The SQLServer 2005 Having MM/dd/yyyy

Apr 30, 2008

Anyone please suggest me that , I have a text box where I am entering th date in dd/MM/yyyy format.
But the default field in my SqlServer2005 is MM/dd/yyyy.
How can i insert it into the database. or how can i change the MM/dd/yyyy of database to dd/MM/yyyy
 
Please, its urgent.
Thanks in advance
Regards
Tapan

View 14 Replies View Related

Convert 'dd.mm.yyyy' String To Mm/dd/yyyy Date

Nov 30, 2007

Hi!

Is it possible to convert a 'dd.mm.yyyy' string into an mm/dd/yyyy date using convert or cast?The date format set on the sql server is mm/dd/yyyy...

Thanks!

View 6 Replies View Related

Datepicker Transposes Dates From Dd/mm/yyyy To Mm/dd/yyyy

Mar 31, 2008

We are having problems with a new PC, we have installed oracle 10g client, Toad, and SQLServer2005 BITools
PC regional settings set to en-NZ( we need date format to be dd/mm/yyyy)
BITools/tools/options/international settings language = Same as Microsoft Windows

Ran a simple query(against oracle db) using between with 2 date parameters one parameter is datatype string the other datetime. When previewing report string is entered 01/03/2008 and datetime param is entered by choosing from datepicker, when view report button is clicked the datetime param is transposed whereas the string param remains unchanged.

The problem seems to be the datepicker not picking up on regional date format.

This is a new PC with xp-sp3 and the above software installed.

View 1 Replies View Related

Variable Insert To SQL Server Insert Satement Setting Values For The @variable INSIDE Sql

Apr 29, 2007

ok, I am on Day 2 of being brain dead.I have a database with a table with 2 varchar(25) columns I have a btton click event that gets the value of the userName,  and a text box.I NEED to insert a new row in a sql database, with the 2 variables.Ive used a sqldatasource object, and tried to midify the insert parameters, tried to set it at the button click event, and NOTHING is working. Anyone have a good source for sql 101/ASP.Net/Braindead where I can find this out, or better yet, give me an example.  this is what I got <%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">     protected void runit_Click(object sender, EventArgs e)    {       //SqlDataSource ID = "InsertExtraInfo".Insert();      //SqlDataSource1.Insert();    }      protected void Button1_Click1(object sender, EventArgs e)    {        SqlDataSource newsql;                newsql.InsertParameters.Add("@name", "Dan");        newsql.InsertParameters.Add("@color", "rose");        String t_c = "purple";        string tempname = Page.User.Identity.Name;        Label1.Text = tempname;        Label2.Text = t_c;        newsql.Insert();    }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>mini update</title></head><body>    <form id="form1" runat="server">        &nbsp;name<asp:TextBox ID="name" runat="server" OnTextChanged="TextBox2_TextChanged"></asp:TextBox><br />        color        <asp:TextBox ID="color" runat="server"></asp:TextBox><br />        <br />        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="Button" />        &nbsp;<br />        set lable =&gt;<asp:Label ID="Label1" runat="server" Text="Label" Width="135px" Visible="False"></asp:Label><br />        Lable 2 =&gt;        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label><br />        Usernmae=&gt;<asp:LoginName ID="LoginName1" runat="server" />        <br />        <br />        <br />        <br />        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"            ConnectionString="<%$ ConnectionStrings:newstring %>" DeleteCommand="DELETE FROM [favcolor] WHERE [name] = @original_name AND [color] = @original_color"            InsertCommand="INSERT INTO [favcolor] ([name], [color]) VALUES (@name, @color)"            OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [name], [color] FROM [favcolor]"            UpdateCommand="UPDATE [favcolor] SET [color] = @color WHERE [name] = @original_name AND [color] = @original_color">            <DeleteParameters>                <asp:Parameter Name="original_name" Type="String" />                <asp:Parameter Name="original_color" Type="String" />            </DeleteParameters>            <UpdateParameters>                <asp:Parameter Name="color" Type="String" />                <asp:Parameter Name="original_name" Type="String" />                <asp:Parameter Name="original_color" Type="String" />            </UpdateParameters>            <InsertParameters>        <asp:InsertParameter("@name", "Dan", Type="String" />        <asp:InsertParameter("@color", "rose") Type="String"/>                                       </InsertParameters>        </asp:SqlDataSource>        &nbsp;        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"            AutoGenerateColumns="False" DataKeyNames="name" DataSourceID="SqlDataSource1">            <Columns>                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />                                <asp:BoundField DataField="color" HeaderText="color" SortExpression="color" />                <asp:BoundField DataField="name" HeaderText="name" ReadOnly="True" SortExpression="name" />            </Columns>        </asp:GridView>           </form></body></html>  

View 1 Replies View Related

Date Convert From Yyyy-mm-dd To Dd/mm/yyyy

Jun 14, 2007

Hi to ALL
Here I am using .net 2.0 and MS SQL 2K. In our database table DateTime saved as in the format of 2007-01-31 8:33:19.000(yyyy-mm-dd) to access to this records by searching based on Date, when we are searching based on Date that Date format would be (dd/mm/yyyy). How we can convert the date format.

Data Base Date Format: 2007-01-31 (yyyy-mm-dd)
Search Criteria Date Format: 31/01/2007 (dd/mm/yyyy)

I have written following Code: Pls suggest me whether its correct r not
----------------------------------------------------------------------------
Select distinct tbl_adminuser.adminUserName,tbl_adminCategory.Name, COUNT(dbo.tbl_outbox.msgUserID) As

TotalCount

FROM dbo.tbl_adminuser,dbo.tbl_AdminCategory, dbo.tbl_outbox

where tbl_adminuser.adminUserID = dbo.tbl_AdminCategory.CatID and tbl_AdminCategory.CatID =

dbo.tbl_outbox.msgUserID

and tbl_outbox.msgUserID <> 0 and Convert(varchar,tbl_outbox.msgDate,103)>=@fromdate and
convert(varchar,tbl_outbox.msgDate,103)<=@todate
group by tbl_adminuser.adminUserName, dbo.tbl_AdminCategory.Name
--------------------------------------------------------------------------------------


Thanks in Advance
Bashu

View 4 Replies View Related

SETTING VARIABLE

Aug 27, 2006

sry im an idiotbut how do u take like "SELECTbla FROM blar WHERE blam=blfda" and make the thing it "selects" into a variable thnx 

View 5 Replies View Related

Setting A @db Variable

Jul 6, 2004

Hi, I have this query basically im trying to set the @db to the current database depending on the quarter. This will be used in a package to change the database that the package will use.

DECLARE @db nVarchar(4000)
SET @db = N'TESTDB' + RIGHT(DATEPART(yy, GETDATE()), 2) + '_' + CASE WHEN DATEPART(m, GETDATE()) IN ('11', '12', '1')
THEN 'Q1' ELSE CASE WHEN DATEPART(m, GETDATE()) IN ('2', '3', '4') THEN 'Q2' ELSE CASE WHEN DATEPART(m, GETDATE()) IN ('5', '6', '7')
THEN 'Q3' ELSE CASE WHEN DATEPART(m, GETDATE()) IN ('8', '9', '10')
THEN 'Q4' END END END END
EXECUTE sp_executesql @db, N'@level tinyint', @level = 35

I get the error Incorrect Syntax near 'TESTDB04_Q3'.

View 3 Replies View Related

Setting Variable Value

Jun 21, 2006

hi !

I am trying to set the variables value through Execute SQL task and create directory through the FileSystemTask by setting the user variable as source. The User variable has the Directory path to create the directory, but when i set the source as the user variable it complains that its value is empty.

Execute SQL TAsk happens to work correctly when i check the watch window the user variable is set correctly . but value is not setting in the SSIS/Variable window Value.

What is wrong an what method should i use to set the variables value to create directory.

Thanks,

aaks

View 5 Replies View Related

DateTime Format Problem: Setting To 16/Mar/2006 8:50:00 AM

Aug 2, 2006

my Current DateTime Format is         01/08/2006 9:15:00 AM
i want to set it to                                01/Aug/2006 9:15:00 AM
what parameter will be pass in "SET DATEFORMAT"?
plz help and give me a chance of thanks.
 

View 7 Replies View Related

Need Help Setting Default DateTime On SqlDataSource Control

Jan 21, 2007

I thought this would be easy.  I have a repeater control and a sqldatasource control.  I am trying to filter the select statement using DateTime.Now.ToString() and keep getting an invalid date string format.  The control is on a content page in my asp.net site.  On the master page this <%= DateTime.Now.ToLongDateString() %>  works to display the current date.  If I try and put <%= DateTime.Now.ToString() %> in the Default value of the SelectParameter it does not work.  No intellisense either so I am assuming I am missing something.  Here is the code... pretty basic really.
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="sqlDSnews">
<ItemTemplate>
<h3><%# Eval("newTitle")%></h3>
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource
ID="sqlDSnews"
runat="server"
ConnectionString="<%$ ConnectionStrings:XXXX%>"
SelectCommand="SELECT [newTitle], [newsDetails], [dateExpires], [newsImage], [dateCreated] FROM [News] WHERE (([GroupID] = @GroupID) AND ([dateExpires] >= @dateExpires))">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="0" Name="GroupID" QueryStringField="Gid" Type="Int32" />
<asp:Parameter Name="dateExpires" DefaultValue='<%= DateTime.Now.ToString() %> 'Type="DateTime" />
</SelectParameters>
</asp:SqlDataSource>
** NOTE the DateTime does not show up in blue - if that helps with a solution **

View 5 Replies View Related

Transact SQL :: Cast Or Convert Date In Format YYYY-MM-DD Into New Format Of MM/DD/YYYY?

Nov 27, 2015

I have a table that has a DATE field named. AccountingDate that is in the format YYYY-MM-DD. It's not a VARCHAR field. I simply want to convert this date field into the format MM/DD/YYYY and call it New_Accounting_Date.

I've played with various combinations of CAST & CONVERT but haven't been able to get it to work.

Below is my latest effort which returns the error:

Incorrect syntax near the keyword 'as'

What code would work to return a MM/DD/YYYY value for New_Accounting_Date?

Select GLBATCH.AccountingDate,
convert(GLBATCH.AccountingDate as date),101) AS New_Accounting_Date
from GLBATCH

View 11 Replies View Related

Simple DB ? , Getting A Value And Setting As A Variable.

May 12, 2008

Hi, folks. As part of a larger bunch of code, I am trying to validate some user form input against a database...I've been picking apart code samples and have the following (currently not yet working) code to show for it. I find tons of complex examples out there RE the data controls, and I have those working. But I can't find any examples of just pulling a single record from a DB, sticking it in a variable, and then checking against that variable to get a boolean response. Anyway, here is the code. I am trying to check that a password field filled by the user matches the value located in the DB. I am not married to this code; if someone suggests a better way to do it rather than using a custom validator control, that's fine too:BEGIN CODE SNIPvoid Page_Load(object sender, EventArgs e)
{
Page.Validate();
SqlDataSource1.SelectCommand = "SELECT Password FROM aspnet_Membership WHERE aspnet_Membership.Email='" + emailID.Text + "'";
}

private void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
//between this and the next comment is where I have to get the DB Password field value for the current record
SqlCommand command = new SqlCommand("SELECT Password FROM aspnet_Membership WHERE aspnet_Membership.Email='" + emailID.Text + "'");
command.CommandType = CommandType.StoredProcedure;
sqlConnection.Open();
reader=command.ExecuteReader();
string currentPasswordDb = reader.IsDBNull(reader.GetString("Password"))? null: reader["Password"].ToString();
args.IsValid = false; // Assume False
{
// Compare db entry against user's entry
if (currentPasswordDb == currentPassword.Text)
{
args.IsValid = true;
}
}
}  END CODE SNIP The code above give me the following at runtime:Line 14: SqlCommand command = new SqlCommand("SELECT Password FROM aspnet_Membership WHERE aspnet_Membership.Email='" + emailID.Text + "'");Line 15: command.CommandType = CommandType.StoredProcedure;Line 16: sqlConnection.Open();Line 17: reader=command.ExecuteReader();Line 18: string currentPasswordDb = reader.IsDBNull(reader.GetString("Password"))? null: reader["Password"].ToString();Although I'm sure it won't be the last. I'm a former ASP classic developer, moving to c# and .Net. Any ideas? 

View 4 Replies View Related

Run Time Variable Setting

Aug 25, 2006

Hi,

I want to execute a BAT file using Execute Process task, where I want to select the file path (directory) dynamically using a variable whose value is set at runtime.

In simple terms I want to send a value to the "Executable" property dynamically

Can some one help me on this

View 3 Replies View Related

Setting A Variable In A For Loop

Jan 30, 2008



The For Loop will execute a stored procedure that passes a variable each time it loops. I need to set this variable, @FiscalWeek, equal to the variable @Counter. So the first time it loops, the counter will be 1, and the Fiscal Year would be set to 1. The next time it would be two, and so forth. Can I do this in the Expressions section of the For Loop? If so,
what would the property be?


InitExpression @Counter =0
EvalExpression @Counter == @CurFiscalWeek
AssignExpression @Counter = @Counter + 1

View 1 Replies View Related

Setting Result To A Variable

Jan 16, 2008



Hi,
below is the sql statements for my web service using C#.




Code Block
string sql = "SELECT TOP 1 Pos FROM" + "TABLE1" +"ORDER BY Pos ASC"

SqlCommand comm = new SqlCommand(sql, conn);




Now if i want to set the Pos to a variable where i can call at another part of my program, how do i do that?

View 5 Replies View Related

How To Convert UTC Based Datetime Values To Local Setting?

Sep 11, 2007

Hello:

I've recently discovered the MS CRM 3.0 stamps any datetime field in SQL as UTC (aka GMT). Even though the end user may select 12:00 noon on the CRM gui interface, the datetime is stamped in SQL as 16:00 (I'm in EST).

So, is there an easy way to read the 16:00 back to local EST, taking into account daylightsavings (DST)? Apparently in VB or C# this conversion is a trivial matter of using ToLocalTime(), but I don't believe SQL 2005 has such a convenient function.

I'm currently building a SQL view that I wish to use to support multiple reports, and it would be ideal for the view to translate the UTC datetime fields (even if via a user-defined function) to EST rather than coding every report or custom app to translate the UTC.

Any suggestions or links to code will be greatly appreciated!

Thanks,
Pete

View 5 Replies View Related

Setting The Value Of A Variable In A Select Statment...

Oct 19, 2001

I want to be able to have a single select statment:

SELECT TOP 1 Call.JobNum, Call.CallID, Call.Company, Call.LastCallTime
FROM ClientJob INNER JOIN Client ON ClientJob.ClientID = Client.ClientID
INNER JOIN Call INNER JOIN Login ON Call.JobNum = Login.JobNum ON ClientJob.JobNum = Login.JobNum
WHERE (Login.LoginID = 3) AND (Call.Status = 0) AND (DATEDIFF(hh, Call.LastCallTime, getdate()) > 10)
ORDER BY Call.CallID

but with this select statment I also want to set a variable:

declare @variable int

SELECT TOP 1 Call.JobNum, @variable = Call.CallID, Call.Company, Call.LastCallTime
FROM ClientJob INNER JOIN Client ON ClientJob.ClientID = Client.ClientID
INNER JOIN Call INNER JOIN Login ON Call.JobNum = Login.JobNum ON ClientJob.JobNum = Login.JobNum
WHERE (Login.LoginID = 3) AND (Call.Status = 0) AND (DATEDIFF(hh, Call.LastCallTime, getdate()) > 10)
ORDER BY Call.CallID

Now SQL Server does not like this, can not set a variable in a multiple select statment. I NEED to do this all in one step if possible. Any suggestions?

pat

View 1 Replies View Related

Setting SQL_VARIANT_PROPERTY Return To A Variable

Jan 31, 2007

Why does this not work?

declare @ret varchar(50)
DECLARE @X SQL_VARIANT
set @X=10
SET @ret=select SQL_VARIANT_PROPERTY(@X,'BaseType')

Just trying to assign the SQL_VARIANT_PROPERTY return value to @ret and it issues an error: Implicit conversion from data type sql_variant to varchar is not allowed. Use the CONVERT function to run this query.


But I don't want to convert I just want to assign the result to the variable.

what's confusding is that you can do this:
if(select SQL_VARIANT_PROPERTY(@X,'BaseType'))='int'

So I assume I should b able to do the above.

--PhB

View 1 Replies View Related

Problem With Setting A Variable In SQL String

Jul 20, 2005

Hi,I am having problems setting the value of a variable in a SQL Stringthat I have to create dynamically in my procedure. The code that Icurrently have is as follows:set @sqlStatement='Set @compare_string=' + '(Select ' +@group_column_list_mod + ' from ' + @Tbl_Name + '_Sorted' + ' whereIdentity_Column=' + ltrim(rtrim(str(@loop_counter))) + ')'exec(@sqlStatement)The error message that I get is as follows:Must declare the variable '@compare_string'.Here @compare_string has already been declared in the procedure and Idon't have a problem using the variable anywhere else but this SQLStatement (when called using the EXEC function).I am not sure why SQL Server can't see the variable declared when usedin a string in conjunction with EXEC. Is this a syntax issue? Any helpon this issue would be greatly appreciated!Thanks in advance.

View 5 Replies View Related

Setting Package Variable Using Dtexec

Feb 15, 2008

Hi,

If this is the syntax to set a property in a package using dtexec:

/set PackageMyForEachLoopMyDataFlow.Disable;False

What is the syntax for setting a global variable in the package?

Thanks

View 1 Replies View Related

Setting BufferTempStoragePath From Package Variable

Jan 8, 2008

I'm in the process of creating a series of packages to do the ETL for a datawarehouse. As such, I've got quite a few DataFlow tasks scattered through them.

The problem I'm coming across is where the disk that the temp files (created during the processing) are put on is short of space (when compared to some of the data sets I'm copying around and noting that it's the System disk, not the "Data Drive").

To get around this, I found number of article scattered around that suggested using the BufferTempStoragePath property of the DataFlow tasks to redirect the temp files to somewhere else. This works fine for the tasks that I hard-code the new directory.

Noting the number of these tasks that I want to redirect, and also that the Dev environment will be different to the Production environment (and I have no control over the drive letters, paths, etc, in Prod), it was suggested that a package variable be created, assigned to the property and then said variable could be exposed via the Package Configuration file.

That's great as far as it goes, but I just cannot, for some reason, make it work.

The xml in the config file is:

<Configuration ConfiguredType="Property" Path="Package.Variables[::BufferTempStoragePathValue].Properties[Value]" ValueType="String">
<ConfiguredValue>D:Temp</ConfiguredValue>
</Configuration>

The property in the DataFlow task is then set to: @BufferTempStoragePathValue.


When the package is executed, it logs the error message "The buffer manager cannot create a temporary storage file on any path in the BufferTempStoragePath property. There is an incorrect file name or no permission."

My question for the group is two-fold: 1) what am I doing wrong in the setup of the property/variable, and 2) what are the security permissions that are required for the (new) folder.

It's got to be something obvious, I just can't see what!

Many thanks for your assistance.

Cheers,
Mike

View 6 Replies View Related

Setting A Variable In A Foreach ADO Enumerator

Sep 13, 2006

Hi,

im using a Foreach ADO Enumerator in my SSIS Package, which iterate on a DataSet from a SQL Task.

I use the "Variable Mappings" on my Foreach Loop to retrieve the values into User-variables. But what i need is a way to combine a value from the DataSet with a User-variable and assign this new value to a new User-variable.

Anybody tried something like this?

Regards, Martin

View 2 Replies View Related

Setting User Variable Dynamically

May 24, 2007

Hi,

I have a package that uses a variable string (in date format) to execute a package.

I want to modify that variable in such a way that if no value is set for that variable then use system date else use date in varaiable.



Can someone help me out in this.. I know it has something to do with the expression builder but donn know how to do it.



Cheers

View 5 Replies View Related

Problem With Setting Variable Values In A Loop

Sep 11, 2007

In a stored procedure that I'm fixing, there is a problem with assigning variable values inside a loop. The proc is using dynamic SQL and if statements to build all these statements, but I'm having to add a new variable value to it that is throwing it out of whack.

This is the current structure:

SET @MktNbr = 10

WHILE @MktNbr < 90

BEGIN

DECLARE@sqlstmt varchar(1000)

SET @Market = '0' + CONVERT(char(2),@MktNbr)

SET @sqlstmt = 'SELECT (columns)
INTO dbo.table' + @Market + '
FROM #table
WHERE marketcode = ''' + @Market + '''
IF @MktNbr = 50
BEGIN
SET @MktNbr = 51
END
ELSE
IF @MktNbr = 51
BEGIN
SET @MktNbr = 52
END
ELSE
IF @MktNbr = 52
BEGIN
SET @MktNbr = 55
END
ELSE
IF @MktNbr = 55
BEGIN
SET @MktNbr = 60
END
ELSE
BEGIN
SET @MktNbr = @MktNbr + 10
END
EXEC (@sqlstmt)


END


I'm probably having a blonde moment, but I'm trying to replace the if statements with this:

SET @MktNbr =
CASE
WHEN @MktNbr = 10 THEN 20
WHEN @MktNbr = 20 THEN 30
WHEN @MktNbr = 30 THEN 40
WHEN @MktNbr = 40 THEN 50
WHEN @MktNbr = 50 THEN 51
WHEN @MktNbr = 51 THEN 52
WHEN @MktNbr = 52 THEN 55
WHEN @MktNbr = 55 THEN 60
WHEN @MktNbr = 60 THEN 70
WHEN @MktNbr = 70 THEN 80
WHEN @MktNbr = 80 THEN 81
ELSE @MktNbr END

Clearly it's wrong because the proc bombs every time with a duplicate table error.

It has been suggested to me that I should hold these market values in an external table. This sounds reasonable but I'm ashamed to admit that I don't know how I'd implement that. Can someone maybe give me a nudge in the right direction?

View 14 Replies View Related

Setting Variable Parameters In A SSRS Subscription

Nov 7, 2007

I would like to set up a subscription that has two date parameters, I would like the end_date to be today and the start_date to be (today - 1 Month). The interface does not seem to support expressions?

I saw some documentation that said to use defaults in the report but that does not help because I may want multiple subscriptions with different params like 1 person may want (today - 2 months) as the start date ...

Any help would be appreciated

View 9 Replies View Related

Setting Variable Values From Within A Data Flow

Feb 15, 2008

Hello There:
I am running a data flow within a ForEach loop wherein I am computing a value called QuotaGap. When it is 0 I do not want any further execution of the loop. I am using a Conditional Transform within this dataflow that writes a record to a table only when the QuotaGap is NOT 0. However, I am unable to terminate the execution of the loop as I am still within the dataflow.

Now, the computation of the gap requires a value from another variable called NetPurchases. I tried using an ExecuteSQL task in the control flow but could not figure out how to pass the value of the variable NetPurchases into the select statement to compute the gap. For example, the select statement would read:


select (QuotaUpperLimit - ?) As QuotaGap from <<tablename>>

I tried setting the parameter as an input as well as an output and it did not work.

Then I tried passing the entire SQL as a string within a variable. This does not work either because in order to compute the math QuotaUpperLimit - NetPurchases, both variables need to be integers but then you cannot concatenate integres together, which is what we need to do to create the SQL.

The other reason I am going through these hoops I guess is that I have not figured out a way to set the value of a variable within a data flow. I compute the value for QuotaGap within the dataflow in a ForEach loop but I have no way to pass this result to a variable called QuotaGap without using an ExecuteSQL task or another ForEach Loop.


I have spent hours on this simple issue and so have given up and looking to the good friends in this forum for help.

If what I have stated is not clear please let me know and I will try to clarify things a bit.

Thanks!

View 7 Replies View Related

Setting A Value Of The Query Result To Scalar Variable

Mar 26, 2006

Hi!

Is it possible to set a query result (scalar) to scalar variable. I would like to set a qery result (SELECT COUNT(*) FROM MyTable) to a scalar variable:

DECLARE @temp int

SET @temp = query result...

Is it possible? I couldn't find the way to do that...

View 1 Replies View Related

Setting The Global Variable Values In SSIS

May 27, 2008

Hi,
I am trying to create an SSIS package but am not able to set the global variable values.

I want to have a Global Variable as @EventID

and the create a Execute SQL Task which will run this query:

SELECT Max(EventID)
FROM EventTable

and assign this Max value to the global variable @EventID


How can I achieve this...help me please


Regards,

Nusrath

View 1 Replies View Related







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