CHAR Column Problem
Jul 11, 2006
I have a column in my db which is char(40).
There are entries in this with the same text, but some come up with a length of 24 and some 25. This sugggests to me that there is a blank trailing space. Am I right?
However, if I update it to iteslf using a Rtrim, nothing changes.
Is is something to do with ANSI padding?
How can I get these entries to be identical, please?
View 9 Replies
ADVERTISEMENT
Jun 2, 2000
Hi All,
I put a blank or ‘0’ in one of column of a text file and then I used BCP to load this file to a table of SQL server 6.5. The field in SQL server table is char type with size 1. After I run this process, all rows with this column received ‘0’ and no blank or null at a black value place. Could you please help me to fix this problem and make some of rows in the column get a blank or null value.
TIA.
Stella Liu
View 1 Replies
View Related
Jan 31, 2005
i'm going nuts with this, i suppose i will crack it eventually, but i thought i'd ask around here, seems like all the smart SQL Server guys hang out here
(i'm an SQL guy, not an SQL Server guy)
how does one place 5 spaces into a CHAR(5) column?
create table testzeros
( id smallint not null primary key identity
, myfield char(5)
)
insert into testzeros (myfield) values (' 1')
insert into testzeros (myfield) values (' 11')
insert into testzeros (myfield) values (' 111')
insert into testzeros (myfield) values (' 1111')
insert into testzeros (myfield) values ('11111')
insert into testzeros (myfield) values (' ')
select id
, myfield
, len(myfield) as L
from testzerosno matter what i do, id=6 shows up with L=0, just like an empty string
i've even tried inserting 4 spaces and a non-blank character, which enters just fine, just as you would expect, but when i update the value and replace the non-blank character with a blank, all 5 spaces collapse back to an empty string
is there some kind of server setting like SET ALL_SPACE_EQUALS_EMPTY_YOU_IDIOT to OFF or something?
View 12 Replies
View Related
Sep 25, 2006
I have a char(11) for SSN, and I would like to default it to123-45-6789 so I can avoid having nulls in this column, and so I caneasily find the rows in which I need to have a 'correct' SSNentered/updated.I tried using just 123-45-6789, and SQL2005 doesn't seem to bedefaulting to this value, it seems to be keeping it as(((123)-(45))-(6789), and not placing it into this column when a newrow is created....Is there some special way I must specify defaults for a char(11) field(Yes, I will include the dashes).Thank you,Tom
View 7 Replies
View Related
Jan 24, 2002
Hello everyone, I have searched and seached for an answer to something that I know has to be simple but have been unsuccessful. I appreciate any help...
I am trying to take a char (6) column named col001 and convert it to datetime.
The column is in mmddyy format. I am using SQL 2000, but have available sql 7.0 servers if there is a difference. I expect that I have to write a cursor but have been unable to get the correct syntax. Thanks everyone
View 1 Replies
View Related
Jul 3, 2002
Hi,
I have a table with column size char(100), But As soon as I enter 60 charcters I get an error 'Maximum limit violation'
Any help please
Thanks
Raja Jayaseelan
View 1 Replies
View Related
Jun 13, 2002
Hi Gents,
I have a file that contains internet addresses accessed by users.
When I load this file into DTS I only want to insert into a table the first part of the address, ie,
http://www.microsoft.com.au/something/something.asp
I only want to insert the http://www.microsoft.com.au part of the address. Each address will be of varying lengths depending on the site visited, but still only want the first part. Up to the third instance of a /.
Any help???
Tony
View 1 Replies
View Related
Feb 18, 2008
I have a table column can save english(single byte) or chinese(double byte) char, how to distinguish the records containing chinese(double byte) char thru sql command
thx.
View 1 Replies
View Related
Jan 16, 2014
I am working with Excel, then within Excel I am using MS Query to query a database. I am trying to use the CAST function on a field with numbers (1,2 or 3 digits) so I can convert it to a text value with three digits, i.e. 1 would read 001, 12 would read 012, etc.
I am not using CAST in the design grid. Is this even possible?
I am modifying the underlying SQL code. Here is the line that is giving me trouble:
CAST(GL02GLF.GLF_SEQ_NUM as CHAR(3)) as “Sequenceâ€
View 1 Replies
View Related
Nov 6, 2007
sorry all help does not work , if the value like this
table = test
magusageid playid msgtype mchangeprice
------------- --------- ---------- ---------------
35 6 a 400
36 8 a 450
======================================
and other question is if magusageid is use int IDENTITY(1,1)
how can i edit char in my magusageid which like this
magusageid playid msgtype mchangeprice
------------- --------- ---------- ---------------
A000_35 6 a 400
A000_36 8 a 450
sorry the question is
when i insert one row into this table and the data type my want to auto increase 1 to z
in sql i can use IDENTITY this data type to increas but the column of data use only number without char
so i need to know how can i use IDENTITY + char to save data into one row
thank's
View 5 Replies
View Related
Apr 19, 2008
Hi I have a table, which contains Char and NChar NOT NULL columns
Now I need to change it to NULL, when I use the following command, it fails for the following error,
The command I used,
ALTER TABLE <TableName>
ALTER COLUMN <ColName> CHAR NULL
ALTER TABLE <TableName>
ALTER COLUMN <ColName> NCHAR NULL
Msg 8152, Level 16, State 13, Line 1
String or binary data would be truncated.
The statement has been terminated.
But for the same table, the below command executes fine,
ALTER TABLE <TableName>
ALTER COLUMN <ColName> SMALLINT NULL
Also I can change the NULLABILITY from NOTNULL to NULL using Enterprise Manger, editing the table using Table Design and selecting Allow Nulls option.
I need a script to accomplish this task.
Any help would be greatly appreciated.
-Senthil
View 1 Replies
View Related
Apr 21, 2008
I am trying to import data from an excel file. One of the columns contains textual information with linefeeds. Its length is greater than 255 characters. I am having trouble with truncation of the data. Is there a limitation I am running into? Is there a work around?
TIA
eventnext
View 2 Replies
View Related
May 29, 2015
How can I get time difference of the following record :
STARTTIME ENDTIME
3:30 PM 4:30PM
7:30 PM 8:30PM
I have tried it by below query,
SELECT CONVERT(TIME,STARTTIME,108) - CONVERT(TIME,ENDTIME,108) FROM BATCH_MASTER
but it gives following error message
[color=red]Operand data type time is invalid for subtract operator.[/color]
View 6 Replies
View Related
Oct 21, 2013
I have to select rows from a table
if the first 2 characters of a 12 char column are
'GB'
Select BFKEYC from table where
I have a hokey way of doing it but it looks embarrassing:
BFKEYC GT 'GA9999999999'
AND BFKEYC LT 'GC'
View 8 Replies
View Related
Sep 18, 2007
Hi guys/ladies I'm still having some trouble formatting a select statement correctly.
I am using a sqldatasource control on an aspx page. It is connecting via odbc string to an Informix database.
Here is my select statement cut down to the most basic elements.
SELECT commentFROM informix.ipr_stucomWHERE (comment > 70)
The column "comment" contains student grades ranging from 0-100 and the letters I, EE, P, F, etc. Therefore the column is of a char type. This is a problem because I cannot run the above statement without hitting an alpha record and getting the following error
"Character to numeric conversion error"
How can I write this statement where it will work in the datasource control and have it only look at numeric values and skip the alpha values?
I have tried case with cast and isnumeric... I don't think that I have the formating correct.
I have also used:
WHERE (NOT (comment = ' I' OR comment = ' EE' OR comment = ' NG' OR comment = ' WP' OR comment = ' WF' OR comment = ' P' OR comment = ' F'))
This works but is very clunky and could possibly break if other letters are input in the future. There has to be a better way.I am sorry for my ignorance and thanks again for your help.
View 2 Replies
View Related
Nov 28, 2012
Is there a way to extract the date part (11/27/2012) of a datetime/time stamp column (11/27/2012 00:00:00.000) and keep it in a date format?
The code i have below extracts the date part of a timestamp column and converts it to a char field. This becomes a problem when I joing the resultant table with a SAS dataset which contains the same column but is in a date format. The join process generates an error saying the column is in different formats.
convert(char(15), process_date,112) as process_dt
View 3 Replies
View Related
May 10, 2007
I have used the following Windows C codes to retrieve records from the bus_newjob table in SQL server:
==========================================================
// construct command buffer to be sent to the SQL server
dbcmd( dbproc, ( char * )"select job_number, job_type," );
dbcmd( dbproc, ( char * )" disp_type, disp_status," );
dbcmd( dbproc, ( char * )" start_time, end_time," );
dbcmd( dbproc, ( char * )" pickup_point, destination," );
dbcmd( dbproc, ( char * )" veh_plate, remark," );
dbcmd( dbproc, ( char * )" customer, cust_contact_person," );
dbcmd( dbproc, ( char * )" cust_contact_number, cust_details" );
dbcmd( dbproc, ( char * )" from bus_newjob" );
dbcmd( dbproc, ( char * )" where disp_status = 0" );
dbcmd( dbproc, ( char * )" order by job_number asc" );
result_code = dbsqlexec( dbproc ); // send command buffer to SQL server
// now check the results from the SQL server
while( ( result_code = dbresults( dbproc ) ) != NO_MORE_RESULTS )
{
if( result_code == SUCCEED )
{
memset( ( char * )&disp_job, 0, sizeof( DISPATCH_NEWJOB ) );
dbbind( dbproc, 1, INTBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.job_number );
dbbind( dbproc, 2, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.job_type );
dbbind( dbproc, 3, INTBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.disp_type );
dbbind( dbproc, 4, INTBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.disp_status );
dbbind( dbproc, 5, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.start_time );
dbbind( dbproc, 6, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.end_time );
dbbind( dbproc, 7, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.pickup_point );
dbbind( dbproc, 8, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.destination );
dbbind( dbproc, 9, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.veh_plate );
dbbind( dbproc, 10, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.remark );
dbbind( dbproc, 11, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.customer );
dbbind( dbproc, 12, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.cust_contact_person );
dbbind( dbproc, 13, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.cust_contact_number );
dbbind( dbproc, 14, NTBSTRINGBIND, ( DBINT )0, ( LPBYTE )&disp_job.new_job.cust_details );
// now process the rows
while( dbnextrow( dbproc ) != NO_MORE_ROWS )
{
new_job = malloc( sizeof( DISPATCH_NEWJOB ) );
if( !new_job )
return( 0 );
memcpy( ( char * )new_job, ( char * )&disp_job, sizeof( DISPATCH_NEWJOB ) );
append_to_list( &Read_Job_List, new_job );
}
}
else
{
sprintf( str, "Results Failed, result_code = %d", result_code );
log_str( str );
break;
}
==========================================================
where the job_type columIn is of the char(1) type, NTBSTRINGBIND is the vartype argument in the dbbind() function.
However, what I have gotten is nothing more than a null string from the job_type column. I have alternatively changed the vartype argument to STRINGBIND, CHARBIND and even INTBIND, but the results are the same.
Who can tell me the tricks to retrieve a char(1) column from SQL server?
View 1 Replies
View Related
Jun 19, 2008
Hi,
alter PROCEDURE [dbo].[PPUpdateIWDetails]
(
@CompanyID NVARCHAR(36),
@DivisionID NVARCHAR(36),
@DepartmentID NVARCHAR(36),
@ItemID NVARCHAR(36),
@OrderNo NVARCHAR(36),
@LineNo NVARCHAR(36),
@TAllotedQty Numeric,
@EmployeeID NVARCHAR(36),
@Trndate datetime
)
AS
BEGIN
By default iam passing 12 char itemid as parameter...
Here iam selecting the itemid from InventoryLedger -if it is 8 char than this query should be executed
IF EXISTS(SELECT ItemID FROM InventoryLedger WHERE TransDate=@Trndate AND ItemID=@ItemID AND ILLineNumber =@LineNo AND TransNumber=@OrderNo AND TransactionType='Production' AND CompanyID=@CompanyID AND DivisionID= @DivisionID AND DepartmentID=@DepartmentID)
BEGIN
DECLARE @Qty INT
select @Qty =QUANTITY from inventoryledger WHERE TransDate=@Trndate AND ItemID=@ItemID AND ILLineNumber =@LineNo AND TransNumber=@OrderNo AND TransactionType='Production' AND CompanyID=@CompanyID AND DivisionID= @DivisionID AND DepartmentID=@DepartmentID
select qtyonhand=qtyonhand+@Qty from InventoryByWareHouse where ItemID=@ItemID
END
Here iam selecting the itemid from InventoryLedger -if it is 12 char than this query should be executed(both queries are same)
IF EXISTS(SELECT ItemID FROM InventoryLedger WHERE TransDate=@Trndate AND ItemID=@ItemID AND ILLineNumber =@LineNo AND TransNumber=@OrderNo AND TransactionType='Production' AND CompanyID=@CompanyID AND DivisionID= @DivisionID AND DepartmentID=@DepartmentID)
BEGIN
DECLARE @Qty INT
select @Qty =QUANTITY from inventoryledger WHERE TransDate=@Trndate AND ItemID=@ItemID AND ILLineNumber =@LineNo AND TransNumber=@OrderNo AND TransactionType='Production' AND CompanyID=@CompanyID AND DivisionID= @DivisionID AND DepartmentID=@DepartmentID
select qtyonhand=qtyonhand+@Qty from InventoryByWareHouse where ItemID=@ItemID
END
View 11 Replies
View Related
Aug 21, 2007
I create two tables:
create table table1
(
col1 char(1)
)
go
create table table2
(
col2 char(2)
)
go
I add some records to two tables after createing operation completed.
Then i use dbcc page command to oversee the structures of data page in two tables.
I found some interest things:
The rows in two tabes take up same space:9 bytes
You can see the "9" on top of the data, for example:Slot 0, Offset 0x60, Length 9, DumpStyle BYTE
or calculate from the offset array
Any suggestions?
View 14 Replies
View Related
Dec 8, 2005
Sql Server uses bit field for boolean while Access uses Y/N. What are the pros and cons of either way? Thanks.
View 14 Replies
View Related
May 4, 2000
What does it mean char(13) and char(10) when I use this in my sql code
ali
View 1 Replies
View Related
Jul 23, 2005
I am importing a table where I need to convert a char(1) with thevalues of 't' or 'f' into a bit field with valies of 1 or 0. Is therea built-in function that does that? I've been searching, but I can'tfind an answer.
View 6 Replies
View Related
Oct 1, 2007
Hi, I am trying to write some simple SQL to join two fields within a table, the primary key is an int and the other field is a varchar. But i am receiving the error:'Conversion failed when converting the varchar value ',' to data type int.The SQL I am trying to use is:select game_no + ',' + team_name as matchfrom result Thanks
View 2 Replies
View Related
Dec 5, 2001
Hi,
Does any body know of any performance implications of using 'varchar' data type against 'char'?
I have some columns that are using 'char' data type, but the data in them is not fixed length. So, to gain some disk space I am planning to change the data type to 'varchar'. But, I am concerned if there will be any performance de-gradation or any other implications of doing this.
Regards
Chakri
View 3 Replies
View Related
Mar 26, 2001
Hi,
Is that true that using CHAR datatype improves the performance comparing to VARCHAR
thanks
indeed.
View 3 Replies
View Related
Nov 2, 2000
Would the char or varchar datatype fieldname accept non-english letters like Japanees, Chinees, Russian..etc.
Or should I use nchar or nvarchar?
Thanks
View 2 Replies
View Related
Oct 27, 2000
Why would you want to use char when you have varchar? Is there any performance hit using a varchar and the size you make that varchar?
Debate going at work.
Phil
View 7 Replies
View Related
Feb 17, 1999
I have recently inherited a database where all of the tables use varchar instead of chars for fields. Very , very few of these fields are involved in keys of even indices, but performance is an issue. I thought that I had read that varchars are worse for performance than chars when page splits may occur. Is this related to updates only, or does it matter?
Any help appreciated.
View 1 Replies
View Related
May 8, 2006
In relation to the code in this thread
http://forums.databasejournal.com/showthread.php?t=42622
My customer code field is Char (8) but accept an argument of Varchar (8) to my stored procedure. Don't ask me why!?!!
The customer code could be anything from 'A' to 'ZZZZZZZZ'.
Will this have any effect especially relating to overhead and retrieving incorrect data?
View 1 Replies
View Related
Jan 15, 2002
Hi Everybody,
I hv executed the following query in the Query Qnalyzer
(Ofcourse I am Using SQL 2000 Enterprise Edition) and Surprisingly
I am getting the Output as follows,
query:-
select '5' + 10
Output:- 15
Can anybody please tell me, why it is happening like this? OR Did I miss any Configuration Parameter in the Server Settings?.
Tks in Advance,
Sam
View 1 Replies
View Related
Jul 28, 2001
I have a table which will recieve and interface file to be loaded. All the fields are there except an account_id field which is a char(12), but the data is a number 000000000001, 000000000002, etc. These numbers are to be incremented by one. I understand how to write the process using a cursor to run through all the records and to increment them before loading. My question is the best way to get the max number in the existing table which is the char(12) , and icrement the number by one, but retain the leading zeroes I will need. Anyone had the pleasure of doing this providing input greatly appreciated.
View 5 Replies
View Related
Feb 12, 2008
I'm looking through some data in a third party application, trying to figure something out for a report. There is a char(1) column holding control characters that apparently effects the status of certain records, and whether they should appear on the report. I want to look at the integer value of those characters rather than the character representation, but I can't get it to work. I keep getting "Error converting data type varchar to numeric." I'm trying to do something like this:
Code:
SELECT CONVERT(int, MyColumn) As IntValue FROM MyTable
I've tried every combination of cast and convert I can think of, as well as numeric data types other than int. There aren't that many distinct values, so I'm just going to do this manually, but I still want to know why it won't work, or what I'm doing wrong. Any thoughts?
View 2 Replies
View Related
Dec 12, 2005
Dear All,
I am new to MS SQL. One VB application that I need to maintain using it.
There is one problem reported but I couldn't explain: one field is declared
as Char (20), but the application seems able to insert a string with length
even 30. There is no character truncatd when retrieved neither.
However, I cannot simulate the case in the MSSQL database manager. When I executed a SQL script to insert, I was simply not allowed to do so.
Any explanation to the sDid anyone encounter same thing before?
Thanks for any hint.
Regards
View 3 Replies
View Related