How to pass TEXT(the list of id's as a string) to sybase ase stored procedure - sybase

How to pass TEXT(the list of id's as a string as I have long list of id's) to sybase ase stored procedure call?
If I want to pass TEXT to stored procedure call then how can I use same TEXT in where IN query of sybase?
CREATE PROCEDURE Collect_List(
#ids_list TEXT
)

Looks like this is not an efficient way to pass dynamic IDs in the query.
Why don't you use temp table to do it?

Related

Multi Value Parameter in SSRS -Values are showing NUll when selected

I tried using
Where Location IN(#Location)
in my storedprocedure
In SSRS
i used =join(Parameters!Location.Value,",")
When i select all values the result is null
The value is in string format
Eg: 'XXXX,YY','yyy,mm'
You need to change your Sql stored procedure code so that it could recognize the comma separated values being passed from SSRS.
One way would be using table-value function that can split a comma-delimited string back out into a mini table - link
Once done the code in your stored procedure should be like this -
WHERE Location IN (SELECT Param FROM dbo.fn_MVParam(#Location,','))

Execute sql stored procedure with array input from kettle table input step

I am having a sql stored procedure that takes 2 inputs and returns a resultset based on the given input.
I am using the input1 in sql IN clause like,
WHERE myCol IN(#input1)
when executing the store procedure from kettle table input step,
If i give a single value for the input1, it works fine.
EXEC sp_procedureName #input1='07423', #input2='2014-09-02'
If i give multiple values like below, it results empty resultset.
EXEC sp_procedureName #input1='07423,07022,07033', #input2='2014-09-02'
How can i pass multiple values as a parameter to my procedure.
the transformation will execute the procedure and insert the result set into another table using table output step.
What you need to do inside your stored procedure is split the comma delimited list of numbers into a list of single values in rows. Once you have this you can use WHERE myCol IN(SELECT v FROM #r), or use an INNER JOIN instead of IN. One point you might have to watch for is that you have leading zeros - if you want to keep those you will need to use strings instead of integers.
There are lots of articles around on the subject of splitting delimited values into rows, you could start here.

Dynamic Insert MSSQL Procedure

Is there any way to create a stored procedure take two parameters (Table_Name, Rows) rows will be in standard format like json for example:-
INSERT("TABLENAME","{{id:1,Code:'AA'},{id:2,Code'BB'}}")
or any other format. the goal is "creating one procedure for simple insert"
thank you
Please try to search for TVP to achive this goal.
With help of TVP (Table valued parameter), you need to pass only one parameter in SQL Stored procedure, so insted of creating Json string in code behind, create datatable.

How to use the results of a SQL Server stored procedure (scheduled to run weekly) for trending the data over time?

I have a stored procedure in a SQL Server 2008 database that returns a set of values pulled from various different tables such as the following. I run the stored procedure as shown below, without any parameters.
EXEC [Data].[dbo].[sp_Usage]
Each row shows the product usage data such as
Last Login
No.of times used last month
last 3 months
last 6 months
App Version
for each unique AccountId
I want to run this stored procedure automatically every month/week and store the corresponding results in the database, without erasing the last week/month's data.
I plan to use this data over time to do data trending.
How should I execute this plan?
Any help or guidance will be much appreciated
Cheers!
Shiny
So your stored procedure presumably has a SELECT (list of columns) ..... inside it, right?
Why not change that to something like:
INSERT INTO dbo.YourBigTable(ExecutionDateTime, ...other columns here.....)
SELECT
GETDATE(), -- get current date/time
(list of other columns)
FROM .......
Just basically make the stored procedure run the INSERT into your target table directly. That would seem like the easiest way to go from my point of view.
Otherwise, you need to insert the data returned from the stored procedure into a temporary table, and then insert that temporary table's data, along with the execution date/time, into your target table.

SqlCommandBuilder.DeriveParameters(command) and IsNullable

I have written an O/R database wrapper that generates some wrapper methods for stored procs it reads from the database.
Now I need to produce some custom wrapper code if an input parameter of a stored proc is defaulted to NULL. The problem is - I get stored proc parameters using:
SqlCommandBuilder.DeriveParameters(command)
and it doesn't bring parameter defaults. Is there any way to look up those defaults? Are they stored anywhere in the database?
BTW, I'm using SQL Server 2008
For T-SQL stored procedures, the only means to do this is to parse the procedure definition out of the sys.sql_modules table. From the BOL on the sys.parameters table regarding the has_default_value column:
1 = Parameter has default value.
SQL Server only maintains default
values for CLR objects in this catalog
view; therefore, this column has a
value of 0 for Transact-SQL objects.
To view the default value of a
parameter in a Transact-SQL object,
query the definition column of the
sys.sql_modules catalog view, or use
the OBJECT_DEFINITION system function.
Here is an article to someone that wrote a T-SQL function that supposedly does just that: Figure Out the Default Value of Stored Procedure Parameters.
Basically, sqlcommandbuilder class automaticaly generates single table commands that are used to reconcile changes made to a dataset with the sql server.

Resources