Unwanted NVARCHAR Padding

Jan 22, 2004

I've created an asp.net page that takes the content of text boxes and writes them to a sql table.





The problem is that when I examine the resulting data in the SQL database, I find that the fields written to have had padding added (up to the maximum size of the fields).





I was under the impression that fields of type NVARCHAR did not store padding (only the no of characters being stored).





I've checked it's not the text boxes on the aspx page by explicitly posting values instead of the boxes content and the same thing happens.





Help





example of function i'm using to post data:





Function AddNews(ByVal Category As String, ByVal ApplicRole As String, ByVal NewsType As String, ByVal Description As String, ByVal News As String, ByVal Hyperlink As String, ByVal Email As String, ByVal BirthDate As Date, ByVal KillDate As Date, ByVal Parent As String) As Integer


Dim connectionString As String = ConfigurationSettings.AppSettings("AuthentConnection")


Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)


Dim queryString As String = "INSERT INTO [News]([Category],[ApplicRole],[NewsType],[Description],[News],[Hyperlink],[Email],[BirthDate],[KillDate],[Parent]) VALUES (@Category,@ApplicRole,@NewsType,@Description,@News,@Hyperlink,@Email,@BirthDate,@KillDate,@Parent)"


Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand





dbCommand.CommandText = queryString


dbCommand.Connection = dbConnection





Dim dbParam_Category As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter


dbParam_Category.ParameterName = "@Category"


dbParam_Category.Value = Category


dbParam_Category.DbType = System.Data.DbType.StringFixedLength


dbCommand.Parameters.Add(dbParam_Category)


Dim dbParam_ApplicRole As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter


dbParam_ApplicRole.ParameterName = "@ApplicRole"


dbParam_ApplicRole.Value = ApplicRole


dbParam_ApplicRole.DbType = System.Data.DbType.StringFixedLength


dbCommand.Parameters.Add(dbParam_ApplicRole)


Dim dbParam_NewsType As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter


dbParam_NewsType.ParameterName = "@NewsType"


dbParam_NewsType.Value = NewsType


dbParam_NewsType.DbType = System.Data.DbType.StringFixedLength


dbCommand.Parameters.Add(dbParam_NewsType)


Dim dbParam_Description As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter


dbParam_Description.ParameterName = "@Description"


dbParam_Description.Value = Description


dbParam_Description.DbType = System.Data.DbType.StringFixedLength


dbCommand.Parameters.Add(dbParam_Description)


Dim dbParam_News As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter


dbParam_News.ParameterName = "@News"


dbParam_News.Value = News


dbParam_News.DbType = System.Data.DbType.StringFixedLength


dbCommand.Parameters.Add(dbParam_News)


Dim dbParam_Hyperlink As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter


dbParam_Hyperlink.ParameterName = "@Hyperlink"


dbParam_Hyperlink.Value = Hyperlink


dbParam_Hyperlink.DbType = System.Data.DbType.StringFixedLength


dbCommand.Parameters.Add(dbParam_Hyperlink)


Dim dbParam_Email As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter


dbParam_Email.ParameterName = "@Email"


dbParam_Email.Value = Email


dbParam_Email.DbType = System.Data.DbType.StringFixedLength


dbCommand.Parameters.Add(dbParam_Email)


Dim dbParam_BirthDate As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter


dbParam_BirthDate.ParameterName = "@BirthDate"


dbParam_BirthDate.Value = BirthDate


dbParam_BirthDate.DbType = System.Data.DbType.Date


dbCommand.Parameters.Add(dbParam_BirthDate)


Dim dbParam_KillDate As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter


dbParam_KillDate.ParameterName = "@KillDate"


dbParam_KillDate.Value = KillDate


dbParam_KillDate.DbType = System.Data.DbType.Date


dbCommand.Parameters.Add(dbParam_KillDate)


Dim dbParam_Parent As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter


dbParam_Parent.ParameterName = "@Parent"


dbParam_Parent.Value = Parent


dbParam_Parent.DbType = System.Data.DbType.StringFixedLength


dbCommand.Parameters.Add(dbParam_Parent)





Dim rowsAffected As Integer = 0


dbConnection.Open


Try


rowsAffected = dbCommand.ExecuteNonQuery


Finally


dbConnection.Close


End Try





Return rowsAffected


End Function

View 4 Replies


ADVERTISEMENT

Unwanted Sort

Mar 21, 2006

Hi All,I am trying to delete rows from a table using a SQL statement similarto this:DELETE FROM TableA where ID1 IN(Select ID1 From TableB where ID2>= @min and ID2<=@max)Basically I want to delete all rows from TableA that have an ID in arange in TableB. This is done in a stored proc.When I look at the execution plan, it is using the indexes as I wouldhope for. The problem is that it is doing a sort which accounts for73% of the cost. I do not need to sort the results. I don't care whatorder they are deleted in.How can I prevent the sort from occuring? I need this delete to occuras fast as possible.Thanks In Advance

View 4 Replies View Related

How To Remove Unwanted Characters In SQL?

Dec 10, 2007

Hi all,
I have a stored procedure that generates the following SQL WHERE clause
UserName LIKE 'Adi234%' AND Fname LIKE 'David%' AND LName LIKE 'Justin%' AND
It is good except that it i can not remove the last AND which is not neccessary at the end of the clause.
I want to remove the last AND that come up at the end, my code places AND after each data field(UserName, Fname, Lname) .
 
Thanks

View 3 Replies View Related

Remove Unwanted Logins .

Jun 18, 2002

Hi ,

I have lot of SQL logins which do not have access to any databases . They do not show any database access when i check their properties .
My server is SQL 7.0 with SP 3 .

I want to clean up those logins with the help of script instead of deleting every login manually which is time consuming as i have to check the database access before deleting the login.

Is there any where script available or any other way to delete these unnecessary logins ? Also will it be a problem on the SQL Server if i delete those logins at one command ?

Any info. will be helpful to me.

Thanks
Sandeep .

View 1 Replies View Related

Unwanted Auto-incrementing

Aug 17, 2006

Here is a simplified version of my problem:
I am inserting data into a table using a stored procedure. The table has an identity column that increments with each insert. When I use erroneous data in the other fields the insert fails….no surprises there! But when the next insert occurs with valid data I find that my identity field has increased even with those inserts that failed, so my sequence has jumped a few numbers. How do I get the identity inserts to roll back if the rest of the data in a row doesn’t insert successfully?
Marcha x

View 9 Replies View Related

Unwanted Date Conversion - Please Help

Jul 3, 2007

Hello, I have a report that is based on a dynamic column. The column is specified by the user, and the column tyep may be text, datetime, or bigint. The user specifies the column name, and there is also a parameter that specifies the type. I allow my users to format the date via passing in a date format string, so my code looks something like:



=Switch

(

Parameters!primarycolumntype.Value = "text",

Fields(Parameters!primaryitemcolumn.Value).Value,

Parameters!primarycolumntype.Value = "date",

[DO DATE FUNCTIONS HERE, e.g. Year(Fields(Parameters!primaryitemcolumn.Value).Value)],

Parameters!primarycolumntype.Value = "numeric",

Fields(Parameters!primaryitemcolumn.Value).Value

)



The trouble I am running into is that I am getting invalid date conversion errors whenever a text value is being supplied - in other words, the code in the "DO DATE FUNCTIONS HERE" is being executed regardless of whether my primary column type parameter is text OR date. It would appear that all conversion fuctions are calculated at runtime prior to running other logic. If so, this is a bad thing for me, as that means I cannot mix data types in the same report and figure it out all dynamically. Is this true? I had always thought that the date code (in the example above, the call to Year()) would not be executed unless that statement in the switch statement was true. I've had the same luck with If statements, and Choose statements, and I've even tried using custom code.



I think my whole problem relates to a misunderstanding of how the functions are processed. Can anyone shed some light?



Thanks!



Michael

View 4 Replies View Related

How To Remove Unwanted Characters During ETL?

Jan 5, 2007

Can unwanted characters (e.g. control codes) be replaced or removed in varchar fields during extraction inside DTS package?

SQL Server/SSIS 2005.

Thanks, Andrei.

View 8 Replies View Related

Deleting Unwanted Entries At The Subscriber .

Oct 8, 2002

Hello ,

I have created a publication from SQL Server 7.0 and subscribed the publication it to one of the SQL 2000 server std. edition .

Now there are some entries in the subscription list at the subscriber which need to be deleted .
The list shows the name of the publication , the database name and the date .

I wanted to know hoe can we delete those unwanted entries. If i select the entry and right click on it , there is no delete option .

Are those entries to be deleted from one of the tables at the subscriber or the publisher ? If yes, then what is the name of the table ?

Any ideas ?

Thank you very much .

View 3 Replies View Related

Removing Unwanted Stored Procedures.

Oct 14, 1998

How do I remove old stored procedures that are no longer being used?


Thanks,

rm

View 1 Replies View Related

Unwanted Conversion Fails Sorting Code

Jan 13, 2005

I have some code that sorts a column logically even if it contains both numbers and text. But I've found that SQL converts certain characters automatically....

Here is the code...

SELECT * FROM TABLE

order by
case when isnumeric(fieldname)=1 then
right(replicate(' ', 10 ) + convert(varchar,convert(numeric(10),fieldname)),10)
else fieldnameend --10 is the length of the field


The issue I've run across is that if my column contains the following strings(5D000,5E000,4E001) it thinks they are numeric then the THEN part of the condition causes a typecasting error....

I found out that any certain combinations of number + E or D + 0. Does anyone know a way to get around this? Try it out select isnumeric('5E0303') will return 1

View 1 Replies View Related

SQL 2012 :: Removing Additional Unwanted Log File?

Jul 6, 2015

I wanted to remove an extra transaction log file that was no longer required, and ran the following against the database...

DBCC Shrinkfile (DB_Name_log2, Emptyfile);
go
alter database [Db_Name]
remove file DB_Name_log2;
go

I got a successful removal message. But if I go into the properties of the database, and click on files, it still shows up. Why is this and how can I get rid of it?

It shows up in sys.master_files as offline.

View 4 Replies View Related

How Do I Exclude Certain Unwanted Data From A Query Result

Oct 12, 2007

Hi All,

We've got a basic query that pulls a list of some parts out of our inventory database:

SELECT p21_view_inv_mast.item_id, p21_view_inv_mast.item_desc, p21_view_inv_loc.gl_account_no
FROM dbo.p21_view_inv_loc p21_view_inv_loc, dbo.p21_view_inv_mast p21_view_inv_mast
WHERE p21_view_inv_loc.inv_mast_uid = p21_view_inv_mast.inv_mast_uid

This returns a lot of info over three columns: "item_id" "item_desc" and "gl_account_no"

What I want to do is remove any entries where the "gl_account_no" shows as 011500000

I am by no means a TSQL person, I mostly run the canned queries that our vendor gives us so any help with this would be greatly appreciated.

View 4 Replies View Related

Hidden Graph At Top Of Report Causes Unwanted Whitespace

Mar 31, 2008



Hi,

I have a need to create a report that has a graph at the top and a table at the bottom. The graph at the top can optionally be made hidden because they cause problems when exported to Excel as images. However, when I set the Hidden property of the graph to true, positions of all items on the report remain absolute. Meaning of course that the table that is located half-way down the page remains half-way down the page and there is a lot of nothing on the first half where the graph used to be.

It would be desirable to have the ability to have the table move up when the graph is not visible, however it obviously doesn't do it automatically and also refuses me the ability to change the position with an expression.

Any advice is appreciated, thank you!

View 3 Replies View Related

Unwanted Conversion Of Non Latin ASCII Characters

Oct 27, 2006

hi

we get ASCII data inserted into a SQL Server database by ODBC connection from an old UNIX system.

Example: INSERT INTO test.db VALUES ('123abc', '456ПРО')

All characters > 128 are converted to "?" automatically.

We tried to setup the database to the appropriate codepage, but we allways get "?" inserted.



View 2 Replies View Related

The Parameterized Query '(@contactdate Nvarchar(4000),@dnbnumber Nvarchar(4000),@prospect' Expects The Parameter '@futureopportunity', Which Was Not Supplied.

Jan 10, 2008

HI, I am running the below method which returns this error: The parameterized query '(@contactdate nvarchar(4000),@dnbnumber nvarchar(4000),@prospect' expects the parameter '@futureopportunity', which was not supplied" Please help.Private Shared Sub InsertData(ByVal sourceTable As System.Data.DataTable, ByVal destConnection As SqlConnection)
' old method: Lots of INSERT statements Dim rowscopied As Integer = 0
' first, create the insert command that we will call over and over:
destConnection.Open()Using ins As New SqlCommand("INSERT INTO [tblAppointmentDisposition] ([contactdate], [dnbnumber], [prospectname], [businessofficer], [phonemeeting], [followupcalldate2], [phonemeetingappt], [followupcalldate3], [appointmentdate], [appointmentlocation], [appointmentkept], [applicationgenerated], [applicationgenerated2], [applicationgenerated3], [comments], [newaccount], [futureopportunity]) VALUES (@contactdate, @dnbnumber, @prospectname, @businessofficer, @phonemeeting, @followupcalldate2, @phonemeetingappt, @followupcalldate3, @appointmentdate, @appointmentlocation, @appointmentkept, @applicationgenerated, @applicationgenerated2, @applicationgenerated3, @comments, @newaccount, @futureopportunity)", destConnection)
ins.CommandType = CommandType.Textins.Parameters.Add("@contactdate", SqlDbType.NVarChar)
ins.Parameters.Add("@dnbnumber", SqlDbType.NVarChar)ins.Parameters.Add("@prospectname", SqlDbType.Text)
ins.Parameters.Add("@businessofficer", SqlDbType.NChar)ins.Parameters.Add("@phonemeeting", SqlDbType.NVarChar)
ins.Parameters.Add("@followupcalldate2", SqlDbType.NVarChar)ins.Parameters.Add("@phonemeetingappt", SqlDbType.NVarChar)
ins.Parameters.Add("@followupcalldate3", SqlDbType.NVarChar)ins.Parameters.Add("@appointmentdate", SqlDbType.NVarChar)
ins.Parameters.Add("@appointmentlocation", SqlDbType.NVarChar)ins.Parameters.Add("@appointmentkept", SqlDbType.NVarChar)
ins.Parameters.Add("@applicationgenerated", SqlDbType.NVarChar)ins.Parameters.Add("@applicationgenerated2", SqlDbType.NVarChar)
ins.Parameters.Add("@applicationgenerated3", SqlDbType.NVarChar)ins.Parameters.Add("@comments", SqlDbType.Text)
ins.Parameters.Add("@newaccount", SqlDbType.NVarChar)ins.Parameters.Add("@futureopportunity", SqlDbType.NVarChar)
' and now, do the work: For Each r As DataRow In sourceTable.RowsFor i As Integer = 0 To 15
ins.Parameters(i).Value = r(i)
Next
ins.ExecuteNonQuery()
'If System.Threading.Interlocked.Increment(rowscopied) Mod 10000 = 0 Then
'Console.WriteLine("-- copied {0} rows.", rowscopied)
'End If
Next
End Using
destConnection.Close()
End Sub

View 6 Replies View Related

Compare Nvarchar(10) With Nvarchar(1000)

Sep 4, 2007

I had this question for quite a long time.

It seems the latter one don't take any extra storage space than the previous one.

As long as the real string length is less than 10.

Is that mean the latter one not cost anything?

I once heard the different is when they are in memory. But not sure of it.

Can anyone explain it and provide some official reference on it?

Thank.

View 6 Replies View Related

SQL Server 2012 :: Remove Unwanted P/L Transaction Lines?

Aug 20, 2015

I am creating a report query that returns all unreconciled P/O lines. I am near completion but I am unable to find a way to remove the reconciled records.

I have included a script to produce some sample table, data & query.

The recordset dispalys 6 rows. All reconciled Supplier Invoices are duplicated and have transaction codes 40, 50 and reconcile code of 9 (5024, 921689471).

All unreconciled only appear once and have transaction codes 40 and reconcile code of 0 (4835 & 921978016). These are the only records that I want to show.

CREATE TABLE [dbo].[Purch_Ledger](
[EPDIVI] [nvarchar](3) NULL,
[EPSUNO] [nvarchar](10) NULL,
[EPSINO] [nvarchar](24) NULL,
[EPDUDT] [numeric](8, 0) NULL,
[EPTRCD] [numeric](2, 0) NULL,

[code].....

Whatever I try I cant find a way to get rid of the unwanted records.

View 3 Replies View Related

Padding...

Jul 31, 2000

Hi,

I'm using SQL Server 7.0. I am importing data from an EXCEL spreadsheet. I need to pad my agent_id column from the spreadsheet with zero's. Here are the values from the spreadsheet:

agent_id
--------
123
4567
112233
9

This is what I need to see in my database column:

agent_id (char(6))
--------
000123
004567
112233
000009

Is there a setting on the column in SQL Server 7.0 that I can set to pad the column with zero's?

Thanks in advance,
Darrin

View 1 Replies View Related

How To Delete Unwanted Data From Multiple Different Tables With One Single SQL Query?

Mar 18, 2008

This a microsoft SQL 2000 server.
I have a DB with mutliple tables that have a column called "Date_stamp", which is used as a primary ID.
Here is my problem:
Some of tables have a bad datetime entry for the "Date_stamp". The bad entry is '2008-3-18". I need to delete this entry from every single table that has a name similary to 'Elect_Sub%Daily'.

I know how to get the user table names from the DB as follows:

SELECT name
FROM dbo.sysobjects
WHERE xtype = 'U' and name like 'Elect_Sub%Daily'

What I need to do is have a query that will basically scroll through the tables name produced by the above query and search and delete the entries that read '2008-3-18".

delete from tableName where Date_Stamp = '2008-3-18'

View 7 Replies View Related

Removing Padding From Var

Feb 7, 2008

I have a search box to look up using a number as an identifier. Currently my query is where x = @enteredNumber, but some place where a user might get the number it is padded with zeros. We can have them just see the number and retype it.
 EG: 000000123  would be entered as 123.
 But, I would like to let them copy and paste, but then strip the zeros (left padding only).
EG:
@num = stripPadding(@enteredNumber)
IE:
@num = stripPadding(000000123)
@num = 123
 

View 2 Replies View Related

Varchar Padding

Jun 12, 2000

upgraded to 7.0 and all was fine until...

we run a job that pull selected fields from a table and writes them to a dos text file.
(tables get loaded via bcp)

Pre-7.0, all varchar data was correctly output without any padding.

NOW, all varchar fields are padded with spaces on output.

tried toggling the Set ansi_padding switch before creating table def, didn't work.

HELP! (please?)

fw

View 1 Replies View Related

ANSI PADDING (pt.2)

Jun 13, 2000

ok people, this is getting seriously frustrating! Please help!

As mentioned in a previous post, one of my batch jobs is printing fields with padding added, even when
the table column is defined as varchar.

I've been to the knowledge base, read the article on ansi padding, ran the test scripts.
But when I ran the select to display the columns,
THE OUTPUT FOR BOTH TABLES WAS IDENTICAL!!!
Apparently the SET ANSI_PADDING ON/OFF option had no effect!

What am i doing wrong? What is missing? Do i have to run the Set Ansi Padding option in the Master DB
context? Have I unknowingly overridden the option somewhere else? Must I brush up on my COBOL
for a career change?

HELP!

fjw

View 2 Replies View Related

Padding In SQL 2000

Apr 20, 2007

Hi All,
Is there equivalent of LPAD in SQL 2000 similar to that in Oracle?
I am trying to work out for below piece of query

TO_CAHR(LPAD(columnname,20,'0'))

vishu
Bangalore

View 6 Replies View Related

Right Padding Equivalent

Jun 28, 2006

Hi everyone,Please excuse me if this has been asked before or sounds a bit dim.This is a question asked on another forum but the solutions beingoffered are focussing on programming rather than letting the DB serverdo the work, which I'm not sure is the most efficient solution.However, my confession is I dont use SQL server so can't help themdirectly with the syntax. Hopefully you can help me help them and learna little about SQL Server in the process.Trying to right pad a first name field so the padded string is a totalof 30 chars. It will be output concatenated with the last name field,and each field separated with a "|". So that when output it readssomething like:fname | mylastnameSyntax given was:select id,substring((last_name+','+rtrim(' '+isnull(level,'))+''+rtrim(isnull(first_name,'))+space(30)),1,30)+ ' | ' as student_namefrom studentIssue: It appears this is padding correctly but the spaces are notrendering in the browser. (I have no way to check this as I don't usesqlserver. However, I can understand that multiple spaces are not goingto render in the client browser, if indeed the query is padding withspaces.Question: Instead of using space(), can replicate() be used and aunicode space representation rather than an actual space be used? Or,is there a better way that will ensurethe padding shows in browser?I guess a fixed width font would also need to be used otherwise the30-char blocks could wind up being different widths, which would defeatthe purpose.If there is something I've missed, or you have any suggestions, I'mkeen to learn.TYhanks in advance,Lossed

View 13 Replies View Related

Borderstyle And Padding

Apr 25, 2007

I need a table similar to Fig-1 on my report. The subtotal and total lines need top padding and solid border at top and bottom. I€™m currently using bottom padding of 20pt on the sub total row and setting the border style property of the sub total and total rows to solid at top and bottom. But the problem is that the sub total rows are being padded first and then the border at the bottom is being set to solid. As a result, my table looks something similar to figure 2, which is not acceptable to my customer. I also tried by setting the top padding of the lines below subtotals, but it doesn't give me what I need. Any way I can set the border before padding? Appreciate your help.

Figure-1





A

10


B

20


C

30


Sub Total

60







D

20


E

10


F

50


Sub Total

80







TOTAL

140

Figure-2





A

10


B

20


C

30


Sub Total

60







D

20


E

10


F

50


Sub Total

80







TOTAL

140

View 5 Replies View Related

Padding Zeroes To An Int

Jan 18, 2008

Hi,

I need a simpler way of doing this:

I've a number column which I need to show as a 3 digit field in a string:
Example:
number =1; string = 010
number =10; string =100

is there any function that can do this string manipulation?


Currently I'm using a CASE statement to check the length of this number column,
if its single digit I use:
SUBSTRING(('0' + CONVERT(VARCHAR,CONVERT(INT,ISNULL(D.Number,E.Number)))+'0'),1,3)

else I use
CONVERT(VARCHAR,CONVERT(INT,ISNULL(D.Number,E.Number)))+'0')

Is there a better way of doing this?

Thanks,
Subha

View 5 Replies View Related

Reporting Services :: Strip Unwanted Characters From Parameters For SSRS Report

May 22, 2015

I have a third party app that passes parameters (main dataset query) from the app to SSRS.  Unfortunately, when the parameters are passed from the app they will contain equal signs ("=") in front of each parameter.  For example, the parameters that may be passed to the main dataset query should be:

"HYDRO, OKO, ONEPL, TECHNI"

However, the parameters that are passed from the app, get to SSRS as:

"=HYDRO, =OKO, =ONEPL, =TECHNI"

Again, this is for the main dataset query and there may be one parameter or there may be any number of them.

Basically, I need to strip the "=" signs from the parameters. whether there is one parameter or ten.

I believe that I will need a custom function to strip the equal signs?

View 5 Replies View Related

Padding Values In A Column

Dec 6, 2001

Hi all-

I'm inserting 4-digit codes into my db table where the column is a smallint type. Some of these codes begin with 0's, like "0003". How can I format the val in this column to always have the extra 0's in front?

Thanks!

View 3 Replies View Related

Transact SQL Padding Strings

Oct 24, 2001

Is there a function in transact sql to pad a column with leading zeros?
Similar to the LPAD function in Oracle.

View 1 Replies View Related

Padding An Implied $ Amt Field

Mar 7, 2008

HI Guys, I have a question. I have to output 2 implied decimal amount fields (AJ_Dollar_Amount & AJ_Amount). I have defined they as decimal (13, 0) and decimal (17, 0) respectively. I was told to use the following func to pad the field, but it is not working. How should I define field(s) or rewrite the Cast statement to get it to work?

Right('0000000000000' + Cast(AJ_Dollar_Amount as varchar (13)), 13),

Thank you,

View 11 Replies View Related

SELECT Query Help - Zero Padding

Jul 20, 2005

Hi,I've got a field that stores numeric values, representing a tracking number.I've also got a stored procedure that will extract this field and return itto a client. However, I would like to return it slightly differently to theway in which it is stored. Basically, I want to return it as TRK000nnn -Where TRK is the string "TRK", 000 is zero-padding up to 4 zeros, and nnn isthe number itself - results would look something like this:Tracking Number Formatted Value1 TRK0000124 TRK0002443321 TRK43321At the moment, a typical query could look something like this.SELECT ("TRK" + CAST(trackNo AS varchar(10)))FROM TB_QueueBut I'm not sure how to go about the zero padding. This would be easiest todo on the client, but it is impractical (there are many client programs thatwill use this stored procedure, and the format that it is returned as mayneed to be altered in the future).Many thanks,Rowland.

View 6 Replies View Related

MS OLE DB Provider For DB2 - String Padding

Jan 12, 2006

When using the MS OLE DB Provider for DB2 for retrieving data from a DB2 database on an AS/400, all string are padded with white spaces in the end. For instance, if you have a text field with a length of 10 and the field contains the text 'xyz', then when you transfer the data using SSIS you will get the text 'xyz       ' ('xyz' followed by 7 times white space). Is there any way to get around this - other than using the RTRIM function in the source query?

View 4 Replies View Related

Padding Fields With Zeros.

Oct 4, 2006

I am trying to create a field in SQL query builder that takes the input number 12345 and formats it 0000012345. In MSAccess there is a great Format() function which allowed this to be done easily, but I cant find an equivalent in SQLServer. Can anyone provide me with a new function and possibly a sample? Thanks in Advance,

Michael.

View 6 Replies View Related







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