Showing posts with label variable. Show all posts
Showing posts with label variable. Show all posts

Monday, March 26, 2012

How to determine output format during rendering?

Is there a "global" variable I could test for the output format? I need to change styles/formats for a report based on whether its XML, Excel or CSV. There has to be a better way instead of developing reports for a specific format, in other words, I would like one report instead of multiple versions.

Any suggestions would be helpful.

Bob

Hi,

no so far there is no render-specific format. You will have to design the report for the appropiate format or produce a report to fit all rendering formats.

HTH, Jens SUessmeyer.


http://www.sqlserver2005.de

sql

Monday, March 19, 2012

How to design SP with variable number of params?

I have a form that allows a user to update contact info. For example:
First name
Last name
PO Box
City
State
There are actually more fields (up to 50) but I have only used five for
simplicity. Sometimes a user will submit an update for all fields.
However, for a web service, some one may only send the First Name or any
other one field. In that case, is it better to design an SP for each case?
I see that having scaling issues.
Another approach is to design one SP with many conditionals (50). Both
approaches are inefficient. What is a better way?
Thanks,
BrettSpecify default values for your parameters. I.e.,
CREATE PROCEDURE sample
@.paramLast VARCHAR(30) = NULL, -- NULL default value
@.paramFirst VARCHAR(30) = NULL, -- NULL default value
@.paramPoBox VARCHAR(30) = NULL,
@.paramCity VARCHAR(30) = '', -- Empty string default value
@.paramState CHAR(2) = 'NY' -- 'NY' default value
It will be a little tedious for 50 fields, but will allow you to not specify
parameters on calling.
"Brett" <no@.spam.net> wrote in message
news:OkwoMaUGFHA.2676@.TK2MSFTNGP12.phx.gbl...
>I have a form that allows a user to update contact info. For example:
> First name
> Last name
> PO Box
> City
> State
> There are actually more fields (up to 50) but I have only used five for
> simplicity. Sometimes a user will submit an update for all fields.
> However, for a web service, some one may only send the First Name or any
> other one field. In that case, is it better to design an SP for each
> case? I see that having scaling issues.
> Another approach is to design one SP with many conditionals (50). Both
> approaches are inefficient. What is a better way?
> Thanks,
> Brett
>|||Michael C# wrote:
> Specify default values for your parameters. I.e.,
> CREATE PROCEDURE sample
> @.paramLast VARCHAR(30) = NULL, -- NULL default value
> @.paramFirst VARCHAR(30) = NULL, -- NULL default value
> @.paramPoBox VARCHAR(30) = NULL,
> @.paramCity VARCHAR(30) = '', -- Empty string default
> value @.paramState CHAR(2) = 'NY' -- 'NY' default
> value
> It will be a little tedious for 50 fields, but will allow you to not
> specify parameters on calling.
>
I'm not sure that will work for the OP for updating.
Specify all updatable values in the parameter list. 50 is a lot, and I
might question the number of attributes on the underlying table. Unless
you're dealing with more than one table and could break up the updates
in a meaningful way.
David Gugick
Imceda Software
www.imceda.com|||Commonly we would just update all data on an update in the stored procedure
unless there is a great reason not to. You could do something like:
CREATE PROCEDURE TABLE_UPDATE
@.LastName VARCHAR(30) = NULL,
@.FirstName VARCHAR(30) = NULL,
as
update table
set lastName = coalesce(@.lastName, lastName),
firstName = coalesce(@.firstName, firstName)
go
Then if you call it with table_update @.firstName ='Bob'
The current value of lastName will be used, and the new value for
@.firstName.
----
Louis Davidson - drsql@.hotmail.com
SQL Server MVP
Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design -
http://www.apress.com/book/bookDisplay.html?bID=266
Blog - http://spaces.msn.com/members/drsql/
Note: Please reply to the newsgroups only unless you are interested in
consulting services. All other replies may be ignored :)
"Brett" <no@.spam.net> wrote in message
news:OkwoMaUGFHA.2676@.TK2MSFTNGP12.phx.gbl...
>I have a form that allows a user to update contact info. For example:
> First name
> Last name
> PO Box
> City
> State
> There are actually more fields (up to 50) but I have only used five for
> simplicity. Sometimes a user will submit an update for all fields.
> However, for a web service, some one may only send the First Name or any
> other one field. In that case, is it better to design an SP for each
> case? I see that having scaling issues.
> Another approach is to design one SP with many conditionals (50). Both
> approaches are inefficient. What is a better way?
> Thanks,
> Brett
>|||there is one thing that bothers me with this approach (regardles of number
of fields). the thing is that on update, event if the value for the column
is unchanged, the constraints are being checked all the same. eg, if there
is a foreign key constraint, updating a fk column (with the same value, thus
in fact not updating at all) will cause a lookup in the referenced table,
which is absolutely unnecessary, imho. but the alternatives - dynamically
constructing the update statement, or creating a separate statement for
every combination of params - make even less sense.
any thoughts?
dean
"Louis Davidson" <dr_dontspamme_sql@.hotmail.com> wrote in message
news:%23sEA5TWGFHA.4088@.TK2MSFTNGP09.phx.gbl...
> Commonly we would just update all data on an update in the stored
procedure
> unless there is a great reason not to. You could do something like:
> CREATE PROCEDURE TABLE_UPDATE
> @.LastName VARCHAR(30) = NULL,
> @.FirstName VARCHAR(30) = NULL,
> as
> update table
> set lastName = coalesce(@.lastName, lastName),
> firstName = coalesce(@.firstName, firstName)
> go
> Then if you call it with table_update @.firstName ='Bob'
> The current value of lastName will be used, and the new value for
> @.firstName.
>
> --
> ----
--
> Louis Davidson - drsql@.hotmail.com
> SQL Server MVP
> Compass Technology Management - www.compass.net
> Pro SQL Server 2000 Database Design -
> http://www.apress.com/book/bookDisplay.html?bID=266
> Blog - http://spaces.msn.com/members/drsql/
> Note: Please reply to the newsgroups only unless you are interested in
> consulting services. All other replies may be ignored :)
> "Brett" <no@.spam.net> wrote in message
> news:OkwoMaUGFHA.2676@.TK2MSFTNGP12.phx.gbl...
>|||This seems to be the best approach of the posts here. I see there probably
isn't a way to get around conditionals for NULL checks. coalesce is a type
of conditional but probably better than using multiple IF statements
correct?
Thanks,
Brett
"Louis Davidson" <dr_dontspamme_sql@.hotmail.com> wrote in message
news:%23sEA5TWGFHA.4088@.TK2MSFTNGP09.phx.gbl...
> Commonly we would just update all data on an update in the stored
> procedure unless there is a great reason not to. You could do something
> like:
> CREATE PROCEDURE TABLE_UPDATE
> @.LastName VARCHAR(30) = NULL,
> @.FirstName VARCHAR(30) = NULL,
> as
> update table
> set lastName = coalesce(@.lastName, lastName),
> firstName = coalesce(@.firstName, firstName)
> go
> Then if you call it with table_update @.firstName ='Bob'
> The current value of lastName will be used, and the new value for
> @.firstName.
>
> --
> ----
--
> Louis Davidson - drsql@.hotmail.com
> SQL Server MVP
> Compass Technology Management - www.compass.net
> Pro SQL Server 2000 Database Design -
> http://www.apress.com/book/bookDisplay.html?bID=266
> Blog - http://spaces.msn.com/members/drsql/
> Note: Please reply to the newsgroups only unless you are interested in
> consulting services. All other replies may be ignored :)
> "Brett" <no@.spam.net> wrote in message
> news:OkwoMaUGFHA.2676@.TK2MSFTNGP12.phx.gbl...
>|||"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:%2359VcIWGFHA.524@.TK2MSFTNGP14.phx.gbl...
> Michael C# wrote:
> I'm not sure that will work for the OP for updating.
>
Why not? Here's an example of a stored procedure, with a variable number of
params, that updates a table.
--Create Table and Primary Key
CREATE TABLE [dbo].[Table1] (
[IDNum] [int] NOT NULL ,
[LastName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[FirstName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Table1] WITH NOCHECK ADD
CONSTRAINT [PK_Table1] PRIMARY KEY CLUSTERED
(
[IDNum]
) ON [PRIMARY]
GO
--Populate table
INSERT INTO Table1 (IDNum, LastName, FirstName) VALUES (0, 'Jetson',
'George')
INSERT INTO Table1 (IDNum, LastName, FirstName) VALUES (1, 'Flintstone',
'Fred')
INSERT INTO Table1 (IDNum, LastName, FirstName) VALUES (2, 'Rubble',
'Barney')
GO
--Create stored procedure with variable number of parameters
CREATE PROCEDURE usp_UpdateRecord
@.paramID INT,
@.paramLast VARCHAR(50) = NULL,
@.paramFirst VARCHAR(50) = NULL
AS
UPDATE Table1 SET LastName = @.paramLast
WHERE IDNum = @.paramID
AND @.paramLast IS NOT NULL
UPDATE Table1 SET FirstName = @.paramFirst
WHERE IDNum = @.paramID
AND @.paramFirst IS NOT NULL
GO
--Now call the stored procedure with a variable
--number of parameters each time
EXEC usp_UpdateRecord @.paramID = 0, @.paramLast = 'Johnson'
EXEC usp_UpdateRecord @.paramID = 1, @.paramFirst = 'Wilma'
EXEC usp_UpdateRecord @.paramID = 2, @.paramLast = 'Public', @.paramFirst =
'John'
GO

> Specify all updatable values in the parameter list. 50 is a lot, and I
> might question the number of attributes on the underlying table. Unless
> you're dealing with more than one table and could break up the updates in
> a meaningful way.
>
> --
> David Gugick
> Imceda Software
> www.imceda.com|||I personally would not recommend you design a procedure to perform up to
50 distinct updates to update a single row in the table. Seems more work
and overhead than a single update to me.
David G.|||Are you talking about the overhead incurred when typing in the code once, or
the overhead incurred each time you UPDATE 50 fields in order to change one?
Michael C.
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:eunWozbGFHA.3112@.tk2msftngp13.phx.gbl...
>I personally would not recommend you design a procedure to perform up to 50
>distinct updates to update a single row in the table. Seems more work and
>overhead than a single update to me.
> --
> David G.
>|||Michael C# wrote:
> Are you talking about the overhead incurred when typing in the code
> once, or the overhead incurred each time you UPDATE 50 fields in
> order to change one?
> Michael C.
I just mean the possibly running up to 50 individual updates to satisfy
what a single update can do. Plus, the implementation does not allow you
to return a column value to NULL, if needed.
My only real point here is issuing a single update and supplying all
parameters is generally the easiest, most maintainable, and safest
implementation. If the OP has a component in ASP.net or his/her
fat-client app that automates the execution of the update, then he only
has to write it once.
David G.

Monday, March 12, 2012

How to deserialize matchData?

Hi,
I am having problems deserializing the matchData variable returned by the
GetSubscriptionProperties() method.
My matchData looks like this:
"<ScheduleDefinition><StartDateTime>2005-04-27T06:00:00.000-05:00</StartDateTime><WeeklyRecurrence><WeeksInterval>1</WeeksInterval><DaysOfWeek><Wednesday>True</Wednesday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>"
I found several code snippets from this newsgroup to figure out how to
convert this to a ScheduleDefinition object but everytime, it returns a
startdatetime of 1/1/1 and the "Item" part of the ScheduleDefinition object
is null...
code snippet I am currently using:
private ScheduleDefinition DeserializeObject (string sMatchData)
{
sMatchData MemoryStream vStream = new
MemoryStream(System.Text.Encoding.Default.GetBytes(sMatchData));
XmlAttributes attrs=new XmlAttributes();
attrs.XmlElements.Add(new
XmlElementAttribute("MinuteRecurrence",typeof(MinuteRecurrence)));
attrs.XmlElements.Add(new
XmlElementAttribute("DailyRecurrence",typeof(DailyRecurrence)));
attrs.XmlElements.Add(new
XmlElementAttribute("WeeklyRecurrence",typeof(WeeklyRecurrence)));
attrs.XmlElements.Add(new
XmlElementAttribute("MonthlyRecurrence",typeof(MonthlyRecurrence)));
attrs.XmlElements.Add(new
XmlElementAttribute("MonthlyDOWRecurrence",typeof(MonthlyDOWRecurrence)));
XmlAttributeOverrides attrOver=new XmlAttributeOverrides();
attrOver.Add(typeof(ScheduleDefinition),"ScheduleDefinition",attrs);
XmlSerializer newSr=new XmlSerializer(typeof(ScheduleDefinition),attrOver);
return (ScheduleDefinition)newSr.Deserialize(vStream);
}
Any help would be greatly appreciated... I am using this to display a
schedule on a web page. I can set subscriptions fine but I am having a hard
time reading them back.
I used the following code to set subscriptions and it works fine:
http://www.odetocode.com/Articles/114.aspx
Thanks in advance for any help!Never mind. I got it.
For those who are interested, call DeserializeObject() first.
private XmlAttributeOverrides GetScheduleOverrides ()
{
XmlAttributeOverrides overrides = new XmlAttributeOverrides();
XmlAttributes attrs = new XmlAttributes();
attrs.Xmlns = false;
overrides.Add(typeof(ScheduleDefinition), attrs);
overrides.Add(typeof(MinuteRecurrence), attrs);
overrides.Add(typeof(WeeklyRecurrence), attrs);
overrides.Add(typeof(MonthlyRecurrence), attrs);
overrides.Add(typeof(MonthlyDOWRecurrence), attrs);
overrides.Add(typeof(DaysOfWeekSelector), attrs);
overrides.Add(typeof(MonthsOfYearSelector), attrs);
return overrides;
}
private ScheduleDefinition DeserializeObject (string sMatchData)
{
sMatchData = sMatchData.Replace("True", "true");
Stream stream = new
MemoryStream(System.Text.Encoding.Default.GetBytes(sMatchData));
XmlAttributeOverrides overrides = GetScheduleOverrides();
XmlSerializer ser = new XmlSerializer(typeof(ScheduleDefinition),
overrides);
stream.Position = 0;
return (ScheduleDefinition)ser.Deserialize(stream);
}
"Pierrick" <email@.nospam.com> wrote in message
news:426f60d7$0$1254$8fcfb975@.news.wanadoo.fr...
> Hi,
> I am having problems deserializing the matchData variable returned by the
> GetSubscriptionProperties() method.
> My matchData looks like this:
> "<ScheduleDefinition><StartDateTime>2005-04-27T06:00:00.000-05:00</StartDateTime><WeeklyRecurrence><WeeksInterval>1</WeeksInterval><DaysOfWeek><Wednesday>True</Wednesday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>"
> I found several code snippets from this newsgroup to figure out how to
> convert this to a ScheduleDefinition object but everytime, it returns a
> startdatetime of 1/1/1 and the "Item" part of the ScheduleDefinition
> object is null...
> code snippet I am currently using:
> private ScheduleDefinition DeserializeObject (string sMatchData)
> {
> sMatchData MemoryStream vStream = new
> MemoryStream(System.Text.Encoding.Default.GetBytes(sMatchData));
> XmlAttributes attrs=new XmlAttributes();
> attrs.XmlElements.Add(new
> XmlElementAttribute("MinuteRecurrence",typeof(MinuteRecurrence)));
> attrs.XmlElements.Add(new
> XmlElementAttribute("DailyRecurrence",typeof(DailyRecurrence)));
> attrs.XmlElements.Add(new
> XmlElementAttribute("WeeklyRecurrence",typeof(WeeklyRecurrence)));
> attrs.XmlElements.Add(new
> XmlElementAttribute("MonthlyRecurrence",typeof(MonthlyRecurrence)));
> attrs.XmlElements.Add(new
> XmlElementAttribute("MonthlyDOWRecurrence",typeof(MonthlyDOWRecurrence)));
> XmlAttributeOverrides attrOver=new XmlAttributeOverrides();
> attrOver.Add(typeof(ScheduleDefinition),"ScheduleDefinition",attrs);
> XmlSerializer newSr=new
> XmlSerializer(typeof(ScheduleDefinition),attrOver);
> return (ScheduleDefinition)newSr.Deserialize(vStream);
> }
> Any help would be greatly appreciated... I am using this to display a
> schedule on a web page. I can set subscriptions fine but I am having a
> hard time reading them back.
> I used the following code to set subscriptions and it works fine:
> http://www.odetocode.com/Articles/114.aspx
> Thanks in advance for any help!
>

Sunday, February 19, 2012

How to defne a globale variable in the report

I want's to define some global contant variable which contains some values

Like Name="Abc"

Age=123

Date=12/12/2006

How can i define it on sql server reporting serices report and access it value to assign on some fields?

You could use hidden parameters with default values I guess.

1 - Add a parameter to your report and set it to the correct type (string / number etc) and mark it as hidden

2 - Set the default value that you want for it

3 - In your report, access it with something like "=Parameters!theParameter.Value"

Regards Andreas

|||

On the report properties, click on the Code tab and define it there, e.g.

Public Dim Age as Integer = 123

Then, you can reference it in the report as =Code.Age

|||

Which approach will be best for performance?

Can anybody give the pros and cons of the both approaches .

|||

If you want to be able to change the defined variables when calling a report it's good to have them as parameters. Lets say you programatically calls the report because you want to render a report in a WinForms app or something and want to be able to set the parameters from the winForms app, then the hidden parameter way is a good way I guess.

Otherwise, I suggest you do as Teo says.

Regards Andreas

|||

hi,

but parameters are readonly.

You cant set them through your custom code.

hemant

How to defne a globale variable in the report

I want's to define some global contant variable which contains some values

Like Name="Abc"

Age=123

Date=12/12/2006

How can i define it on sql server reporting serices report and access it value to assign on some fields?

You could use hidden parameters with default values I guess.

1 - Add a parameter to your report and set it to the correct type (string / number etc) and mark it as hidden

2 - Set the default value that you want for it

3 - In your report, access it with something like "=Parameters!theParameter.Value"

Regards Andreas

|||

On the report properties, click on the Code tab and define it there, e.g.

Public Dim Age as Integer = 123

Then, you can reference it in the report as =Code.Age

|||

Which approach will be best for performance?

Can anybody give the pros and cons of the both approaches .

|||

If you want to be able to change the defined variables when calling a report it's good to have them as parameters. Lets say you programatically calls the report because you want to render a report in a WinForms app or something and want to be able to set the parameters from the winForms app, then the hidden parameter way is a good way I guess.

Otherwise, I suggest you do as Teo says.

Regards Andreas

|||

hi,

but parameters are readonly.

You cant set them through your custom code.

hemant

How to define token syntax in MSSQL2005 sp1?

There is one token in my Agent Job $WMI(DatabaseName)

Now,I defined this using $(ESCAPE_NONE(WMI(DatabaseName)))

but failed and prompted: Variable WMI(DatabaseName) not found

What should i do for this? thanks

From the updated books online:

For jobs that run in response to WMI alerts, the value of the property specified by property. For example, $(WMI(DatabaseName)) provides the value of the DatabaseName property for the WMI event that caused the alert to run.

So I believe you don't need the ESCAPE_NONE...

|||

If do not add ESCAPE_NONE,prompt "For SQL Server 2005 Service Pack 1 or later, all job steps with tokens must be updated with a macro before the job can run"

Discover In SQL Server 2005 SP1, the SQL Server Agent job step token syntax has changed

url:http://support.microsoft.com/kb/915845

I want to do something for each database just was created,So I could not specifiy the value of database, how to deal with that? thanks

|||

Perhaps the tokens remain disabled?

Because access to Eventlog is not always secured, the alerts are disabled by default. To get the substitutions to work, you should ensure that only members of trusted groups have write permissions to Eventlog, then enable these tokens on the Agent Properties Dialog Alert System tab, or you can set the AlertReplaceRuntimeTokens reg key.

jkh

How to define token syntax in MSSQL2005 sp1?

There is one token in my Agent Job $WMI(DatabaseName)

Now,I defined this using $(ESCAPE_NONE(WMI(DatabaseName)))

but failed and prompted: Variable WMI(DatabaseName) not found

What should i do for this? thanks

From the updated books online:

For jobs that run in response to WMI alerts, the value of the property specified by property. For example, $(WMI(DatabaseName)) provides the value of the DatabaseName property for the WMI event that caused the alert to run.

So I believe you don't need the ESCAPE_NONE...

|||

If do not add ESCAPE_NONE,prompt "For SQL Server 2005 Service Pack 1 or later, all job steps with tokens must be updated with a macro before the job can run"

Discover In SQL Server 2005 SP1, the SQL Server Agent job step token syntax has changed

url:http://support.microsoft.com/kb/915845

I want to do something for each database just was created,So I could not specifiy the value of database, how to deal with that? thanks

|||

Perhaps the tokens remain disabled?

Because access to Eventlog is not always secured, the alerts are disabled by default. To get the substitutions to work, you should ensure that only members of trusted groups have write permissions to Eventlog, then enable these tokens on the Agent Properties Dialog Alert System tab, or you can set the AlertReplaceRuntimeTokens reg key.

jkh

How to define global var?

How to I create a global variable for several SPs to share? For example, I
might have two status vars, such as statusred = 3 and statusgreen = 1.
Thanks,
BrettInsert the value(s) in a table and have each of your stored procs select the
value from the table?
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"Brett" <no@.spam.com> wrote in message
news:%23YLgthPIFHA.1176@.TK2MSFTNGP12.phx.gbl...
> How to I create a global variable for several SPs to share? For example,
I
> might have two status vars, such as statusred = 3 and statusgreen = 1.
> Thanks,
> Brett
>|||That's one way but isn't that inefficient?
How does SQL Server use the @.@.ERROR global var for example?
Thanks,
Brett
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:uj8mZsPIFHA.3076@.TK2MSFTNGP10.phx.gbl...
> Insert the value(s) in a table and have each of your stored procs select
> the
> value from the table?
>
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>
> "Brett" <no@.spam.com> wrote in message
> news:%23YLgthPIFHA.1176@.TK2MSFTNGP12.phx.gbl...
> I
>|||Do the two SPs have anything in common? i.e., do they run in support of one
another? or in rsponse to the same trigger? or are they totally indodependan
t
except for their use of this same value?
If they're functionally related, consider creating a single SP That aclls
both of them, and have that SP pass the value to both SPs that need it.
If they're not, it sounds like what you have is (one of potentially many)
application configuration settings. These can be stored and propogated to
wherever they are needed in a variety of ways, including externally in XML
files, or the Registry, or internally in a separate Database Table that has
name value pairs (Setting, value).
Don;t worry about efficiency ( I Think you meant performance) because SQL is
optimized for this. If the value is used often, it will be cached and kept
in memory anyway.
"Brett" wrote:

> How to I create a global variable for several SPs to share? For example,
I
> might have two status vars, such as statusred = 3 and statusgreen = 1.
> Thanks,
> Brett
>
>|||"Brett" <no@.spam.com> wrote in message
news:O9k4M4PIFHA.3628@.TK2MSFTNGP10.phx.gbl...
> That's one way but isn't that inefficient?
> How does SQL Server use the @.@.ERROR global var for example?
No; SQL Server will keep the value in memory if it's accessed often --
the in-memory cache frees data based on usage, so keep using it and it
stays.
As for @.@.ERROR, that's a function, not a global variable. It's just
named similarly to a variable.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--|||From BOL ...@.@.ERROR is cleared and reset on each statement executed...
Where did you get the idea that this is a global variable?
Why don't you just pass the 2 status's as parameters from 1 SP to the other?
"Brett" <no@.spam.com> wrote in message
news:O9k4M4PIFHA.3628@.TK2MSFTNGP10.phx.gbl...
> That's one way but isn't that inefficient?
> How does SQL Server use the @.@.ERROR global var for example?
> Thanks,
> Brett
> "Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
> news:uj8mZsPIFHA.3076@.TK2MSFTNGP10.phx.gbl...
>|||Think about this for a moment. It is a relational database with the primary
goal of storing data in a table. The whole purpose is optimal data
handling. For a few values that you will be dealing with they will likely
be stored in memory throughout the process anyhow.
Just create a permanent table that your procs use and they can share data on
multiple connections. You will have to figure out how to handle garbage
collection when the programs stop and/or when the start however.
----
Louis Davidson - drsql@.hotmail.com
SQL Server MVP
Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design -
http://www.apress.com/book/bookDisplay.html?bID=266
Blog - http://spaces.msn.com/members/drsql/
Note: Please reply to the newsgroups only unless you are interested in
consulting services. All other replies may be ignored :)
"Brett" <no@.spam.com> wrote in message
news:O9k4M4PIFHA.3628@.TK2MSFTNGP10.phx.gbl...
> That's one way but isn't that inefficient?
> How does SQL Server use the @.@.ERROR global var for example?
> Thanks,
> Brett
> "Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
> news:uj8mZsPIFHA.3076@.TK2MSFTNGP10.phx.gbl...
>

How to define a user variable on Execute Sql Task?

Hi everyone,

How to define a Input variable in a Execute Sql Task?

I've defined a User::Inicio variable which contains 4 as value.

In Parameter Mappins it has been defined. Then, I've gone to General->Sql Statement and allocated the following SQL Statement:

UPDATE CARGAPROCESOS SET FECHAULTIMACARGA = [Inicio]

or

UPDATE CARGAPROCESOS SET FECHAULTIMACARGA = [User::Inicio]

Anyway, I'm stuck, both did not work

Thanks in advance for your comments

Enric,

Use an expression in SQlStatementSource property of your Execute SQL task to build your SQL statement:

"UPDATE CARGAPROCESOS SET FECHAULTIMACARGA = " @.[User::Inicio]

Rafael Salas

|||

Hi Rafael,

Thanks for your quick answer but it doesn't work.

[Execute SQL Task] Error: Executing the query "UPDATE CARGAPROCESOS SET FECHAULTIMACARGA = [@.User::Inicio]" failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

Let me know, I can imagine that's a silly thing..

|||

Well, the error talks abour the ResulSet porperty; what is your value for that? what is you set that to None. Also i think you do not need anything in your parameter tab since the SQL statement is being created by the expression

RAfael Salas

|||Rafael is telling you to set an Expression for the SQLStatementSource property and not set the property value directly. Looks like you set the SQLStatementSource directly to "UPDATE CARGAPROCESOS SET FECHAULTIMACARGA = " + @.[User::Inicio]. To set an expression for the SQLStatementSource property click on the Expressions node on the left hand side of the Execute SQL Task Editor dialog.|||

Hi,

You mean you want to use the user variable in your query right?

Refer this:

http://msdn2.microsoft.com/en-us/library/ms141003.aspx

|||Thanks to all of you