Wednesday, June 5, 2013

[T-SQL] check value in database

[T-SQL] check value in database


check value in database

Posted: 04 Jun 2013 04:47 PM PDT

Hi,I have a table in which I have stored some data from XML. Now I want to validate that data from database tables.Create table #temp( StoreCode int, TerminalId int, TransactionNo varchar(10), RequestDate date, RequestTime char(5), VoucherDetails varchar(10))StoreCode TerminalId TransactionNo RequestDate RequestTime VoucherDetails1234 2 0123456789 2013-03-05 11:30 VVD00000211234 2 0123456789 2013-03-05 11:30 VVD00000221234 2 0123456789 2013-03-05 11:30 BVD0003213There is a voucher table in my table where all these voucherno in voucherDetails exists. If the status of these vouchers are 'Store Active' or 'Not Expired' then I have to insert these information into another table.How can I achive this?

get part of the string in between square brackets

Posted: 04 Jun 2013 11:29 PM PDT

hii have the following string '[N] 18. Is the C.B. removed from the panel? [Yes / No]' and i need to return only this part18. Is the C.B. removed from the panel?please helpthanks in advance

How To get Characters after a string

Posted: 04 Jun 2013 11:39 PM PDT

Hi AllI need to select the document file extention but I'm not getting the same results if the fileName has more that one dot "."e.g C:\Documents and Settingskiewiedo001\Desktopatalie Cv.doc = doc --Which is the results I wantand C:\Documents and Settings\HRTemp001.ZADBNHRW1\Desktop\cv.doc = ZADBNHRW1\Desktop\cv.doc --starting after the first "."How do I get just the file extension using the query below?:Select CVFileName ,RIGHT(CVFileName, len(CVFileName) - charindex('.', CVFileName))From CandCVThanks.Teee

Counting Days with Reset

Posted: 04 Jun 2013 02:23 AM PDT

I have been struggling with this all morning, and I think I am missing something obvious. What I need to do is take a typical date dim table and count every 7 days as a 1 week, keeping the running count, but at week 52 it needs to start back at 1. This requirement does not match to the datepart function's weeks. I have tried several different ways, and I can get a count of weeks, which changes on the correct day, but I am stuck on getting the count to restart.Can anyone point me in the right direction?

Selecting XML Data

Posted: 04 Jun 2013 02:17 AM PDT

HiI'm trying to execute a script in SSMS using SQL Server 2008 R2, but it's returning the following error message:"Msg 9420, Level 16, State 1, Line 1XML parsing: line 1, character 3, illegal xml character".I suspect I need to set encoding to '<?xml version="1.0" encoding="iso-8859-1" ?>'. However, I don't know how to do this and I can't waste the rest of the day on it. Can anyone help please?The code is as follows:[code="sql"];WITH XMLNAMESPACES ( DEFAULT 'http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition', 'http://schemas.microsoft.com/SQLServer/reporting/reportdesigner' AS rd)SELECT name, x.value('CommandType[1]', 'VARCHAR(50)') AS CommandType, x.value('CommandText[1]','VARCHAR(50)') AS CommandTextFROM ( select name, CAST(CAST(content AS VARBINARY(MAX)) AS XML) AS reportXML from ReportServer.dbo.Catalog) aCROSS APPLY reportXML.nodes('/Report/DataSets/DataSet/Query') r(x)WHERE x.value('CommandType[1]', 'VARCHAR(MAX)') = 'StoredProcedure'[/code]Many thanks.C

creating procedure for Insertion?

Posted: 22 May 2013 05:15 PM PDT

Hai Friends , I m creating one web application in that input fileds are departuredate,from_place,To_place,travel mode.My condition for insertion when i choose to enter departuredate(input date) is always greater than already appeared date on database date.create table journey(departuredate datetime,from_place varchar(50),to_place varchar(50),travel mode nvarchar(50))insert into journey values ('20-05-2013','cdsfs','dhf','Train')insert into journey values ('21-05-2013','cds','dh','Car')insert into journey values ('22-05-2013','cfs','df','Bus')My procedurecode:create procedure jack(@departuredate datetime,@from_place varchar(50),@to_place varchar(50),@travelmode nvarchar(10))as begin if exists('select departuredate from journey where departuredate<@departuredate')print 'Must choose greater date of departuredate'endelsebegininsert into journey (departuredate,from_place,to_place,travel mode) values(@depaturedate,@from_place,@to_place ,@travelmode,)endend/these query shows exceuted successfully,but it was not woking any body suggest me

No comments:

Post a Comment

Search This Blog