Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MS SQL Server


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Converting Data To Be Inserted Into A Database


Hi,

I am using web matrix, and I am trying to insert a data into a MSDE database. I have used webmatrix to generate the update code, and it is executed when a button is pressed on the web page. but when the code is executed I get the error:

Syntax error converting the varchar value 'txtAmountSold.text' to a column of data type int.So I added the following code to try to convert the data, but i am still getting the same error, with txtAmountSold.text replaced with "test"

dim test as integer

test = Convert.ToInt32(txtAmountSold.text)

Here is the whole of the function I am using:

Function AddItemToStock() As Integer

        dim test as integer
        test = Convert.ToInt32(txtAmountSold.text)
       
        Dim connectionString As String = "server='(local)Matrix'; trusted_connection=true; database='HawkinsComputers'"
        Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)

        Dim queryString As String = "INSERT INTO [stock] ([Catagory], [Type], [Name], [Manufacturer], [Price], [Weight"& _
            "], [Description], [image], [OnOffer], [OfferPr"& _
            "ice], [OfferDescription], [AmountInStock], [AmountOnOrder], [AmountSold]) VALUES ('CatList.SelectedItem.text', 'txtType.text', 'txtname.text', 'txtmanufacturer.text'"& _
            ", convert(money,'txtPrice.text'), 'txtWeight.text', 'txtDescription.text', 'txtimage.text', 'txtOnOffer"& _
            ".text', convert(money,'txtOfferPrice.text'), 'txtOfferDescrip"& _
            "tion.text', 'txtAmountInStock.text', 'txtAmountOnOrder.text', 'test')"
        Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
        dbCommand.CommandText = queryString
        dbCommand.Connection = dbConnection

        Dim rowsAffected As Integer = 0
        dbConnection.Open
        Try
            rowsAffected = dbCommand.ExecuteNonQuery
        Finally
            dbConnection.Close
        End Try

        Return rowsAffected
    End Function

Any help in solving this problem would be greatly appreciated, as I am really stuck for where to go next.




View Complete Forum Thread with Replies

Related Forum Messages:
Check Inserted Data In A SQL Database
Hi im having problems as im new to ASP.NET C#

i have created a button to add details into a SQL database but i want to check the details before i insert the new values from the textboxes

can anyone help....... this is what i have to insert into the database........i just want some help to compare the user name eg... if user name exists a message will appear telling the user to change a different user name


Thanks


private void Button1_Click(object sender, System.EventArgs e)
{
string connectionString = "server='(local)'; trusted_connection=true; database='tester'";

//System.Data.IDbConnection conn = new System.Data.SqlClient.SqlConnection(connectionString);
System.Data.IDbConnection conn = new System.Data.SqlClient.SqlConnection(connectionString);
conn.Open();

string commandString = "INSERT INTO Users (UserName, Password) " + "Values(@UserName, @Password)";

//SqlCommand dbCommand = new SqlCommand (commandString, dbconn);

System.Data.IDbCommand dbCommand = new System.Data.SqlClient.SqlCommand();

//System.Data.SqlClient.SqlCommand myCmd = new System.Data.SqlClient.SqlCommand(queryString, conn);

dbCommand.CommandText = commandString;

dbCommand.Connection = conn;

SqlParameter unParam = new SqlParameter ("@UserName", SqlDbType.NVarChar, 60);
unParam.Value = txtUser.Text;
dbCommand.Parameters.Add(unParam);
SqlParameter paParam = new SqlParameter ("@Password", SqlDbType.NVarChar, 60);
paParam.Value = txtPassword.Text;
dbCommand.Parameters.Add(paParam);

dbCommand.ExecuteNonQuery();

conn.Close();

Response.Redirect ("WebForm1.aspx");
}

View Replies !
Monitoring Inserted Data And Comparing Against Selected Data
I made ahuge load script in SQL Server 2000 as i load data from manytables(select some of each one collumns) into one single table and iwant to test the loaded data against the selected data to make surethat the loaded data is the same the selected datais there a code or tool to make this test or monitoring ?? pleaseurgent ....

View Replies !
How WCF Can Get New Inserted SQL Data ?
dear all,

I have a WCF service which is host in a console application for the time beeing.
This service provide methods for retriving history data when request.
So far so good.
 
My WCF service need also to know when a particular table (ALARMS tabel ) gets updated with DELETE, INSERT, OR UPDATE. This because my client application (WinForm) need to refresh a datagrid binding to that ALARMS table.
 
In other words my WCF servcie would send a callback event to my client when it as been notice for a change..
 
But my problem is how my WCF service can be notify from an update in my SQL table ?
I have tried SQLDependency class, but I give up was not working properly...and hard to know the xact context you are runing on.
Was thinking also of having a timer whcih pool every 1s by calling my tabel store procedure and verifiy is somerow ha changed....
 
What to do, how to do, what is the best way and thred safe method
 
Thnaks for help and advise
 
regards
serge

View Replies !
Getting Identity Of Inserted Record Using Inserted Event????
is there any way of getting the identity without using the "@@idemtity" in sql??? I'm trying to use the inserted event of ObjectDataSource, with Outputparameters, can anybody help me???

View Replies !
Getting Inserted Data In Trigger
I am using SQL Server 2000.I want to create an after insert trigger on one of my tables, but I have forgotten how I reference the inserted data to do some business logic on it. Can someone please help. Thanks Jag 

View Replies !
INSERT INTO - Data Is Not Inserted
hi thereCreated sproc - it stops dead in the first lineWhy ????Thanks in advanceCREATE PROCEDURE [dbo].[test] ASinsert into timesheet.dbo.table1 (RE_Code, PR_Code, AC_Code, WE_Date,SAT, SUN, MON, TUE, WED, THU, FRI, NOTES, GENERAL, PO_Number,WWL_Number, CN_Number)SELECT RE_Code, PR_Code, AC_Code, WE_Date, SAT, SUN, MON, TUE,WED, THU, FRI, NOTES, GENERAL, PO_Number, WWL_Number, CN_NumberFROM dbo.WWL_TimeSheetsWHERE (RE_Code = 'akram.i') AND (WE_Date = CONVERT(DATETIME,'1999-12-03 00:00:00', 102))GO

View Replies !
Access Inserted Data
i have a oledb destination in my data flow pointing to table ABC and an
error output if the insert failed..follow the error output, i have a
lookup on table ABC which doesn't seem to work..is it possible to
access new data in table ABC follow the error output?



thanks

View Replies !
Prevent Data Being Inserted Twice
I have a table with 3 columns: ID, Status, DateTime.

I created a stored procedure to insert a staus value for each ID. This will run every hour. The DateTime stores the time, date when the Status was inserted.

If the procedure was to be run a second time in hour window I do not want any Status to be inserted.

Note: that I cannot rely on the procedure being run at exactly the right time - if it was scheduled to run on the hour (i.e at 1:00, 2:00, 3 :00 etc) but didn't run until 1:20 it sould still be able to run at 2:00.

Does anyone know if there is anyway I can gaurd against this?

 

View Replies !
Compare Inserted Value In Database ?
How could i compare value or string in my database with text in textbox1 before i inserted in the same database ?

View Replies !
How To Get The ID Of An Inserted Data In A Stored Procedure
hi iam working for a stored procedure where i am inserting data for a table in a database and after inserting i must get the ID in the same procedure.later i want to insert that output ID into another table inthe same stored procedure.
for example:
alter procedure [dbo].[AddDetails]
(
@IndustryName nvarchar(50),
@CompanyName nvarchar(50),
@PlantName nvarchar(50),
@Address nvarchar(100),
@Createdby int,
@CreatedOn datetime
)
as
begin
insert into Industry(Industry_Name,Creadted_by,Creadted_On) OUTPUT inserted.Ind_ID_PK values(@IndustryName,@Createdby,@CreatedOn)
insert into Company(Company_Name,Company_Address,Created_by,Created_On,Ind_ID_FK) OUTPUT inserted.Cmp_ID_PK values(@CompanyName,@Address,@Createdby,@CreatedOn)
insert into Plant(Plant_Name,Created_by,Creadted_On,Ind_ID_FK,Cmp_ID_FK)values(@PlantName,@Createdby,@CreatedOn,@intReturnValueInd,@intReturnValueComp)
end
 
Here iam getting the output ID of the inserted data as OUTPUT inserted.Ind_ID_PK and later i want to insert this to the company table into Ind_ID_FK field.how can i do this.
Please help me, i need the solution soon.

View Replies !
Clipping Data Inserted Into NText Field
I'm having a major problem. I'm executing an sql statement to insert data into an nText field. It's clipping the text though. I haven't seen any patterns yet. Example "Welcome to the show.", it would save "Welcome to t". And it's not all the time. Please Help.

Thanks for your time,
Randy

View Replies !
User-defined Stored Procedures &&"InsertCustomer&&"in Northwind Database That Is Cached In Database Explorer:No New Values Inserted?
Hi all,
 
I put "Northwind" Database in the Database Explorer of my VB 2005 Express and I have created the following stored procedure in the Database Exploror:
 
--User-defined stored procedure 'InsertCustomer'--

ALTER PROCEDURE dbo.InsertCustomer

(

@CustomerID nchar(5),

@CompanyName nvarchar(40),

@ContactName nvarchar(30),

@ContactTitle nvarchar(30),

@Address nvarchar(60),

@City nvarchar(15),

@Region nvarchar(15),

@PostalCode nvarchar(10),

@Country nvarchar(15),

@Phone nvarchar(24),

@Fax nvarchar(24)

)

AS

INSERT INTO Customers

(

CustomerID,

CompanyName,

ContactName,

ContactTitle,

Address,

City,

Region,

PostalCode,

Country,

Phone,

Fax

)

VALUES

(

@CustomerID,

@CompanyName,

@ContactName,

@ContactTitle,

@Address,

@City,

@Region,

@PostalCode,

@Country,

@Phone,

@Fax

)
=================================================
In my VB 2005 Express, I created a project "KimmelCallNWspWithAdoNet" that had the following code:
--Form_Kimmel.vb-- 
Imports System.Data

Imports System.Data.SqlClient

Imports System.Data.SqlTypes

Public Class Form_Kimmel

 
Public Sub InsertCustomer()

Dim connectionString As String = "Integrated Security-SSPI;Persist Security Info=False;" + _

"Initial Catalog=northwind;Data Source=NAB-WK-EN12345"

Dim connection As SqlConnection = New SqlConnection(connectionString)

connection.Open()

Try

Dim command As SqlCommand = New SqlCommand("InsertCustomer", connection)

command.CommandType = CommandType.StoredProcedure

command.Parameters.Add("@CustomerID", "PAULK")

command.Parameters.Add("@CompanyName", "Pauly's Bar")

command.Parameters.Add("@ContactName", "Paul Kimmel")

command.Parameters.Add("@ContactTitle", "The Fat Man")

command.Parameters.Add("@Address", "31025 La Jolla")

command.Parameters.Add("@City", "Inglewoog")

command.Parameters.Add("@Region", "CA")

command.Parameters.Add("@Counrty", "USA")

command.Parameters.Add("@PostalCode", "90425")

command.Parameters.Add("@Phone", "(415) 555-1234")

command.Parameters.Add("@Fax", "(415 555-1235")

Console.WriteLine("Row inserted: " + _

command.ExecuteNonQuery().ToString)

Catch ex As Exception

Console.WriteLine(ex.Message)

Throw

Finally

connection.Close()

End Try

 

End Sub

End Class
==============================================

 
I executed the Form_Kimmel.vb and I got no errors.  But I did not get the new values insterted in the table "Custermers" of Northwind database.  Please help and tell me what I did wrong and how to correct this problem.
 
Thanks in advance,
Scott Chang

View Replies !
Rows Not Being Inserted Regularly Into Database Table
 Hello All,

Doe anyone know if any limitations with SQL Server Express may be causing this?

I have an application (a web service hosted on my local PC) that parses an InfoPath form and submits the data to a database (SQL Server Express). The problem I'm have is that new records are not always inserted into the database when I submit. There is an autoincrement ID field and I observed that every other record was successfully inserted (a day ago) and today I observed that the records were inserted intermittently. However, when I run the same application on a laptop, the records are inserted each time.

I posted the associated code on the Data Access forum but it occurred to me that it may be because of the nature of SQL Server Express.Any suggestions would be much appreciated. Thanks!

View Replies !
Incorrect Data Is Inserted Into The SQL Table From OLEDB Command
I have an OLEDB command in a package that inserts the data into two tables.
When I run the package, the data is getting inserted as divided by 100 of original data for derived columns.
For example: Say col1 is my input column from flat file with value 1000. I am dividing it by 100 in Derived column and then inserting into the table.
So the value 100 should be inserted into the table. But it is not so, the value 1 is getting inserted.
 
Two Tables involved here have referential integrity constraints between them. SQL Script for the operation I am doing looks like the one just below
 
INSERT INTO PrimaryKeyTable(ID,
           FirstName)
       VALUES
           (?,?)   
          
If @@rowcount=1
BEGIN
      DECLARE  @MaxID as int
 
      SELECT   @MaxID =max(AutoID) FROM  dbo.PrimaryKeyTable --AutoIncremented column
           
      INSERT INTO  [ForeignKeyTable]
                          (    [MaxID]
                                ,[Cost]
                                ,[MarkDownDollars]
                                 ,[VersionCode]
                           )          
 
      VALUES(@MaxID,?,?,'act')
 
END
 
But this script did not work in OLEDB commandL
 
So I wrote the below script for which I am facing the problem mentioned
 
 
INSERT INTO PrimaryKeyTable(ID,
           FirstName)
       VALUES
           (?,?)   
    If @@rowcount=1
BEGIN       
          
            DECLARE @Cost AS  money
            SET @Cost=?
            DECLARE  @MarkDownDollars AS  money
            SET @MarkDownDollars=?
            DECLARE @MaxID as int
 
            SELECT   @MaxID =max(AutoID) FROM  dbo.PrimaryKeyTable
           
            INSERT INTO  [ForeignKeyTable]
                          (    [MaxID]
                                ,[Cost]
                                ,[MarkDownDollars]
                                 ,[VersionCode]
                           )          
 
      VALUES(@MaxID,@Cost,@MarkDownDollars,'act')
 
END

View Replies !
How To Solve &"Tables Or Functions 'inserted' And 'inserted' Have The Same Exposed Names. &"
Hi all!In a insert-trigger I have two joins on the table named inserted.Obviously this construction gives a name collition beetween the twojoins (since both joins starts from the same table)Ofcourse I thougt the usingbla JOIN bla ON bla bla bla AS a_different_name would work, but itdoes not. Is there a nice solution to this problem?Any help appriciated

View Replies !
Using Inserted / Deleted Tables With Text / NText / Image Data Type
Hi folks,

Table:

a int,
b int,
c int,
d text

I need to change my AFTER - Trigger from this (example!):

select * into #ins from inserted

to something like

select *(without Text / nText / image -columns) into #ins from inserted.

So I tried to build a string like this: (using INFORMATIONSCHEMES)

select @sql = 'select a,b,c into #ins from inserted'
exec(@sql)

a,b,c are not of Text, nText or Image datatype.

After executing the trigger, I get an error, that inserted is unknown.

Does anyone know how to solve this ?

Thx.

View Replies !
System.Data.SqlClient.SqlException: Error Converting Data Type Numeric To Decimal.
Hi There,

I'm using C# to get a value for a DOUBLE precision variable, called "Length", from a textBox using the following line:

Length = Convert.ToDouble( txtLength.Text )

I'm also using the following lines to prepare my stored procedure call:

arParms[9] = new SqlParameter("@Length", SqlDbType.Decimal, 5);
arParms[9].Value = record.Length;

My stored procedure has the following parameter definition:

@Length decimal(9,3)

My problem is that if someone types a value bigger than 999999 in the textbox he will get for sure the following error:

System.Data.SqlClient.SqlException: Error converting data type numeric to decimal.

I don't know how to either make sql or C# to truncate the value or catch the exception to automatically assign 0 to the parameter.

Please Help.
Moshe

View Replies !
System.Data.SqlClient.SqlException: Syntax Error Converting The Varchar Value 'V' To A Column Of Data Type Int
 I am using  a stored procedure which returns a value of charecter datatype 'V' to the calling program.I am getting an sql exception System.Data.SqlClient.SqlException: Syntax error converting the varchar value 'V' to a column of data type inti didnot define any int datatype in my tablethis is my codeSqlCommand com = new SqlCommand("StoredProcedure4", connection);com.CommandType = CommandType.StoredProcedure;  SqlParameter p1 = com.Parameters.Add("@uname", SqlDbType.NVarChar);SqlParameter p2 = com.Parameters.Add("@opwd", SqlDbType.NVarChar);SqlParameter p3 = com.Parameters.Add("@role", SqlDbType.NVarChar);p3.Direction = ParameterDirection.ReturnValue;p1.Value = username.Text.Trim();p2.Value = password.Text.Trim();com.ExecuteReader();lblerror2.Text = (string)(com.Parameters["@role"].Value); can your figure out what is the error ? Is it a coding error or error of the databse

View Replies !
Converting From Express Database To Main Sql Server 2005 Database
Hi,
What are the steps required to migrate or upgrade  data or database from a sql server 2005 express database to main sql server 2005 database?
Regards,Sandy

View Replies !
Data Flow: Converting Data In Multiple Columns
Hi,

I'm just wondering what's the best approach in Data Flow to convert the following input file format:

Date, Code1, Value1, Code2, Value2

1-Jan-2006, abc1, 20.00, xyz3, 35.00

2-Jan-2006, abc1, 30.00, xyz5, 6.30

into the following output format (to be loaded into a SQL DB):

Date, Code, Value

1-Jan-2006, abc1, 20.00

1-Jan-2006, xyz3, 35.00

2-Jan-2006, abc1, 30.00

2-Jan-2006, xyz5, 6.30

I'm quite new to SSIS, so, I would appreciate detailed steps if possible. Thanks.

 

View Replies !
Converting Text Data To Ntext Data
Hi,

We are adapting our application to use unicode. However, one of our ptoblems is to ocnvert existing data from text to ntext. I couldn't find anything that document this. What is the preferred way to do this? I would like to be able to migrate the data from an existing text column to another ntext column in the table.

If I can't do that, what are the options? Preferrably, I would like to be able to do this in sql script.

Thanks.

Maggie :)

View Replies !
Converting Text Data To Ntext Data
Hi all,

My organization have a web-based application and needs it to support multilingual so we will be adapting our app to use unicode. However, one of our problems is to convert existing data from text to ntext. I couldn't find anything that document this. What is the best way to do that? I would like to be able to migrate the data from an existing text column to another ntext column in the table.


I brief you about my system, I used List manager system to store the messages and distribute to all members. Right now,by design the Lyris system keep the message in the text field which mean it 's not support multilanguage directly because of unicode field. We needs to create new Db which has the data structure as same as Lyris but just one difference is keep the message in unicode format (ntext) which we need the sql script to automatically update the new record get from Lyris to new DB.


If I can't do that, what are the options? If it's possible, I would like to be able to do this in sql script.


Thanks a mil, in advance.

Eddie

View Replies !
Converting A SQLite Database To A SQL Server Database
Hi

 

I have a SQLite database. I want to convert it to SQL Sever 2005 database. Can u pls guide me how to do it?

 

Imalka

 

 

View Replies !
Converting Data
hi, 
can any one tell me how to  convert my access data to sql server data. using sql server express edition

View Replies !
Converting Data
Hi I am converting data from old DB to NEW DBIn the OLD table fields like "PhoneNumber" the data enterd are [ 657 985-986,     (03)-987-543,      675(89)00,     ect]Is their any function in sql where I can get rid of all those spaces and () and -  between the numbers as my new field is only numbers and with out spaceOtherwise I have to clean them up manually as I have 1000000 records
cheers
 
 
 

View Replies !
Converting A SQL 7 Database To 6
Hi,

I have a SQL Server 7.0 database which I have to move to SQL Server 6.5. Is there any automated way to do it? Like a downsize wizard etc.

Or is the only way to script each of the ojects out and re-create on SQL Server 6.5 and for the data use bcp?

Any help appreciated.

Thanks

View Replies !
INSERT INTO - Data Is Not Inserted - Using #temp Table To Populate Actual Table
Hi thereApplication : Access v2K/SQL 2KJest : Using sproc to append records into SQL tableJest sproc :1.Can have more than 1 record - so using ';' to separate each linefrom each other.2.Example of data'HARLEY.I',03004,'A000-AA00',2003-08-29,0,0,7.5,7.5,7.5,7.5,7.0,'Notes','General',1,2,3 ;'HARLEY.I',03004,'A000-AA00',2003-08-29,0,0,7.5,7.5,7.5,7.5,7.0,'Notes','General',1,2,3 ;3.Problem - gets to lineBEGIN TRAN <---------- skipsrestINSERT INTO timesheet.dbo.table14.Checked permissions for table + sproc - okWhat am I doing wrong ?Any comments most helpful......CREATE PROCEDURE [dbo].[procTimesheetInsert_Testing](@TimesheetDetails varchar(5000) = NULL,@RetCode int = NULL OUTPUT,@RetMsg varchar(100) = NULL OUTPUT,@TimesheetID int = NULL OUTPUT)WITH RECOMPILEASSET NOCOUNT ONDECLARE @SQLBase varchar(8000), @SQLBase1 varchar(8000)DECLARE @SQLComplete varchar(8000) ,@SQLComplete1 varchar(8000)DECLARE @TimesheetCount int, @TimesheetCount1 intDECLARE @TS_LastEdit smalldatetimeDECLARE @Last_Editby smalldatetimeDECLARE @User_Confirm bitDECLARE @User_Confirm_Date smalldatetimeDECLARE @DetailCount intDECLARE @Error int/* Validate input parameters. Assume success. */SELECT @RetCode = 1, @RetMsg = ''IF @TimesheetDetails IS NULLSELECT @RetCode = 0,@RetMsg = @RetMsg +'Timesheet line item(s) required.' + CHAR(13) + CHAR(10)/* Create a temp table parse out each Timesheet detail from inputparameter string,count number of detail records and create SQL statement toinsert detail records into the temp table. */CREATE TABLE #tmpTimesheetDetails(RE_Code varchar(50),PR_Code varchar(50),AC_Code varchar(50),WE_Date smalldatetime,SAT REAL DEFAULT 0,SUN REAL DEFAULT 0,MON REAL DEFAULT 0,TUE REAL DEFAULT 0,WED REAL DEFAULT 0,THU REAL DEFAULT 0,FRI REAL DEFAULT 0,Notes varchar(255),General varchar(50),PO_Number REAL,WWL_Number REAL,CN_Number REAL)SELECT @SQLBase ='INSERT INTO#tmpTimesheetDetails(RE_Code,PR_Code,AC_Code,WE_Da te,SAT,SUN,MON,TUE,WED,THU,FRI,Notes,General,PO_Nu mber,WWL_Number,CN_Number)VALUES ( 'SELECT @TimesheetCount=0WHILE LEN( @TimesheetDetails) > 1BEGINSELECT @SQLComplete = @SQLBase + LEFT( @TimesheetDetails,Charindex(';', @TimesheetDetails) -1) + ')'EXEC(@SQLComplete)SELECT @TimesheetCount = @TimesheetCount + 1SELECT @TimesheetDetails = RIGHT( @TimesheetDetails, Len(@TimesheetDetails)-Charindex(';', @TimesheetDetails))ENDIF (SELECT Count(*) FROM #tmpTimesheetDetails) <> @TimesheetCountSELECT @RetCode = 0, @RetMsg = @RetMsg + 'Timesheet Detailscouldn''t be saved.' + CHAR(13) + CHAR(10)-- If validation failed, exit procIF @RetCode = 0RETURN-- If validation ok, continueSELECT @RetMsg = @RetMsg + 'Timesheet Details ok.' + CHAR(13) +CHAR(10)/* RETURN*/-- Start transaction by inserting into Timesheet tableBEGIN TRANINSERT INTO timesheet.dbo.table1select RE_Code,PR_Code,AC_Code,WE_Date,SAT,SUN,MON,TUE,WE D,THU,FRI,Notes,General,PO_Number,WWL_Number,CN_Nu mberFROM #tmpTimesheetDetails-- Check if insert succeeded. If so, get ID.IF @@ROWCOUNT = 1SELECT @TimesheetID = @@IDENTITYELSESELECT @TimesheetID = 0,@RetCode = 0,@RetMsg = 'Insertion of new Timesheet failed.'-- If order is not inserted, rollback and exitIF @RetCode = 0BEGINROLLBACK TRAN-- RETURNEND--RETURNSELECT @Error =@@errorprint ''print "The value of @error is " + convert (varchar, @error)returnGO

View Replies !
Converting Data Types
Having a slight problem. For whatever reason I had a column setup for nvchar but the only data i have in there is dates (MM/DD/YY) and a whole bunch of NULLs. I wanted to change the datatype to datetime but it gave me an error. I thought it was due to all the NULLs, so I removed all the nulls. It still doesn't work. I get the error : Conversion failed when converting datetime from character string.
I don't belive its because I have the data in mm/dd/yy format. I created another table and populated it with mm/dd/yy data as nvchar (50) and then converted to datetime and it worked fine.
 any ideas?

View Replies !
Converting Data Types
I've inherited a monster database that needs updating. It has a field called Birthdays that has been a text field and I want to convert it to datetime. The data entry people have been sloppy from time to time and some of the values generate errors when you try and change datatypes. Is there a way to change the datatype and have the oddball values left blank without bombing out the conversion process?

Thanks

View Replies !
Converting SQL Server Data Into XML
Hi Folks!

I have the following sql script I wrote using Explicit Option to convert data from SQL Server tables into a single XML file. I am aware of the tedious nature of the select statements, but this seems to the only option I have to depict parent-child nature of the data in XML format and also to schedule it as a job to run via SQL Server Agent.

My problem is that as I run this using the following command, I get "There is insufficient system memory to run this query" error.
I am using the following commnd:
exec master..xp_cmdshell 'bcp "EXEC swr_cv2..sproc_BuildXMLTree" queryout "C: est.xml" -U -P -c -r -t'

Is there any way I can tune my query to fix that error?

Thanks so much for your help!

-Parul

View Replies !
Converting Data From One Datatype To Another.
I am populating tables with Columns of fixed length (of a text format)
from a different table with some Columns of Money ( DataType).
It would not allow me to populate these Columns.

Can anyone please give me a hint?????

Thanks in advance.

M. Khan

View Replies !
Converting Read Only Data From SQL 6.5 To SQL 7
I am using SQL 6.5 and we are going to upgrade to SQL 7. Has anyone
had any experience converting "read only" data? If so, I am looking
for tips and tricks. thanks in advance.

View Replies !
Converting/ Casting Data -- HELP
My Table_A has data in Column_ A stored as varchar(50) format. I want to
be able to create a view on this data storing varchar data from numeric data.

Can I use ISNUMERIC or something similar applied with a case statement:

case IsNumeric --- ( cast(column_A) as numeric ) as Numeric_Column_A
else --- column_A as CHAR_Column_A


Thanks for any suggestion
Ziggy

View Replies !
Converting Hex Data To String
I am writing a stored procedure that generates a computername for new workstations. Our naming standards, based on terminal ID's, are as follows:
'R' + X + Y + ZZZ, where 'R' is the letter 'R', X is a hex digit indication a locatoin, Y is a hex digit indicating business line, and ZZZ is a hexadecimal sequential number assigned within each location/busines line, for up to 4096. (This isn't a perfect naming standard, but is an improvement over the one that preceded it and is a requirement for our legacy applications).
I can do everything fine, and calculate the sequential number using an int. Once I have the new number, I am trying to convert the integer to a varbinary, then convert that to a string, then use RIGHT to get the rightmost three characters of the hex string.
set @SEQNUM = 4095
set @HEXSEQNUM = CONVERT(varbinary ,@SEQNUM)
PRINT CONVERT(varbinary ,@SEQNUM) -- displays 0x00000FFE etc.
PRINT 'HEXSEQNUM ' + @HEXSEQNUM -- displays 'HEXSEQNUM'


Any ideas? I am very new to TSQL...

View Replies !
Serious Converting Data Problem
Hi,

I am going to map a SQL Server 2005 table to a SQL Server 2000 table.

Here are databases specifications:

SQL Server 2000:
Collation: SQL_Latin1_General_CP1256_CI_AS
Table: Party
Feilds:
Serial  int   not null
FullName  varchar(50)

SQL Server 2005:
Collation: Arabic_CI_AS
Table: CMN_tblParty
Fields:
PartyID   int not null
FullName nvarchar(50)

I used SSIS to map data from 2005 to 2000 but it failed. Actually it can't convert unicode field to non unicode one. Therefore I used a Data Conversion Block and I converted the FullName from CMN_tblParty to string with CodePage 1256. But when I connect this block to OLEDB Destination block, a validation error happens which mentions that it can't map data from CodePage 1256 to a 1252 one.

This shows that the SQL Server 2005 assume the SQL_Latin1_General_CP1256_CI_AS as 1252 (I don't know why) and if I change my data conversion block that it converts the FullName from CMN_tblParty to Codepage 1252, it gives an error in runtime which shows that it can't convert nvarchar from Codepage 1256 to a varchar - codepage 1252.

I used also the export data wizard in order it generate the package itself. But this also failed due to conversion problem.

As another solution I checked the DTS on SQL Server 2000 and it could successfully export data to SQL Server 2005 with no conversion problem.

Please let me know how I can run my conversion using SSIS since SSIS enhancements are greate and I am using much of it features in Conversion and Lookups.

Samy

 

 

View Replies !
Converting The Value To Data Format
Hello Everyone,
                              Please guide me in converting the value to date format.
from source i'm getting the value (which is acchally a data value) '20070730'.
I need this value to be in date format '2007/07/30'
Please help me in getting it done.
thank you

View Replies !
Converting Data Question
I need to combine two columns and copy them to another.  One column is varchar and one is decimal (3,0) and the destination column is int.  The column of decimal contains only 1 and 2 digit numbers.  I need to perface a 0 to the data with 1 digit before combining the two columns. If someone could guide me here, I'd appreciate it.  I've been trying to use cast and convert with no success.

View Replies !
Converting Data Types
I have a table with a field of Char(10) Data type

this field contains  records of work time Attendance in a decimal format

Ex. I attend today for 8.30 this means eighthours and thirty mintutes

 

the main problem faced me to make some calculations on those records (sum, subtract, etc)

so I want to convert the data from char type to decimal or real using the next code but it doesn't work

select (cast (satreg, decimal) + cast (satot, decimal)) from timecard

can u please help me in the main issue how to sum char type records or at least how to convert them to decimal

 

Regards

 

View Replies !
Converting Data From MS SQL Format
 We will be getting a disk from a company that we have been working with that will have all our data on it in

 MS SQL format. The problem is, that we do not have SQL anything here to be able to utilize our data!
 
Are there any good programs on how to convert this data to something we could use? What programs can we convert this data to?
 
Any insight appreciated. I'm fairly computer literate - but not with SQL at all.

View Replies !
Converting Relational Data In XML??
Hello everyone

When converting From Relational data into XML which
method ie RAW, AUTO, PATH, EXPLICIT is mostly used and why please

Regards

Rob

View Replies !
Converting Data Format
hi guys how can I change this format

date|amount
02/25/07| 00.00
02/26/07| 00.00

To
date|amount
02/25/07| 0.00
02/26/07| 0.00
thanks!

View Replies !
Converting .sql File Data
Hi,

I have two postcode databases in .sql ready to dump into my existing database, the first sql file is 300megs and
the second one is 300k, the reason the second is so small is because it misses out the last 3 letters of the post
code, i dont need theese last 3 digits anyway.

Basically i want to convert the second file so that it is compatible for me to import it into my database and use.

the first file looks like this

INSERT INTO `ZIPCodes` VALUES ('AB101GY',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,57.1476,-2.0975);
INSERT INTO `ZIPCodes` VALUES ('AB101NP',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,57.1467,-2.1074);
INSERT INTO `ZIPCodes` VALUES ('AB101RQ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,57.1467,-2.1107);
INSERT INTO `ZIPCodes` VALUES ('AB101TT',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,57.1431,-2.114);
INSERT INTO `ZIPCodes` VALUES ('AB101WX',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0);
INSERT INTO `ZIPCodes` VALUES ('AB106AA',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,57.135,-2.1156);
INSERT INTO `ZIPCodes` VALUES ('AB106DE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,57.1377,-2.1173);

And the second file looks like this:

insert into `hwz_postcodes` values ('postc',0,0,0,0),('AB10',392900,804900,57,-2),('AB11',394500,805300,57,-2),('AB12',393300,801100,57,-2),('AB13',385600,801900,57,-2),('AB14',383600,801100,57,-2),('AB15',390000,805300,57,-2),('AB16',390600,807800,57,-2),('AB21',387900,813200,57,-2),('AB22',392800,810700,57,-2),('AB23',394700,813500,57,-2),('AB25',393200,806900,57,-2),('AB30',370900,772900,56,-2),('AB31',368100,798300,57,-2),('AB32',380800,807200,57,-2),('AB33',355200,815100,57,-2),('AB34',350800

Is there any utility out there that can do this for me? What about the co-ordinates systems, they look incompatible,
so the converter would need to be able to convert the co-ordinates aswell. It would also need to add in all those nulls.

once the file is converted i would then import it through the sql command line.

Why am I such an SQL n00b!???

View Replies !
Converting Data Types
I have a table where one of the columns is defined as numeric (12,0). This table already contains rows.

I want to modify the attribute so that it is numeric (12,2).

When I execute the following :-

alter table test3
alter column amt1 numeric (12,2)

I get the errors :-

Server: Msg 8115, Level 16, State 8, Line 1
Arithmetic overflow error converting numeric to data type numeric.
The statement has been terminated.

Can it be done via a cast/convert statement and if so, can somehow please enlighten me?

Many thanks.

View Replies !
Converting ACCESS And EXCEL Data To SQL
Hi,
I have some tables in an ACCESS database, and would like to recreate them in a SQL2005 databse.How may this be done?I am able to create a Data Component with the ACCESS mdb file.
Likewise, how may I convert EXCEL data to SQL2005 table?Thanks.
David
 

View Replies !
Converting Data Types (GB To Unicode)
Hi, is there a way to convert the data stored from GB to Unicode?

I'm transfering data from varchar to nvarchar. :o

To add on, I'm transfering from SQL 6.5 to SQL 2000. I'd like see if SQl provides a built in function so that I don't have manually patch the 130+ records.

I'm doing this because when I view the data on the browser, it's all garbage. I tried using <meta-equiv="content-type" content="text/html; charset=gbk">, which was of no use.

Thanks.

View Replies !
Converting SQL Server 2000 Data From UCS-2 To UTF-8
Hello,

I am currently working on a JRun 3 application that lets the user input data in a Latin language such as French, English, etc. or in an Eastern or Far-Eastern language such as Arabic, Japanese, etc., into an HTML form whose character set is UTF-8. As soon as the user presses the form's Submit Button, the data get stored in a SQL Server 2000 database located on the Web server. Unfortunately, SQL Server does not support UTF-8 (see http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q232580&). It supports UCS-2 instead. As a result, the non-ASCII data returned by the database and displayed by my JSP scripts are garbage.

Is there a solution to this problem other than writing code to convert the database's UCS-2 characters to UTF-8 characters? If writing conversion code is the only solution, are you aware of any UCS-2-to-UTF-8 Java code available on the Web?

Many thanks.

Philippe de Rochambeau

View Replies !
Converting Text Dat To Ntext Data
Hi all,

My organization have a web-based application and needs it to support multilingual so we will be adapting our app to use unicode. However, one of our problems is to convert existing data from text to ntext. I couldn't find anything that document this. What is the best way to do that? I would like to be able to migrate the data from an existing text column to another ntext column in the table.

If I can't do that, what are the options? If it's possible, I would like to be able to do this in sql script.


Thanks a mil, in advance.

Eddie

View Replies !
Converting Vertical Data To Horizontal
I have a table as follows
opendate (datetime) callnumber (int) closed (bit)

I want to find how many calls were opened today and of those how many are closed

I have come up with the code below but again am looking for
1. a more elegant solution
2. a way to generalise this to show the same information for x number of days




create table #holdit1
(opencount int)

create table #holdit2
(closedcount int)

insert into #holdit1
SELECT count(*) as opencount
FROM [dbo].[problog]
WHERE datediff(dd, opendate, getdate()) = 0
AND closed = 0
group by closed

insert into #holdit2
SELECT count(*) as closedcount
FROM [dbo].[problog]
WHERE datediff(dd, opendate, getdate()) = 0
AND closed = 1
group by closed


select #holdit1.opencount AS CallsOpen, #holdit2.closedcount AS CallsClosed, #holdit1.opencount + #holdit2.closedcount AS AllCalls
from #holdit1 cross join #holdit2 #holdit2


DROP TABLE #holdit1
DROP TABLE #holdit2



this gives me
CallsOpen CallsClosed AllCalls
----------- ----------- -----------
1 3 4

View Replies !
Converting Character Data To DATETIME
For our DataWarehouse, we get several date fields from our mainframe system in a character format. When this data was loaded into SQL Server 6.5 using the CONVERT(DATETIME...) function, any dates containing 'bad' data would simply be replaced by a NULL automatically by the DBMS. We are now going to SQL 7.0, and I have found that when it hits a bad date it terminates the stored procedure, resulting with no update.

Is there a straightforward way around this? Possibly a script that will scrub the data, replacing bad data with NULLs? I'm trying to avoid writing something that will take the number of days per month and determine if it is valid.

Thanks

Michael

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved