Convert Data File Type From Unix To Pc Using Stored Procedure?

Jul 14, 2006

Hi, I have a script written in ASP to load data file (.csv) to ms sql. In the script, I have a portion of script looks like taht :

.....

Do While NOT oInFile.AtEndOfStream
  oOutFile.WriteLine Replace(oInFile.Readline, chr(13), vbcrlf)
Loop

.....

After that, I will use a BULK INSERT to input data to ms sql.

I am wondering how do I convert each row (data) to vbcrlf in Stored Procedure? Coz' I did not compose the convertion part, and I got no error when running BULK INSERT, but no rows are inserted :( HELP!!!!

I guess it's because the file is not being converted into a correct format??

 

View 1 Replies


ADVERTISEMENT

How To Convert To Regular Text, Data Stored In Image Data Type Field ????

Jul 20, 2005

Hi,This is driving me nuts, I have a table that stores notes regarding anoperation in an IMAGE data type field in MS SQL Server 2000.I can read and write no problem using Access using the StrConv function andI can Update the field correctly in T-SQL using:DECLARE @ptrval varbinary(16)SELECT @ptrval = TEXTPTR(BITS_data)FROM mytable_BINARY WHERE ID = 'RB215'WRITETEXT OPERATION_BINARY.BITS @ptrval 'My notes for this operation'However, I just can not seem to be able to convert back to text theinformation once it is stored using T-SQL.My selects keep returning bin data.How to do this! Thanks for your help.SD

View 1 Replies View Related

Unix, Windows For Unix, And Direct Read Of .mdf File This Is A True Story

Sep 13, 2007

First, let me start by saying I know the answer to this, but due to politics any answer I give will be viewed with some disdain and disbelief.

A Unix/Network [rtdpmin one our sister agencies is trying to solve a problem that really does not need to be solved, but ....

The sister agency uses Information Builder's WebFocus on Unix. When they try to read my data warehouse in SQL Server 2000 it times out on them (on their end and they claim they cannot fix it) (This is using the supplied WebFocus ODBC/JDBC driver for SQL Server). This has lead to accusations of us not letting them read the data.

After much gnashing of teeth over "if you do data and data analysis for a living, why do I have to show you how to set-up an ODBC connection" we have shown them how to connect to the data, read it, and transfer it using MS-ACCESS, EXCEL, and more importantly SPSS. This is not good enough because they cannot figure out how to put it into WebFocus.

Their network person has come-up with the brilliant idea of reading the .mdf directly by installing Windows for Unix on the Unix side and then just pointing to the .mdf file and "reading it ".

Unless I have missed something somwhere (I will admit possible), I know you need a driver to read MS-SQL and that driver in every example I have seen could care less about the physical location of the .mdf file. It wants to know what database, what server (ip or name) and what security/login to use.

Could someone give me a more "technical answer" or even Microsoft's party line so I do not have this person mucking around with my production server trying to acomplish the impossible.

View 5 Replies View Related

Kill Stored Procedure Invoked Through Unix

Nov 11, 2014

I am using sql server 2008 version and invoking the stored procedure using unix script. I want to know the procedure of killing the stored procedure in sql server.

If I kill -9 the unix script will it also terminate the process at the SQL server. When I executed the kill -9 PID in unix and ran the command exec sp_who2 it showed me only one sessionid and status as runnable - which means waiting for resources. BUt I am not sure whether it was the one which was triggered through unix.

My SP is executing in loop thereby is there any way I can avoid going into infinite loop?

View 3 Replies View Related

Data Type Conversion In Stored Procedure

Aug 2, 2006

Hi,

I have a stored procedure a portion of which looks like this:


IF (CAST (@intMyDate AS datetime)) IN (
SELECT DISTINCT SHOW_END_DATE
FROM PayPerView PP
WHERE PP_Pay_Indicator = 'N' )
BEGIN
--ToDo Here
END


where:
@intMyDate is of type int and is of the form 19991013
SHOW_END_DATE is of type datetime and is of the form 13/10/1999

however when I run the procedure in sql query analyzer as:

EXEC sp_mystoredproc param1, param2

i get the error:


Server: Msg 242, Level 16, State 3, Procedure usp_Summary_Incap, Line 106
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.


what is the proper way of doing the conversion from int to datetime in stored procedure?

thank you!

cheers,
g11DB

View 11 Replies View Related

Data Type Of Parameter Passing To A Stored Procedure

Feb 25, 2004

Hi,
I pass a paramter of text data type in sql server (which crosspnds Memo data type n Access) to a stored procedure but the problem is that I do not know the crossponding DataTypeEnum to Text data type in SQL Server.

The exact error message that occurs is:

ADODB.Parameters (0x800A0E7C)
Parameter object is improperly defined. Inconsistent or incomplete information was provided.

The error occurs in the following code line:
.parameters.Append cmd.CreateParameter ("@EMedical", advarwchar, adParamInput)

I need to know what to write instead of advarwchar?
Thanks in advance

View 1 Replies View Related

Converting Date Data Type In Stored Procedure

Jul 31, 2006

HI Experts...

I am using SQL SERVER 2005 standard edition

I have encountered a problem regarding converting date data type in stored procedure

As i was having problem taking date as input parameter in my stored procedure, so, then  I changed to varchar (16) i.e.

CREATE PROCEDURE sp_CalendarCreate
                                      @StDate VARCHAR(16) ,
                                      @EDate VARCHAR(16),

then I am converting varchar to date with following code

DECLARE @STARTDATE DATETIME
DECLARE @ENDDATE DATETIME

SELECT @STARTDATE = CAST(@STDATE AS DATETIME)
SELECT @ENDDATE = CAST(@EDATE AS DATETIME)

When I try to execute the procedure with following code

execute sp_CalendarCreate @stdate='12-1-06',@edate='20-1-06'

but it gives me following error

Msg 242, Level 16, State 3, Procedure sp_CalendarCreate, Line 45
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

Can any one tell me the  solution of that problem (at ur earliest)

regards,

Anas

View 5 Replies View Related

How To Deal With Image Data Type Within Stored Procedure When Using SQL2000?

Dec 5, 2007

Hi,
Does anyone know how to deal with image data type within stored procedure when using SQL2000?
I have a table and there is an image data type column. In this table I need to make a copy of one row within a table through a SP /it means to retrieve the whole row within SP,  change another columns data (but, that the image is not modified) / and save the modified row back to the same table.
Problem is, that within SP is not alowed to use local varaibles of image data type. Does anyone know a solution for this? Please.
Thank you.

View 1 Replies View Related

User Defined Data Type Used In Stored Procedure Parameters

Jul 23, 2005

I have several stored procedures with parameters that are defined withuser defined data types. The time it takes to run the procedures cantake 10 - 50 seconds depending on the procedure.If I change the parameter data types to the actual data type such asvarchar(10), etc., the stored procedure takes less that a second toreturn records. The user defined types are mostly varchar, but someothers such as int. They are all input type parameters.Any ideas on why the stored procedure would run much faster if notusing user defined types?Using SQL Server 2000.Thanks,DW

View 13 Replies View Related

Output Parameter With Text Data Type In Stored Procedure

Jul 20, 2005

How can I make a stored procedure which has a output parameter withtext data type? My procedure is:CREATE PROCEDURE try@outPrm text OutputASselect @outPrm =(select field1 from databaseName Wherefield2='12345')GOHere field1 is text data type.Thanks

View 1 Replies View Related

.NET Framework :: CLR Stored Procedure With Table Data Type Parameter

May 27, 2015

I want to create a CLR Stored Procedure with a Table User Defined Type like this short example in SQL:

CREATE TYPE [dbo].[TypeTable] AS TABLE
(
[Id] [integer] NOT NULL,
[Value] [sysname] NOT NULL,
PRIMARY KEY CLUSTERED

[Code] ....

I found some example in this link : CLR UDT

But I can't figure how to do the same with a User Defined Type Table.

View 5 Replies View Related

How Can I Change The Data Type Of The Parameter For The Deployed Stored Procedure ??

Jan 11, 2006

Hi
 
I have Try to Create Stored Procedure in C# with the following structure
 
[Microsoft.SqlServer.Server.SqlProcedure]
public static void sp_AddImage(Guid ImageID, string ImageFileName, byte[] Image)
{
       
}
 
But  when I try to deploy that SP to SQL Server Express  , The SP Parameters become in the following Stature
 
@ImageID uniqueidentifier
@ImageFileName nvarchar(4000)
@Image varbinary(8000)
 
But I don€™t want that Data types .. I want it to be in the following format
 
@ImageID uniqueidentifier
@ImageFileName nText
@Image Image
 
 
How Can I Control the data type for each parameter ??
Or
How Can I Change the data type of the parameter for the Deployed Stored Procedure ??
Or
How Can I defined the new Data type ??
 
Or
 
What's the solution to this problem ??
 
Note : I get Error when I try to use Alert Statement to change the parameter Data type for the SP
 
ALTER PROCEDURE [dbo].[sp_AddImage]
      @ImageID [uniqueidentifier],
      @ImageFileName nText,
      @Image Image
WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [DatabaseAndImages].[StoredProcedures].[sp_AddImage]
GO
 
And thanks with my best regarding
Fraas

View 7 Replies View Related

Convert Text Data Type To Smalldatetime Data Type

Oct 9, 2007

I have a field that is currently stored as the data type nvarchar(10), and all of the data in this field is in the format mm/dd/yyyy or NULL. I want to convert this field to the smalldatetime data type. Is this possible?
I've tried to use cast in the following way, (rsbirthday is the field name, panelists is the table), but to no avail.


SELECT rsbirthday CAST(rsbirthday AS smalldatetime)

FROM panelists


the error returned is "incorrect syntax near 'rsbirthday'.

I'm rather new to all things SQL, so I only have the vaguest idea of what I'm actually doing.

Thanks for the help!

View 10 Replies View Related

How Do I Convert A Unix Date/Time Field To A Date When The The SQL DB Stores That Data As Char 11?

Nov 13, 2007

Hi there.
I'm trying to extract data from my SQL server & everything in the script I've got is working (extracting correct data) except for one field - which is for the most part it's off by +2 days (on a few occasions - I see it off by just +1 day or even +3, but it's usually the +2 days).

I'm told that it's due to the conversion formula - but - since SQL is not my native language, I'm at a bit of a loss.

The DB table has the date field stored as a type: CHAR (as opposed to 'DATE')
Can anyone out there help?

Please advise. Thanks.

Best.
K7

View 1 Replies View Related

Error Converting Data Type Varchar To Numeric In Stored Procedure

Aug 28, 2012

Here's the SP

Code:
USE [byrndb]
GO
/****** Object: StoredProcedure [dbo].[sp_GetLikeJobsByJobNumber] Script Date: 08/28/2012 15:17:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON

[Code] ....

Why when I run

Code:
USE [byrndb]
GO
DECLARE@return_value int
EXEC@return_value = [dbo].[sp_GetLikeJobsByJobNumber]
@number = N'23913'
SELECT'Return Value' = @return_value
GO

Am I getting an "Msg 8114, Level 16, State 5, Procedure sp_GetLikeJobsByJobNumber, Line 16

Error converting data type varchar to numeric." error? Line 16 is "@number varchar = null"

View 5 Replies View Related

Input Parameter Exceeds The Limit Of The Data Type's Length In Stored Procedure

Sep 4, 2007



Hi guys, is there any way to solve my problem as title ? Assuming my stored proc is written as below :

CREATE PROC TEST
@A VARCHAR(8000) = '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,...,5000'

AS
BEGIN

DECLARE @B nvarchar(MAX);
SET @B = 'SELECT * FROM C WHERE ID IN ( ' + @A + ')'

EXECUTE sp_executesql @B
END
GO

View 2 Replies View Related

Creating A Stored Procedure That Will Summarize Data In A Table Into A Table Reflecting Period Data Using An Array Type Field

Sep 20, 2007

I am attempting to create a stored procedure that will launch at report runtime to summarize data in a table into a table that will reflect period data using an array type field. I know how to execute one line but I am not sure how to run the script so that it not only summarizes the data below but also creates and drops the table.

Any help would be greatly appreciated.

Current Table

Project | Task | Category | Fiscal Year | Fiscal Month | Total Hours
---------------------------------------------------------------------------------------------------------
Proj 1 | Task 1 | Cat 1 | 2007 | 01 | 40
Proj 1 | Task 1 | Cat 2 | 2007 | 02 | 20
Proj 1 | Task 1 | Cat 3 | 2007 | 03 | 35
Proj 1 | Task 1 | Cat 1 | 2008 | 01 | 40
Proj 1 | Task 1 | Cat 2 | 2008 | 02 | 40
Proj 1 | Task 1 | Cat 3 | 2008 | 03 | 40

Proposed Table

Project | Task | Category | Fiscal Month 01 | Fiscal Month 02 | Fiscal Month 03 | Fiscal Year
---------------------------------------------------------------------------------------------------------------------------------------------------
Proj 1 | Task 1 | Cat 1 | 40 | 0 | 0 | 2007
Proj 1 | Task 1 | Cat 2 | 0 | 20 | 0 | 2007Proj 1 | Task 1 | Cat 3 | 0 | 0 | 35 | 2007
Proj 1 | Task 1 | Cat 1 | 40 | 0 | 0 | 2008

Proj 1 | Task 1 | Cat 2 | 0 | 40 | 0 | 2008
Proj 1 | Task 1 | Cat 3 | 0 | 0 | 40 | 2008

Thanks,
Mike Misera

View 6 Replies View Related

Convert Unix Timestamp To UTC

Sep 12, 2007



Hi

Is there a way in T-SQL (Server 2005) to convert unix timestamp to UTC

So want to do this:
1189481763.61 -> Tue, 11 Sep 2007 03:36:03 UTC(or any UTC format)


Thanks

View 3 Replies View Related

Pass All Data In A File As A String Into A Stored Procedure

Jul 5, 2007

Hi,
Using SSIS 2005 how is it possible to loop through a folder on the network, look at each file, pass the data inside each file as a string into a stored procedure.
Thanks

View 1 Replies View Related

Convert Txt To Money Data Type

May 12, 2005

Hi,
I'm using the data type "money" in my SQL database and want to convert what's in txtPrice_textBox to the "money" format. I'm currently using the following code:
' objectCym.price = Convert.ToInt16(txtPrice_textBox.Text) '
Will this work?  Is there any reason I should stay away from the "Money" data type?
 
Thanks,
David
 
 

View 3 Replies View Related

Convert Data Type In SSIS

Oct 1, 2007

Hi, all my friends,

This is another rookie one.

Is there a way in SSIS dev environment that will let you convert/cast data type at desing time?

Under data flow mappings, there are so many things you can do, but why I did not find any easy way to convert?

I got this validation warning about not supportng converting type DT_STR to DT_I4, or something related.

Am I missing something obvious?

Thanks!

View 3 Replies View Related

Cannot Convert Type 'int' To 'System.Data.DataView'

Feb 2, 2008

I have the following SqlDataSource in my page:<asp:SqlDataSource ID="sqlds" runat="server" ConnectionString="<%$ ConnectionStrings:cs %>"    SelectCommand="SELECT [Quest1], [Quest2], [Quest3], [Quest4], [Quest5] WHERE ([QuestID] = @QuestID)">    <SelectParameters>        <asp:Parameter Name="QuestID" />    </SelectParameters> In my code I get the following error: "Cannot convert type 'int' to 'System.Data.DataView'", I don't understand why I am getting this error because I am casting my SqlDataSource as type DataView when passing it to my DataView type.Code: protected void Chart(string record)    {        System.Data.DataView dv = (System.Data.DataView)sqlds.SelectParameters.Add("QuestID", System.TypeCode.Int32, record); //Error line       ...       ...       ...}If anyone could point me in the right direction I would be very grateful. 

View 5 Replies View Related

Convert Hexadecimal Value To Real Data Type

Aug 29, 2006

Hi ,

I want to convert hexadecimal to numeric data type. Using directly Cast or Convert function is not working.

Please suggest an alternative how to retrieve the numeric value of binary data .

Thanks in advance

Regards

Srinivas Govada

View 1 Replies View Related

Load Data From Text File Into Some Table Implemented In Stored Procedure.

Nov 8, 2006

Hello, I want to load data from text file to MS SQL DB table.

In MySQL, it is the "LOAD DATA INFILE..." query statement.

What is sutable query if I want to migration from Mysql to MS SQL Server 2005 Express?

View 2 Replies View Related

Convert Date Format - Data Type Varchar

Aug 6, 2013

I have a column which is

Data type : varchar(10)
Date format : 8/5/2013

I want to convert that column to the following

Data type varchar: (8)
Date format : 20130805

View 5 Replies View Related

Convert Data Type In SSIS Design Time

Oct 2, 2007

Hi, all experts,


Is there a way in SSIS dev environment that will let you convert/cast data type at desing time?


Under data flow mappings, there are so many things you can do, but why I did not find any easy way to convert?


I got this validation warning about not supportng converting type DT_STR to DT_I4, or something like that on many occassions..

I am using OLEDB Source as source and SQL Server Destination as destination.

Am I missing something obvious?


Thanks!

View 6 Replies View Related

Value With Data Type Nvarchar - Convert To Decimal And Remove 0 Infront

Jan 21, 2014

I have value with data type nvarchar:

total
000000854.00
000000042.00
000000065.17
000000000024
000000000.24

How can i convert to decimal and remove 0 infront? but those with 0.xx would not remove the 0 after the dote.

total
854.00
42.00
65.17
24
0.24

View 6 Replies View Related

Cannot Implicitly Convert Type 'System.Data.SqlClient.SqlDataReader' To 'int'

Feb 25, 2008

Hi,

I sometimes get these error messages. Does this sound familiar? Does anyone know what I am doing wrong?


Cannot implicitly convert type 'System.Data.SqlClient.SqlDataReader' to 'int' (SQL-server)

Cannot implicitly convert type 'int' to 'System.Data.OleDb.OleDbDataReader' (Access DB)

TIA

View 5 Replies View Related

Transact SQL :: How To Convert Numeric Data Type To A Varchar With No Decimal Place

Aug 31, 2015

So my data is delivered as numeric(9,2)...like 100.00. I have to extract that data and store it as a varchar 0 filled without the decimal place...like 0000010000///I tried the following and it did not work...

RIGHT('000000000'+CONVERT(VARCHAR,[EODPosting].[Amount]),10),

View 8 Replies View Related

Implicit Conversion From Data Type Datetime To Int Is Not Allowed. Use The CONVERT Function To Run This Query.

Mar 26, 2008

Hey im trying to store a category name and the date into a database. For some reason i keep getting this error
 Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query.
This error is the error im getting back from the database. the datetime field in the database is a datatype (DateTime) so what exactly is going on ?protected void InsertNewCat_Click(object sender, EventArgs e)
{                    string insertSql = "INSERT into Category (CategoryName,Date) VALUES (@Category, @Date)";
                    string conString = WebConfigurationManager.ConnectionStrings["ProCo"].ConnectionString;                    SqlConnection con = new SqlConnection(conString);
                    SqlCommand cmd = new SqlCommand(insertSql, con);                   cmd.Parameters.AddWithValue("@Category", NewCat.Text);
                    cmd.Parameters.AddWithValue("@Date",DateTime.Now);
 
try
{
              con.Open();             int update = cmd.ExecuteNonQuery();            CatInsertStatus.Text = update.ToString() + " record updated.";
}catch (Exception Err)
{
             CatInsertStatus.Text = Err.Message;
}
finally
{
             con.Close();
}
}

View 9 Replies View Related

How To Convert This Into Stored Procedure?

Oct 15, 2006

I have the following coe to populate combobox with data from different tables and I want to know how to convert it into stored procedure?



private void populate_drop_down()

{

try

{

//ensure the box is cleared

cboIDType.Items.Clear();

cboNationality.Items.Clear();

cboCountry.Items.Clear();

cboGender.Items.Clear();

cboMaritalStatus.Items.Clear();

cboBloodGroup.Items.Clear();

cboProfession.Items.Clear();

cboCompany.Items.Clear();

cboBloodGroup.Items.Add("");

cboProfession.Items.Add("");

cboCompany.Items.Add("");

//Use the SQLServer provider..

//set up the connection and the command...

// sql_connection = new SqlConnection("server=JASSIM-PC\SQLEXPRESS;Trusted_Connection=yes;database=shefa;connection timeout=30");

string strSQL = "SELECT id_type FROM id_type SELECT country_name FROM iso_country SELECT gender_title FROM gender SELECT marital_status FROM marital_status SELECT blood_group FROM blood_group SELECT profession_title FROM profession SELECT account_name FROM accounts";

sql_command = new SqlCommand(strSQL, sql_connection);

//open the connection, and use the reader to populate the combobox

// sql_connection.Open();

sql_reader = sql_command.ExecuteReader();

if (sql_reader != null)

{

// while (sql_reader.Read())

// {

// cboIDType.Items.Add(sql_reader["id_type"]);

// }

while (sql_reader.Read())

{

cboIDType.Items.Add(sql_reader.GetString(sql_reader.GetOrdinal("id_type")));

}



sql_reader.NextResult();



while (sql_reader.Read())

{

cboNationality.Items.Add(sql_reader.GetString(sql_reader.GetOrdinal("country_name")));

cboCountry.Items.Add(sql_reader.GetString(sql_reader.GetOrdinal("country_name")));

}

sql_reader.NextResult();

while (sql_reader.Read())

{

cboGender.Items.Add(sql_reader.GetString(sql_reader.GetOrdinal("gender_title")));

}

sql_reader.NextResult();

while (sql_reader.Read())

{

cboMaritalStatus.Items.Add(sql_reader.GetString(sql_reader.GetOrdinal("marital_status")));

}

sql_reader.NextResult();

while (sql_reader.Read())

{

cboBloodGroup.Items.Add(sql_reader.GetString(sql_reader.GetOrdinal("blood_group")));

}

sql_reader.NextResult();

while (sql_reader.Read())

{

cboProfession.Items.Add(sql_reader.GetString(sql_reader.GetOrdinal("profession_title")));

}

sql_reader.NextResult();

while (sql_reader.Read())

{

cboCompany.Items.Add(sql_reader.GetString(sql_reader.GetOrdinal("account_name")));

}

}



//the finally clause will tidy up for us.

cboIDType.Text = "CPR";

cboNationality.Text = "BAHRAIN";

cboCountry.Text = "BAHRAIN";

cboGender.Text = "MALE";

cboMaritalStatus.Text = "SINGLE";

cboBloodGroup.SelectedIndex = 0;

cboProfession.Text = "";

cboCompany.Text = "";

}

catch (Exception oE)

{

MessageBox.Show("Problem Populating Reader Box: [" + oE.ToString() + "]");

}

finally

{

if (sql_reader != null) sql_reader.Close();

if (sql_connection != null)

{

if (sql_connection.State == ConnectionState.Open)

sql_connection.Close();

}

}

}

View 8 Replies View Related

Implicit Conversion From Data Type Ntext To Varchar Is Not Allowed. Use The CONVERT Function To Run This Query.

Oct 9, 2007

Hello Guys,Have been getting this error(
Implicit conversion from data type ntext to varchar is not allowed. Use the CONVERT function to run this query.
) when running on the live environment but it was fine when run locally. If anyone has similar problem please let me know the fix you have done.
Thank you.

View 2 Replies View Related

How To Convert String Data Type To DateTime In Derived Column Control In SSIS Package

Jun 26, 2006

Hi ,

I am Using Derived column between Source and Destination Control. the Source input column PriceTime is String Data type. but in the Destination is should be a DATE TIME column. How to Convert this string to DateTime in the Derivied Column Control.

I already tried to in the Derived column control

PRICEDATETIME <add as new column> ((DT_DBTIMESTAMP)priceDateTime) database timestamp [DT_DBTIMESTAMP]



But still throwing Error showing type case probelm



Pls help me on this



Thanks & Regards

Jeyakumar.M






View 23 Replies View Related







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