T-SQL (SS2K8) :: How To Convert Alphanumeric With Symbols To INT

Jun 5, 2015

I am new to SSC . I have a table that has NO.OF WORKING HOURS for 30 days. I am trying to convert all the values into INT as MINS to generate a SSRS report.

Note: There are some records with negative value (-4h15m)

Sample

NAME D1 D2 D3 ....D31
X1 9H 30M NULL 10M
X2 0M 1H 30M -4H45M
X3 20M -1H NULL

View 6 Replies


ADVERTISEMENT

T-SQL (SS2K8) :: Using Like To Identify Value That Contain Alphanumeric Values Other Than A-Z

May 11, 2015

Trying to use LIKE / NOT LIKE to identify values that contain any alphanumeric characters outside of A-Z e.g £%$^&*_-{[@ etc etc

The field should contain only values between A-G with a numberic e.g ABCD1234567... but some rows have characters such as above, some have spaces (weeps) , and some have letters outside the A-G range ....

View 7 Replies View Related

Convert Column Of Data Alphanumeric To Integer

Nov 14, 2013

I need to convert a column of data from alpha numeric to integer.

I am only querying the tables i.e. i don't have access to actually change the data tables themselves.

CAST or CONVERT throws up an error. Are there any other commands i can use at the query stage?

The data I need to convert is always actually a number. i.e. even though it is recognised as alpha numeric, the figure is a number.

I just need it to be converted to an integer so i can SUM it etc.

View 8 Replies View Related

T-SQL (SS2K8) :: Convert Value To Seconds?

Jun 3, 2014

I want to calculate total sum of column.

I have a table with many values of column:

declare @time table
(times nvarchar(255))
INSERT INTO @time (times)
Select ('05:01')
UNION ALL
Select ('00:01')
UNION ALL
Select ('170:01')
UNION ALL
Select ('2543:01')
Select * from @time

How can I get seconds value for every row?

05:01 - 301
00:01 - 1
170:01 - 10201

P.s. Finally I use - Select convert(char,dateadd(second,152581,60),108) as sumtime

View 2 Replies View Related

T-SQL (SS2K8) :: Convert String To Date?

Sep 5, 2014

I'm importing dates into a table with Bulk insert

SET DATEFORMAT DMY

it works with dates e.g. "14/01/2009"

However sometimes I get dates in the format

"Fri 14/01/2009"

What is the best way to convert these.

I can only think of putting them in a staging table with all date fields as varchars Then updating these varchar fields

LTRIM(REPLACE(dtField, 'Mon', ''))
LTRIM(REPLACE(dtField, 'Tues', ''))

View 9 Replies View Related

T-SQL (SS2K8) :: Way To Convert Rows To Columns

Sep 17, 2014

I work with SQLite and need to write a query the old school way to convert rows to columns. If it was MS SQL I would use pivot to get the expected result. However this is SQLite I cannot use pivot.

Sample data:

create table t1 (id int, Dept char (1), Total int);
insert t1
select 1, 'A', 100
union
select 2, 'B', 120
union
select 3, 'C', 140
union
select 4, 'D', 150;

How do I use LEFT OUTER JOIN to produce result similar to the below?

SELECT 'Total' AS Dept,
[A], [B], [C], [D]
from

[code]....

View 7 Replies View Related

T-SQL (SS2K8) :: Convert Numeric Value To CHAR(7)

Sep 22, 2014

I have to store the result of a calculation in a column of type CHAR(7) (and am unable to change the column type).

The calculation can have results ranging in size from 0.1234567 to 99999999.

In the first case, I would need to store the value of 0.12345 in the column. In the later case, an error should be thrown.

So I need to store all of the significant digits from the left of the decimal (if there are < 7) and as many of the digits to the right as will fit into a CHAR(7), with the remaining precision being truncated.

View 6 Replies View Related

T-SQL (SS2K8) :: Convert Varchar To Float

Feb 11, 2015

I have the following CASE statement:

SELECT CASE WHEN [TBL_whole_rock_geochem].au = 0 THEN '<' + [TBL_ActLab_codes].[Au] ELSE [TBL_whole_rock_geochem].[Au] END AS [Au det]

It errors on the highlighted code.

Error converting data type nvarchar to float

the code should return :

<0.5
<1

I have tried '<' + ISNUMERIC([TBL_ActLab_codes].[Au]) but received this error

Conversion failed when converting the varchar value '<' to data type int.

How I can concatenate the < with a float value?

View 5 Replies View Related

T-SQL (SS2K8) :: Date Format - Convert Function

Mar 12, 2014

How to get this out put.

Details:

declare @deadline Datetime = '2014-03-23 15:30:10.000'
SELECT CONVERT(VARCHAR(30),@deadline, 100) AS DateConvert
----With this I am able to produce that like
----o/p: Mar 23 2014 3:30PM

declare @deadline1 Datetime = '2014-03-03 15:30:10.000'
SELECT CONVERT(VARCHAR(24),@deadline1, 100) AS DateConvert

--o/p: Mar 3 2014 3:30PM
--expected O/p: Mar 03 2014 03:30PM

What is the correct date format to achieve this.

View 2 Replies View Related

T-SQL (SS2K8) :: Convert Float To A Phone Number

Apr 2, 2014

I seem to always get the "Fun Stuff" to try and figure out. I have an entire table that was pumped out of Oracle. I even hate saying that word!

There are a couple columns that are Float data type, and they are storing phone numbers as a Float data type. I am not able to CAST these into anything that is legible.

This is one of the values that I made up that look like some of the others.

9.72732e+009

View 2 Replies View Related

T-SQL (SS2K8) :: Convert Records From Rows To Columns

Nov 13, 2014

I have 5 columns in my database. 1 column is coming like a dynamic.

I want to convert records from rows to columns. Currently I have a data like this.

Race AgeRange Amount

W 17-20 500
W 21-30 400
W 31-40 200
A 17-20 100
H 41-50 250
H 51-60 290

So age range is not fixed and it can be any and I have one separate relational table for age range where it's coming from. Now I want to convert it into columns like

Race 17-20 21-30 31-40 41-50 51-60

W 500 400 200 0 0
A 100 0 0 0 0
H 0 0 0 250 290

View 3 Replies View Related

T-SQL (SS2K8) :: Convert Non-delimited Column Value Into Rows

Nov 14, 2014

I have a scenario wherein one of the column values in a row contains a string value which is non-delimited (as shown below). I need to split them by 2 characters and generate as many rows as count of set of 2 digits in that string.

Current record

RecordID Name CountyList
1 ABC 00
2 CDE 01020304
3 XYZ NULL

Expected output:

RecordID Name CountyList
1 ABC 00
2 CDE 01
2 CDE 02
2 CDE 03
2 CDE 04
3 XYZ NULL

I already have a solution in place to run it thru cursor and then do a while loop on the CountyList column by taking 2 digit value using Substring function (keeping start position dyanamic and jumping 2 positions).

View 2 Replies View Related

T-SQL (SS2K8) :: Try Convert Causes Change In Transaction State

Mar 16, 2015

Why does this code (below) cause a change in the transaction state?

DECLARE @date DATE,
@string VARCHAR(5)= 'test'
BEGIN TRAN
PRINT XACT_STATE()

[Code] ....

View 8 Replies View Related

T-SQL (SS2K8) :: Convert Binary String To Table Value Construct?

Mar 21, 2014

Code snippet for changing '00001001001' into a table value construct containing (64,8,1)?

View 6 Replies View Related

T-SQL (SS2K8) :: Convert Column In Query1 And Return Unmatched?

Apr 14, 2014

I have cpt codes in qry1 that need to be converted then match against qry2 and return the unmatched.

Example:

Cpt 88305 in qry1 can be either g4164 or g4165 in qry2
Cpt 88174 in qry1 can be either g3564 or g3565 or g3566 in qry2

select
Invoice_number
,cpt
From qry1
Select
Invoice_number
,cpt
From qry2

What is the easiest way to get the unmatched from qry1 against qry2 joining on invoice_number and converted cpt?

View 1 Replies View Related

T-SQL (SS2K8) :: Convert Multiple Rows And Columns Into Single Row

Apr 25, 2014

I have this query

SELECT
'Type'[Type]
,CASE WHEN code='09' THEN SUM(Amt/100) ELSE 0 END
,CASE WHEN code='10' THEN SUM(Amt/100) ELSE 0 END
,CASE WHEN code='11' THEN SUM(Amt/100) ELSE 0 END
,CASE WHEN code='12' THEN SUM(Amt/100) ELSE 0 END
FROM Table1 WHERE (Code BETWEEN '09' AND '12')
GROUP BY Code

and the output

Column 1 Column 2 Column 3 Column 4
Type 14022731.60 0.00 0.00 0.00
Type 0.00 4749072.19 0.00 0.00
Type 0.00 0.00 149214.04 0.00
Type 0.00 0.00 0.00 792210.10

How can I modify the query to come up with output below,

Column 1 Column 2 Column 3 Column 4
Type 14022731.60 4749072.19 149214.04 792210.10

View 9 Replies View Related

T-SQL (SS2K8) :: Replace Cursor - Convert To Recursive CTE Or While Loop

Jul 2, 2014

Need getting the below Cursor query convert to a Recursive CTE or with a while loop as I do not want to use a cursor.

Declare @Companyname Nvarchar (400)
declare @str nvarchar(MAX)
TRUNCATE TABLE STAGING.dbo.[IT_G_L Entry]
DECLARE GLEntry_cursor CURSOR FOR
SELECT REPLACE Name FROM Company where Name <> 'AAAAA'
OPEN GlEntry_cursor

[Code] ....

View 9 Replies View Related

T-SQL (SS2K8) :: Convert Multiple Rows In Single Column

Sep 4, 2014

Scenario is like that single dept can have multiple LocationHeads, If Location heads are multiple then they should display in single column using *starting the name as mentioned bottom under required output.

Below is sample of data:

create table #Temp(depID int, Name varchar(50),LocationHead varchar(50))
insert into #temp values(1,'test','head1')
insert into #temp values(1,'test','head2')
insert into #temp values(1,'test','head3')
insert into #temp values(2,'test1','head1')
insert into #temp values(2,'test1','head2')

Required output

depID Name LocationHead
1test *head1,*head2,*head3
2test1 *head1,*head2

View 2 Replies View Related

T-SQL (SS2K8) :: Convert Datetime To W3C Date And Time Format

Dec 21, 2014

I have a standard datetime and I need to convert it to the client specification of:

YYYY-MM-DDThh:mm:ssTZD
eg: 2009-04-16T19:20:30+08:00

I am not sure of the easiest way to do this.

The test code below gets me part of the way but I am unsure on how to get the offset on the end without hardcoding to much.

DECLARE @datetime DATETIME = '2014-12-20 12:30:00'
SELECT CONVERT(VARCHAR(30),@datetime,127)

View 2 Replies View Related

T-SQL (SS2K8) :: How To Concatenate / Convert Date And Time Into Datetime

Aug 3, 2015

We have 2 columns:

StartDate - data type Date
StartTime - data type Time

I need to combine them into a DateTime data type. For now, I convert each of them into varchar, insert space in between, and convert to DateTime, like this:

convert(datetime, convert(varchar(10), EndDate , 101) + ' ' + CONVERT(varchar(20), EndTime,24))

Is there a better, more elegant way to do this?

View 9 Replies View Related

T-SQL (SS2K8) :: Convert Cursor To Recursive CTE Or A Normal Query?

Sep 25, 2015

I have a stored proc I want to convert it to either a Normal Query using A while loop or a set based operation/recursive cte as I want to run it for multiple CompanyNames. I get the error message as An INSERT EXEC statement cannot be nested when I execute if for Multiple Companies using another Cursor

If I convert it to a Function I get the below error message

Invalid use of a side-effecting operator 'EXECUTE STRING' within a function

converting this query to a normal query or let me know if there is any change which need to done to work with multiple companynames.

CREATE PROC [dbo].[USPT] @CompanyName varchar(50),@tablename varchar(50)
AS
BEGIN
-- EXEC [USPT] 'xyz corp','Sales Header'
DECLARE @str1 VARCHAR (MAX)
set @str1 = '
DECLARE @No VARCHAR (MAX)

[code]....

View 5 Replies View Related

T-SQL (SS2K8) :: Using CAST Or CONVERT To Change Data From String To Datetime?

Apr 16, 2014

i am trying to take a field that has part of a date in it, so I have to parse it out as follows:

SUBSTRING(a1.Field1, 3, 2) + SUBSTRING(a1.Field1,5,2) + '20' + LEFT(a1.Field1,2)

This is because a date of 04/16/2014 will show as 160416 in the first part of the field I need to parse it out of, thus becoming 04162014.

From there I then need to convert this "date" into a legitimate SQL datetime type, so that I can then run a DATEDIFF to compare it to when the record was actually entered, which is a separate field in the table, and already in datetime format.

When I use the below statement, I am getting the message that, "Conversion failed when converting date and/or time from character string."

CAST((SUBSTRING(a1.Field1, 3, 2) + SUBSTRING(a1.Field1,5,2) + '20' + LEFT(a1.Field1,2)) as datetime)

I also tried CONVERT(datetime, (SUBSTRING(a1.Field1, 3, 2) + SUBSTRING(a1.Field1,5,2) + '20' + LEFT(a1.Field1,2)), and got the same message.

how I can parse that field, then convert it to a datetime format for running a DATEDIFF statement?

View 9 Replies View Related

T-SQL (SS2K8) :: Convert Unique Identifier From String To Use In A Join / Where Clause

Jan 6, 2015

I am wanting to get the job name based on sys.sysProcesses.[Program_name] column. Why is this query not returning any results even though the 2nd substringed guids are found the the sysJobs table?

SELECTCASE
WHEN RTRIM([program_name]) LIKE 'SQLAgent - TSQL JobStep (Job %' THEN J.Name
ELSE RTRIM([program_name])
END ProgramName
, Val1.UqID
, Val1.UqIDStr

[Code] ......

View 6 Replies View Related

T-SQL (SS2K8) :: Pivot Query - Convert Data From Original Table To Reporting View

Apr 8, 2014

I want to convert the data from Original Table to Reporting View like below, I have tried but not get success yet.

Original Table:
================================================================
Id || Id1 || Id2 || MasterId || Obs ||Dec || Act || Status || InstanceId
================================================================
1 || 138 || 60 || 1 || Obs1 ||Dec1 || Act1 || 0|| 14
2 || 138 || 60 || 2 || Obs2 ||Dec2 || Act2 || 1|| 14
3 || 138 || 60 || 3 || Obs3 ||Dec3 || Act3 || 1|| 14
4 || 138 || 60 || 4 || Obs4 ||Dec4 || Act4 || 0|| 14
5 || 138 || 60 || 5 || Obs5 ||Dec5 || Act5 || 1|| 14

View For Reporting:

Row Header:
Id1 || Id2 || MasterId1 || Obs1 ||Desc1 ||Act1 ||StatusId1||MasterId ||Obs2 ||Desc2 ||Act2 ||StatusId2 ||MasterId3||Obs3 ||Desc3 ||Act3 ||StatusId3||MasterId4||Obs4||Desc4 ||Act4 ||StatusId4 ||MasterId5||Obs5 ||Desc5 ||Act5 ||StatusId5||InstanceId

Row Values:
138 || 60 || 1 || Obs1 ||Desc1 ||Act1 ||0 ||2 ||Obs2 ||Desc2||Act2 ||1 ||3 ||Obs3||Desc3 ||Act3 ||2 ||4||Obs4||Desc4 ||Act4 ||0 ||5 ||Obs5 ||Desc5 ||Act5 ||1 ||14

View 6 Replies View Related

Inserting Symbols In Field

Jul 29, 2007

Hi All,I am trying to insert symbols in a field of a table. I am using the datatype nvarchar for the field.However when i tried to insert a statement with the symbol pi, it comes out as following:(A) 100? cm2    (B) 140? cm2    (C) 200? cm2All the pi symbol are converted to ?.Can ne 1 tell me how i can store such strings in the field.Thanks

View 1 Replies View Related

Symbols In Stored Procedure

Dec 14, 2005

I am creating a Project schedule using a stored procedure. The character is currently set to '>'. I would like to replace this with the 'black square', character code '25A0'. Is this possible?
Here's part of my code:
QBar = CASE WHEN EstStartDate >= @ZFromDate AND EstDeliveryDate <= @ZToDate
THEN Replicate(' ',Datediff(day,@ZFromDate,EstStartDate)) + Replicate('>',Datediff(day,EstStartDate,EstDeliveryDate) + 1)

(Running Access 2002 frontend)

View 2 Replies View Related

Using Pipe Like Symbols To Add Parentheses??

Nov 20, 2007

Hi all,

I was told recently that doing the following:

SELECT ProductName ||' , '|| Category FROM PRODUCTS

would add parentheses around the ProductName field data. However, after trying it out for myself I found it did no such thing.

Does this look familiar to anyone? Is it syntax I have wrong or something?

Butterfly82

View 13 Replies View Related

Inserting Symbols In Field

Jul 30, 2007

Hi All,
I am trying to insert symbols in a field of a table.

I am using the datatype nvarchar for the field.
However when i tried to insert a statement with the symbol pi, it comes out as following:
(A) 100? cm2 (B) 140? cm2 (C) 200? cm2

All the pi symbol are converted to ?.

Can ne 1 tell me how i can store such strings in the field.

Thanks

View 3 Replies View Related

Where Are Debug Symbols For Sqlceqp30?

Mar 7, 2007

Here's the output when I type .reload in windbg (minus warning messages):

20:266> .reload

DBGHELP: C:Program FilesMicrosoft Visual Studio 8SmartDevicesSDKSQL ServerMobilev3.0wce500armv4isqlceqp30.dll - OK
DBGENG:  C:Program FilesMicrosoft Visual Studio 8SmartDevicesSDKSQL ServerMobilev3.0wce500armv4isqlceqp30.dll - Mapped image memory
SYMSRV:  C:SDKsMS_SymbolFilessqlceqp30.pdb79F8C010CB11435E99474335288548601sqlceqp30.pdb not found
SYMSRV:  C:SDKsMS_SymbolFilessqlceqp30.pdb79F8C010CB11435E99474335288548601sqlceqp30.pdb not found
SYMSRV:  http://msdl.microsoft.com/download/symbols/sqlceqp30.pdb/79F8C010CB11435E99474335288548601/sqlceqp30.pdb not found
DBGHELP: sqlceqp30.pdb - file not found
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for sqlceqp30.dll -
DBGHELP: sqlceqp30 - export symbols

Why can't it find the .pdb file on the symbol server and where else should I look?

View 1 Replies View Related

DB Design :: Using Symbols In Primary Key

Jul 25, 2015

I started to working on a project. I dont have a lot experiences except basic information. I just want to ask can I use symbols in primary key column like 2015/1234 etc. for file numbers. These are file numbers and must be unique so i decided to make them primary keys but im not sure that i can use symbols.

View 2 Replies View Related

Inserting Symbols Into Fields (like â„¢)

Jan 18, 2007

I am attempting to insert a trademark symbol„¢ into a database field but it is not working. Does anyone have any ideas on how to do this properly?

Any help would be very appreciated.

View 4 Replies View Related

Importing Null Values Getting Symbols

Dec 11, 2007

I am importing csv files into sql 2000 using odbcbcp and am getting the '' symbols when there are null values. Has anyone ever seen this? Or know how I can prevent this from happening? I am required to use odbcbcp to import this data.

View 5 Replies View Related

How Do I Add Symbols Like A Bullet To A Report(urgent)

May 18, 2007

Hi,



Is there a way i can add a symbol like a bullet a (wingding font) to my report in addition to other text in a text box.



any help will be appreciated.



Regards,

Karen

View 4 Replies View Related







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