Parsing An Input Variable

Apr 15, 1999

Does anyone know how to parse an input variable to a stored proc? For example, if I have an input variable that is: 'ford,chevy,pontiac' how do I parse through this variable and handle each value independently?

Since I do not know how many values may exists I can't do it based on a set amount of input variables.

View 3 Replies


ADVERTISEMENT

Parsing Variable Length Delimited Records

Mar 25, 2006

I am running SQLServer 2000 to parse and store records in the EDIX12
format. This consists of variable length delimited records which
I am passing to the "transforms" tab to process with VBScript.



The problem is though each segment has a defined number of fields, N,
the standard states that if the final M fieds are empty/blank they are
not to be sent. Thus, a segment defined to have 20 fields may
have 6 the first time I see it, 13 the next time, etc. To access
the columns in VBScript I use DTSSource("Col001"). This works as
long as the columns are there, but gives an error when they are
not. Is there a parameter telling me how many columns are
defined? Or is there something akin to IFEXISTS("Colxxx") or
exceptions?



How can I handle this situation? One suggestion has been to pass
the entire segment to the Transforms section and break it up there.



Finally, what resources can yuo point me to for reference? I'd
like to get good at using DTS since my client wants their project
written for it.



Thanks for yuor help,

--greg

View 1 Replies View Related

How To Set Input Xml Name And Folder From Variable

Mar 18, 2008

Hey Guys,

Heres my issue. please help

I have xml files and xslt files are in seperate folders. and each xml file has its own xslt. I've got the for loop riunning which loops thro the metadata table. This table has the file and folder localtions of xml and its corresponding xslt.
I'm using the transform xml task in control fllow. i dont see an option to set input xml name and folder from Variable in transform xml component properties? It seems to expect fully qualified path. is there an alternative? or what am i doing wrong?

View 5 Replies View Related

How To Input A DOS Variable Into A Stored Procedure

May 4, 2004

I am trying to Execute a Stored Procedure using Call OSQL from a .bat file, and passing a DOS variable to the Stored Procedure.

The DOS variable is established in the DOS command...

set SERVERJOB=JOBNAME

I have tried...

EXEC sp_procedure %SERVERJOB%

With this, I get an error...

sg 170, Level 15, State 1, Server ABCDEFGH, Line 20
Line 20: Incorrect syntax near '%'.

If I put the variable name in quotes on the EXEC statement above, the value used is the variable name, %SERVERJOB% itself rather than the value the variable was set to, which would be JOBNAME in the above example.

Any ideas??? Thanks!

View 2 Replies View Related

Variable Number Of Input Columns

May 2, 2007

We are trying to use the Import/export wizard to load a text file to a SQL Server 2005 database. The input file has a variable number of columns per row. For example, the first row has 3 columns, the second has 7, the third has 3, etc. The number of columns varies from 2 to 9 in the input file. The columns are separated by an uptick (`) and the rows are terminated by {CR}{LF}. We are using code page 1252. On processing, the wizard reads the first row (with 3 columns) ok, but then assumes all the other rows have 3 columns and parses the rows accordingly, ignoring the field and row terminators.

The process worked fine with SQL Server 2000. Is there some setting that we are missing, or some configuration on the database that we should be checking?



Thank You

View 3 Replies View Related

Using Input Variable With .NETODBC Provider

Oct 29, 2007



In my data flow task, I use a data reader source to get data from our 400. Currently, I have a simple sql command that is pulling data from a file qualifying by date, which is hard-coded. I would like to pass in a parameter which has the date in it. How can I do this? Thanks!

View 8 Replies View Related

Using Table Variable As Input To Function Or Procedure

Jul 9, 2001

Is there any way to use table variable as input to a function or stored procedure?

View 3 Replies View Related

Creating Views With Variable No. Of Input Tables

Aug 6, 2007

Hello,
I need to create a view which will include an additional table every week of our financial year.
Example: Every week we create a table called Sales_YYYY_WW where YYYY is the Year and WW is the Week, so after the first week we have the table Sales_2007_01 and after the second week we have Sales_2007_01 and Sales_2007_02 etc.. These tables are created evey week and don't exist at the start of the financial year.
I'd like to create a view at the beginning of each year to encompass each table evey week as it is created. If all of the tables were there at the start of the year it would be simple:
CREATE VIEW VIEW_SALES_2007
AS
SELECT * from Sales_2007_01
UNION ALL
SELECT * from Sales_2007_02
etc.
But I don't know how to achieve this when the tables don't already exist. I don't want to have to edit the view each week to add in the new table.

Can anyone out there help me?

View 3 Replies View Related

Standard Input Variable Not Working Properly

Oct 20, 2007

Hi,

I have an Execute Process Task that calls a batch file.

I need to pass in a date value to the batch file.

If I enter the value 20071018 in the "Arguments" section, it works fine.

However, I use the "Standard Input Variable", User::MyDate (which gets assigned in a previous Execute SQL Task), it bombs. The query I am using returns the date back in the format yyyymmdd. It gets assigned to a string variable, called MyDate.

e.g.)
SELECT TOP 1 CONVERT(VARCHAR, MyDate, 112) AS MyDate
FROM myTable

which result is mapped to User::MyDate

Is there any obvious reason why this doesn't work?

Thanks

View 3 Replies View Related

How To Use A Variable From The For Loop Container As A Input Parameter To A SP

Nov 6, 2006

Hi Everyone:

I have a quick but imp SSIS question. I have a For Each Loop Container, and inside that I wish to add a Execute SQL Task item, so I can call a sp to do some inserts/updates. The ForEachLoop container is looping thru a ADO Object source variable(which is the user variable defined by me, as a FullResultSet). In my Execute SQL Task, I would like to utilize one of the columns from the result set as an input parameter to my Stored procedure. Can someone please advise on how to do this? Please let me know if you have any more questions. I am waiting for a response... Thanks in advance.

 

MA

View 1 Replies View Related

Web Service Task - Passing Variable As Input

Nov 24, 2006

Microsoft says it is possible but I just do not see how. Here is the
link to the help file where it said that variables could be pass as
input to web methods...I do not see the check box they mention on my
IDE.


Any help would be greatly appreciated.


Thanks,
Catherine

View 4 Replies View Related

SqlDataSource.Update With Session Variable As Input Parameter

May 25, 2007

I'm getting a type mismatch error (currently string, when I think I need Int32 ?) with the code below. I'm having difficultly setting my session variable to type Int32 and having it take up the value of RawCoDeptRowID. When I "Watch" it, it's value remains as "snCoDeptRowID".  Also, not sure if my Update command and it's snCoDeptRowID input parameter is well formed? Any advice would be greatly appreciated. Thank you.
Web Page 1:
Session["snCoDeptRowID"] = Convert.ToInt32 (RawCoDeptRowID);
 
Web Page2:<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
UpdateCommand="UPDATE [CompanyDepartment] SET [User_Name] = @User_Name, [FirstName] = @FirstName, [LastName] = @LastName, [Company_Name] = @Company_Name, [Department_Name] = @Department_Name WHERE [User_ID] = @snCoDeptRowID ">
<updateparameters>
<asp:parameter Name="User_Name" Type="String" />
<asp:parameter Name="FirstName" Type="String" />
<asp:parameter Name="LastName" Type="String" />
<asp:Controlparameter Name="Company_Name" Type="String" ControlID ="ListBox1" PropertyName ="SelectedValue" />
<asp:Controlparameter Name="Department_Name" Type="String" ControlID ="ListBox2" PropertyName ="SelectedValue" />
<asp:QueryStringParameter Name="User_ID" Type="Int32" QueryStringField ="@snCoDeptRowID" DefaultValue ="@snCoDeptRowID" />
</updateparameters>
</asp:SqlDataSource>

View 1 Replies View Related

Select Statement As Input Variable In Stored Procedure?

May 6, 2015

Is it possible to have an entire sql select statement as the input variable to a stored procedure? I want the stored procedure to execute the select statement.

ie.

exec sp_SomeFunc 'select * from table1 where id=1'

It may sound weird, but I have my reason for wanting to do it this way. Is this possible? if so, how do I implement this inside the stored procedure?

View 4 Replies View Related

Dynamic OLE DB Table Source From Variable Not Seeing Input Columns

Dec 12, 2007

I am building an SSIS package that loops through a table in SQL Server and dynamically builds a select statement that i would like to use as an ole db source. I have been having a difficult time with this as the select statement that i am generating is over 200,000 characters long so using an sql variable is out of the question.

I ended up placing the select statement into a table where each row of the table represents a piece of the select. I then use an execute_sql task that selects the entire rowset from this table into a variable object. I then use a for each loop to shred the variable and concatenate it into on big string variable called user:: sql_statement that is my select.

After setting up the loop and testing to see if the user:: sql_statement variable populates correctly i then added a data flow transfer with an ole db source and destination. I then go into the advanced editor for the source and set it to accept an sql statement from a variable and use my user:: sql_statement variable. I was forced to set validate external metadata option to false to avoid an error since there is no way to validate the columns until the for each loop runs during run time.

Now thats all fine and good but what is causing my problem is that during run time, when the package gets to the data flow task, the select statement doesn't seem to be populating the input columns of the data source. I have been searching to no avail on a way to tell the data source to update the input columns but every time it gets there, the package bombs out telling me the ole db source has no available output columns.

Specifically the error i get is :
[DTS.Pipeline] Error: "output "OLE DB Source Output" (6616)" contains no output columns. An asynchronous output must contain output columns.

Any help with this would be much appreciated.

View 18 Replies View Related

Passing Object Variable As Input Parameter To An Execute SQL Task Query

Mar 29, 2007

I've encountered a new problem with an SSIS Pkg where I have a seq. of Execute SQL tasks. My question are:

1) In the First Execute SQL Task, I want to store a single row result of @@identity type into a User Variable User::LoadID of What type. ( I tried using DBNull Type or Object type which works, not with any other type, it but I can't proceed to step 2 )



2) Now I want to use this User::LoadID as input parameter of What type for the next task (I tried using Numeric, Long, DB_Numeric, Decimal, Double none of there work).



Please give me solutions for the above two..



View 6 Replies View Related

Contact Form - Variable Number Of Input Fields, Store Data As Xml String ?

Jul 13, 2007

Im trying to determine the best way to store data gathered from a form that a user will fill out online.  The form is dynamic and is customized at run time based on group-specific criteria.  The end result is a form that might have 3 extra text boxes, 2 extra sets of radio buttons and a freeform textbox, whereas for another group, there might be a slightly different set of input fields.   Now comes the issue of storing this data.  Since the fields can be somewhat dynamic, it could get tricky to define table columns for each possible input field.  So Im considering storing the data as xml.  Has anyone else had to build custom forms and ended up storing the data as xml ?

View 2 Replies View Related

SQL Server 2008 :: Stored Procedure Returning Different Datasets Based On Input Variable

Sep 15, 2015

I'm seeing where previous developers have used a single stored procedure for multiple reports, where each report required different columns to be returned. They are structured like this:

CREATE PROCEDURE dbo.GetSomeData (@rptType INT, @customerID INT)
AS
BEGIN
IF @rptType = 1
BEGIN
SELECT LastName, FirstName, MiddleInitial

[Code] ....

As you can see, the output depends on the given report type. I've personally never done this, but that's more because it's the way I learned as opposed to any hard facts to support it.

So what I'm looking for is basically 2-fold.

View 5 Replies View Related

XML Parsing

Jul 24, 2002

I am trying to process an XML document that contains the attribute 'from_x'. However an openxml query can't seem to find any column with a '_x' suffix. For example if I were to execute the following fragment:

declare @hDoc int, @Message varchar(200)
select @Message = '<BACK_FM from_x="12"></BACK_FM>'
exec sp_xml_preparedocument @hDoc OUTPUT, @Message
select from_x from openxml(@hDoc, 'BACK_FM',1) with (from_x int)

I get back a null value from the openxml query. Attribute names 'fromx' and 'from_y' work ok but nothing I have tried with a trailing '_x' will work.

Does anyone know if this is a known SQL Server bug? Is it a bug at all or something about XML that I don't know about?

Thanks,
Wayne King

View 1 Replies View Related

Parsing

Aug 13, 2001

I need to figure out how to parse a comma separated value.

Lets say I have a variable equal to a comma separated list.

SET @Variable = '045, 032, 025, 653'

I need to create a dynamic sql string to look like:

SET @Variable = ''' + '045' + ''' + ',' + ''' + '032' + ''' + ',' etc...

Can someone teach me a optimized query to do this?

Thanks
Greg

View 1 Replies View Related

Parsing

Mar 9, 2005

What is parsing?? can someone give me an example please?? this what I got from BOL

Returns the specified part of an object name. Parts of an object that can be retrieved are the object name, owner name, database name, and server name.

View 11 Replies View Related

Help With Parsing

Feb 8, 2007

Hi -

I am new to SQL server and was wondering if someone can help me with this one. Thanks
My table holds 2 columns (SECTOR and TERM) with following example values

SECTOR TERM
Hybrid 6/18
Hybrid 9/19
Hybrid 10/17
Hybrid 3/13

I would like to find out the rows where my values from SECTOR before '/' does not equal TERM

i.e.
Row 1 where 6<>8
and row 3 where 10<>7

Thanks.

View 5 Replies View Related

Parsing A Sql Field

Jul 6, 2007

Can you parse a SQL field? Let's say, FULLNAME field got a TEXT datatype with the following data: <firstname>Norm</firstname><lastname>bercasio</lastname><Color>blue</color>then using a select statement, parse the field to find the lastname then write it to another field called LASTNAME on the same table, same rowID. Can you send a select statement how it can be done? I am using SQL 2003 or 2005. thank you so much.
 
 

View 2 Replies View Related

Need Help Parsing Out Info

Jul 22, 2004

Hi All,

I'm using a SQL selection to fill a DataGrid. One of the fields I have is called diagnosis. This field in the database can contain multiple diagnosis. But I use a set of characters to divide each diagnosis.
Example : Sick!@#$%Hurt!@#$%Ill!@#$%
My problem is this is how it looks in my Data Grid. Can someone tell me how to parse out each diagnosis.

Thanks

View 1 Replies View Related

String Parsing

Jun 7, 2002

How to remove same repeated string in a column per row from a table? Looked at
replace, stuff string functions, but none take a column name as a parameter.

Help is appreciated.

Thanks,

View 1 Replies View Related

Parsing Data

Apr 21, 2000

Do anyone know of any functions I can use to parse the following data eg.
M 3480-7 should be 3480
M 3477-19 should be 3477
M 28-10 should be 28

Thanks in advance,
Vic

View 1 Replies View Related

Parsing A Name Field Using SQL

Aug 18, 2000

Anybody out there ever take a column containing names and parse it out to salutation, first name, middle initial/name, last name, suffix using Transact-SQL? I think I know how to do it using an array in a procedural language, but using SQL I'm drawing a blank.

Any ideas or help will be appreciated!

View 1 Replies View Related

Parsing Strings

Feb 27, 2001

I have a varchar field that contains answers to questions separated by commas. Say there are 4 questions for each user. Here is an example of what the table would look like:
User Answer
1 Good,Fair,Good,Bad
2 Bad,Good,Good,Good
3 Fair,Good,Bad,Fair

I need to write a stored procedure to report off of that separates the Answer field into 4 different columns. How can this be achieved? Any assistance would be greatly appreciated.

View 1 Replies View Related

Parsing XML Data

Nov 7, 2003

I have a SQL Server table that holds XML documents. Is there a known SQL Server XML parser ?....how can I export XML data into a readable format ?

thanks

View 1 Replies View Related

Parsing Data

Sep 13, 2005

Does anyone know any good URL's for examples on parcing data using SQL?

As an example, i've got First/Middle/Last name of a person inside a single field, I want to turn that into 3 fields.

Thanks!
Caden

View 8 Replies View Related

SQL Parsing Challenge!

Nov 9, 2004

Hi guys!

Can anyone tell how I can parse the WHERE clause of an SQL statement to check for special characters such as ''' (single quotes) in fields of type varchar?

thanks
nelo

View 2 Replies View Related

Anyone Know About Parsing An Email?

Mar 20, 2006

Hello everyone

Heres what it looks like:

I have a large file of over 40k email records. The emails are all mixed up and come in various formats but i noticed that most of them are in this format:

firstname.lastname@email.com
firstname.middlename.lastname@email.com

For all those emails with the period (.) in between, the (.) actually separates an individuals first and last name.

My task is this, to separate all the emails that are in this format into first and last name fields. I'm stimped folks and I'll really appreciate any pointers or ideas on how to go about solving this task.

Thanks

View 1 Replies View Related

Parsing A Name Field

Aug 9, 2012

I have a name field that has many variations and been fighting with it for a few days. The possible name variations are:

Smith, Mike
Smith, Mike K.
Smith, Mike K., JR.

I would like to parse each of the for pieces in a separate field.

View 3 Replies View Related

Parsing Address

Feb 13, 2004

Parsing Address
This is not really a reply, but I saw the problem and the replies look very promissing.
I'm using ss2k, I have a table with an address column.
here is some example of the records under ADDRESS :

WILLOW CREEK PL
RED BARN DR
RED BARN DR
CARRINGTON DR
RENNER RD
EDMONTON CT
SPRINGBRANCH DR
HILLROSE DR
CEDAR RIDGE DR
LARTAN TRL
PRESIDENT GEORGE BUSH HWY

What I want to do is to write script that runs daily and parse the street names (RED BARN) and street types (Dr, PL , etc.. ) to 2 colums. As u can see there is no fixed length or fixed number of words ...etc ...
Any help would be really appreciated.
thnks

View 3 Replies View Related







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