Using Query Parameter When Data Cell Has Leading Spaces
Feb 21, 2008
In SQL Reporting I want the user to pass a parameter to the report; the parameter is a employee number. Easy right, you write a where statement like where table_name.employee_number =@employee_number. When the user runs the report they€™re asked to type in the number.
My problem is the dB stores the employee number with leading spaces padding the number out to 9, so if the user types in 1 they get jack, but if they type in €˜ 1€™ they get the right employee. I can€™t roll it out that way
I€™d do something in the where clause so the user could just type in 1 & it would auto pad out to 9 spaces. I€™ve tried using the €˜LIKE€™ clause & I€™ve tried using concatenate but so far neither works well.
I'd appreciate any advice
Thanks -- Vince
View 3 Replies
ADVERTISEMENT
Aug 23, 2001
What is the best way to check for leading spaces in your table, using ltrim?
Such as TableA(name, city)
the data in TableA Smith Dallas
John New York
Greg Richmond
David Chicago
Return only David.
View 1 Replies
View Related
Dec 10, 2001
I loaded data into a CHAR fields from Legacy.
How to remove those leading spaces with in SQL server...?
View 1 Replies
View Related
Sep 27, 2001
I have a char(12) field that was loaded like '000000000101' I need to change the data to be ' 101'. Is there a way to do this and preserve the number and keep the leading spaces?
Thanks
View 3 Replies
View Related
Jan 7, 2008
Hi
Is there any way to trim all the leading and trailing spaces in all the column in a table.
JigJan
View 5 Replies
View Related
Jan 22, 2007
Hi,
I am trying to add spaces to a string value in a cell but when I run the report the value is trimmed.
Any ideas?
Here is the expression I am using:
=Fields!strVal.Value & " "
Thanks,
Igor
View 9 Replies
View Related
Dec 27, 2007
I spent huge amount of time figuring out how to preserve lading and trailing white spaces on report display without success. Can anyone help me here?
My problem is I have data with leading and or trailing white spaces and I need to show it as is. In designer preview it shows correct values. As soon as report is published and accessed on web, it truncates the whitespaces . I had a look at source, it shows values are correctly fetched(with spaces) but are ignored while rendering. I also tried replacing blank space with , however it reads this as  .
I am using asp.net 2.0 and SQL serer 2005 reporting services.
View 4 Replies
View Related
May 1, 2007
Hi,
I have an Excel 2007 file which contains values in specific cells like A23, D30 etc.
I want to populate the values in these cells using SSIS packages into individual rows of an SQL table.
How can this be achieved ?
Cheers
Sam
View 1 Replies
View Related
Jul 20, 2005
HI,I HAVE AN EXCEL SHEET WITH SOME DATA, I WANT TO IMPORT THAT DATA (CELLBY CELL WITH MANIPULATION) INTO THE SQL SERVER TABLES BY USING STOREDPROCEDURE(IF POSSIBLE).IF ANYBODY HAVE DONE SIMILER TYPE OF JOB OR KNOWING ABOUT IT, PLS. LETME KNOW.THANKS IN ADV.T.S.NEGI
View 4 Replies
View Related
Dec 20, 2007
Hello Everyone,
I've seen many entries about trailing spaces but have not found one like this.
In the Control Flow I am using an "Execute SQL Task" to populate some SSIS local variables (type string) by: (1) executing a SQL stored proc with output variables (type varchar(100)) to (2) be mapped to the local variable name (the parameter mapping Data Type is VARCHAR).
One of these mapped outputs is used as a path for subsequent operation in the Control Flow. At execution the sproc fires, populating the local variable with the path but with trailing spaces out to 255. Later in the "Script Task" when that path is used I receive an error telling me that the path is too long, and something about 260 or 246 characters.
Here's the oddity. I have two desktop environments running XP and a server environment (server 2003). This package runs just fine on the server - no trailing space issue, no need to trim. But on both my desktops I get the errors. By adding trim statements I can get back the correct path, but varchars should not be including trailing spaces, and the sproc return variable is a varchar (100).
I know this soulds like numerous other posts which indicate the solution is to trim, but I think the question I am asking is why does it work on the server but not the desktop? Is the SSIS variable type string experiencing a bug on different OS's?
Not to further complicate the issue but it used to work on my laptop, but through a horrible sequence of events I had to reload the studio in which case the error started to happen on that too.
View 6 Replies
View Related
May 6, 2004
Hi!
What I'd like to do is:
UPDATE table1
SET
A_TEXT_COLUMN = (SELECT another_text_column
FROM table2
WHERE table2_id = @precomputed_id_1)
WHERE table1_ID = @precomputed_id_2
Since the cells are text, this does not work. Since the cell to be updated is in an already exitant row, it's not possible to simply use insert.
I'd like to do something like (PSEUDOcode):
WRITETEXT(table1.A_TEXT_COLUMN, READTEXT(@textptr_initialised_to_point_at_target_c ell))
But the *actual* synatx of WRITETEXT and READTEXT seem totally inappropriate for any such trick...
Any hints or pointers HUGELY appreciated... THANX
View 1 Replies
View Related
Oct 5, 2007
Hi,
I'm working with MRS and I've got a table with a lot of entries. For each value in the table I'm trying to get the text colour to be set to 'red' when the value of the cell is less than 0. Otherwise remain black.
I can do this by setting the colour property cell by cell. But I have a lot of cells in the table. Is there a way to set the statement to apply to ALL cells in the table?
Basically I'm asking if there is a way to set the property in bulk instead of going through tediously cell by cell.
Any help would be much appreciated. Thanks!
View 4 Replies
View Related
Mar 16, 2015
Padding leading zeroes for the months in End date
Example: actual data is like
6222007
,11301998
in end date column the following query works fine for 11301998 and converts it as 19981130 which was correct.
But 6222007
fails because month has no leading zero and it converts it as 0076222 which is wrong.
How can i make it as 20070622 with the following code
select (case when replace (ltrim(rtrim(ltrim([end date]))), '|', '') in ('99999999','00000000') then NULL
else substring ([END DATE],5,4)+SUBSTRING([END DATE],1,2)+SUBSTRING([END DATE],3,2) end) as ConvEnd_date
from Mydatabase.dbo.[AccountTable]
View 3 Replies
View Related
Mar 28, 2008
I am importing csv files using dts with a filedsn pointed to the folder that contains the csv files. Some of these csv's are too big to open in notepad for me to be able to set the datatypes as I see them so I'm letting sql create the tables on import and hope the datatypes get set correctly. I have found some data that is being changed on the import like "0001" has come in as "1". What datatype should I set so the leading zeros are not dropped? Also, what other conversions should I look out for that might get changed inappropriately? Thx
View 6 Replies
View Related
Aug 15, 2007
This is embarasing.I'm creating a 500 line query from XML, CSV's, etc. and I can't fingure this out. I'm building a very complex "SELECT" query and then shoving it into the [Select] column in a SQL 2005 table. I want to call a stored procedure that just "executes" that query and returns the results....Any help would rock.
View 3 Replies
View Related
Oct 31, 2007
Hello guys,
Iam showing the query results in the asp.net grid. Iam getting a long string with more than 1 space between some words.
How i can trim the spaces of that column result.
I tried RTRIM and LTRIM but these functions need two individual strings with spaces either left or right.
Help me.
View 15 Replies
View Related
Jun 13, 2006
Hi!
Anyone knows how to select
only certain data from one data field?
Lets say i have this field which captures
Member Name and ID.
The ID is in parantheses "()".
I only want the Member name.
How do I select this from the table?
E.G.:
Field: Data
MName: John Doe (123)
I need to select only "John Doe".
Any help is deeply appreciated.
Thank you!!
View 1 Replies
View Related
Apr 22, 2008
Hi
i have 1 query please guide me,
SELECT P.ProjectName, REPLACE(SPACE(TU.TaskOutlineLevel), ' ', '__') AS dash,TU.TASKISSUMMARY AS TASKSUMMARY,
here i want to add BLANKS but not working so i have to show add spaces using __ here any idea i can add SPACES or ' ' here.
please let me know if any. basically i want to align the data in my GRIDVIEW
Thanks in advance
Parth
View 4 Replies
View Related
May 10, 2001
I want to add 3 spaces at the end of each row for the result of a query.
The initial query being output to a text file (USING DTS) is:
select colA, colB =
CONVERT( CHAR(15), TableX.ColB )
from TableX
------------------------------------------------------------------------
BUT WHEN I EXPORT THE FOLLOWING (USING DTS), I GET THE SAME RESULTS
select colA, colB =
CONVERT( CHAR(18), TableX.ColB )+char(32)+char(32)+char(32) -- ' '
from TableX
Replacing the char(32) with ' ' (3 spaces in quotes) doesn't help.
Any ideas of how to append the 3 spaces after each record when exporting to
a text file using DTS??
Thanks
View 2 Replies
View Related
Sep 15, 2006
I'm using the following command:
osql -E -n -d testdb -i testquery.qry -o "c:Scriptsoutput.txt" -h-1 -w 500 -s ","
With the following query (testquery.qry):
SET NOCOUNT ON
SELECT table1.column5, table2.column9
FROM table1, table2
WHERE table1.column4 = table2.column4
AND table1.column1 != "NULL"
ORDER BY table1.column5
All of the columns are cast as char up to 50 characters.
Even if only a field has a few characters, I get a lot of extra white space in my output. I want to get rid of those trailing spaces. I've tried SET ANSI_PADDING OFF, RTRIM(), and CAST(x AS VARCHAR(y)). I still get the same output. What am I doing wrong, what am I missing?
View 4 Replies
View Related
Feb 22, 2008
Hello, I am haing a little trouble with send cell data from an Excel sheet to SQLEXPRESS and I'm sure that it is not that hard. Has anybody else come accross this. I have the code below, but it is not complete as I'm not sure what to do to complete it:
Private Sub cmdSend_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strConn As String
strConn = "PROVIDER=SQLOLEDB;"
strConn = strConn & "DATA SOURCE=(local)SQLEXPRESS;INITIAL CATALOG=test;"
strConn = strConn & " INTEGRATED SECURITY=sspi;"
cn.ConnectionString = strConn
cn.Open
Set rs = New Recordset
With rs
' Assign the Connection object.
.ActiveConnection = cn
' Extract the required records.
.Open "UPDATE tblData Set ID = ID, Name = Name"
' Copy the records into cell A1 on Sheet1.
Sheet1.Range("A2, B2").CopyFromRecordset rs
' Tidy up
.Close
End With
cn.Close
End Sub
I know that it is not correct, but I am trying to convert a recordset query from SQL to Excel to Update Sql from Excel.
The cells from A2 down have an ID and cells from B2 down have a name.
Thanks for your time
View 1 Replies
View Related
Oct 6, 2005
I'm trying to use DTS to import data from an XLS into a SQL table.It works fine in that it INSERT's the data. However, I need it toUPDATE the table, based upon a ProjectID. Can this be done?Can a DTS package be fired from a SP using parameters?Eg UPDATE tProjects SET MyField1=XLS.Sheet1.CellA1,MyField2=XLS.Sheet2.CellA1 WHERE ProjectID = @ProjectID.Also, it must handle dynamic XLS file names, eg 981-Budget.xls,513-Budget.xls, xyz-Budget.xlsIs this the best way to go? Other suggestions most welcome?Thanks everyone in advance!
View 2 Replies
View Related
May 13, 2008
I have a table that contains a column called hardness. It is a varchar 50 and actually contains numbers. I did not create the database so not sure why they choose varchar vs. number. I need to write a query that will return all results with a space prior to the number in this column. I am having difficulty and would greatly appreciate some help. Thanks!
View 6 Replies
View Related
May 13, 2008
Hello!
We are on SqlServer 2005.
Let me point out at the beginning that I don't have anyway to normalize this structure or get the admins to change the way the data is stored. We don't own the database where this is housed...we're just given the information via an .xls file...which we import to a SQLServer table.
I have some data that is given to me that has two columns (below is for an example):
Column A is an identifiying number, i.e. for a project
Column B is a comma separated list of account strings for the project
A sample layout of what we get via the .xls file might look like the following (Column A is to the left of the dashes, and Column B is to the right of the dashes):
AA.ProjectBuildTower ----- 2222, 3333, 4444, 5555
BB.ProjectBuildFence ----- X900, 6789, 9000, 9876
What I need to do is now haveprojects listed out in Column A with each of it's account strings in Column B like so:
AA.ProjectBuildTower ----- 2222
AA.ProjectBuildTower ----- 3333
AA.ProjectBuildTower ----- 4444
AA.ProjectBuildTower ----- 5555
BB.ProjectBuildFence ----- X900
BB.ProjectBuildFence ----- 6789
BB.ProjectBuildFence ----- 9000
BB.ProjectBuildFence ----- 9876
Any suggestions would greatly help!
Thanks!
View 5 Replies
View Related
Mar 27, 2007
Hello All,
I uploaded custtable under the database, the data looks fine except that the name that apprears has a lot of distance e.g
it should be :
firstname lastname however the format appears very strange:
firstname lastname
firstname lastname
fistname lastname
Same is the case with the address, I need to adjust or format the apperance that appears on the cell. Is there a way/ sql statement to format the data under the table so that the apprearence looks okay.
I will really appreciate any sort of help on this one.
Thanks,
Rashi
View 1 Replies
View Related
Apr 24, 2007
Hi,
If there is no match in the matrix - it displays an empty cell. Is there a way to display some default number instead?
Thanks,
Igor
View 1 Replies
View Related
Jan 31, 2006
Hi,
Whenever I insert a record into my table it adds trailing white spaces up to the amount of char's that the field is set to allow. Obviously I don't want it to do this.
Among other problems then when I get the data back out it has a ton of white spaces, which normally wouldn't be a problem. i could just use the .Trim() function, but for some reason when I bind the data to a drop down list and use the .Trim() function it doesn't trim the white spaces.
Anyways any ideas on how to make it so the white spaces don't get put in in the first place?? Or any other thoughts on this?? Thanks!
View 3 Replies
View Related
Jul 23, 2005
Hello,when I export data from a table to a text file, I get trailing spacesif the data type in char. (This dosen't happen if the data type isvarchar). I can get rid of the spaces by using the trim() function onevery signle column. here is an example:DTSDestination("first_name") = DTSSource("last_name")My question is:Is there any easier way to get ride of the training spaces for allcolumns when exporing a table? It is too time consuming if I have totype trim() for every single column in the table.Thank you in advance,Eddy
View 1 Replies
View Related
Jul 2, 2015
I have a sp where query is as below.
DECLARE @ServerCIName varchar(5000)
SELECT * FROMÂ dbo.INC
WHERE Status in ('Assigned','In Progress','Pending')
and Description like '%' + (Select * from SplitDelimiterString(@ServerName,',')) + '%'
and (select DATEADD(dd, DATEDIFF(dd, 0, (Submit_Date)), 0)) = (select DATEADD(dd, DATEDIFF(dd, 0, getdate()), 0))
In place of "and Description like '%' + (Select * from SplitDelimiterString(@ServerName,',')) + '%' ", if I use "and Description like '%' + @ServerName + '%' " and pass a single value, it works.
But @ServerName contains multiple values and it is dynamic (not constant).
How do I query the data?
View 6 Replies
View Related
May 29, 2015
Currently, I want to get images of an item in my report for illustration purpose.
Below is my query to get image for item 'GL-10000' in the database. However, I would like to pass a parameter value, '@sItem', from my report so that it would get all related pics of items. Â
SQL Query:
Select top 1 item_picture_mst.picture from item_picture_mst
where item_picture_mst.item in (select item_all.item from item_all where item_all.item = 'GL-10000')
ORDER BY item_picture_mst.picture DESC;
View 3 Replies
View Related
Oct 30, 2015
i hav four cells that display
startdate       | %completed|   taskname    | indicator
[startdate value]|[%completed]|[taskname value]|[indicatorfield value]
task name and indicator are grouped by years and months
i want all these in a single cell with a separator.
View 6 Replies
View Related
Feb 28, 2008
Is it possible to format a single cell with many lines of data. For instance, if I wanted to list an entire address in one cell like this:
123 Main St.
Apt. 1
Austin, TX 78759
Would that be possible through some kind of special formatting? Maybe with <br /> or something like that?
View 1 Replies
View Related
Sep 18, 2007
Hi ,
My Input is a flat file source and it has spaces in few columns in the data . These columns are linked to another table as a foreign key and when i try loading them in a relational structure Foreigh key violation is occuring , is there a standard method to replace these spaces .
what approach should i take so that data gets loaded in a relational structure.
for example
Name Age Salary Address
dsds 23 fghghgh
Salary description level
2345 nnncncn 4
here salary is used in this example , the datatype is char in real scenario
what approach should i take to load the data in with cleansing the spaces in ssis
View 4 Replies
View Related