Text (or Ntext) Concatenation

Apr 4, 2004

i want to concatenate 2 columns of type text

what am trying to do is adding an instead of trigger on update which concatenates the old value in the text column with the new value

so the problem is how i can concatenate both values since i cant declare a variable of type text.

A solution may be dividing the text column into many varchar(8000) variables and then add them but i dont know how it can be implemented or if there's an easier solution

the code am trying:

CREATE TRIGGER InsteadTrigger on tbl
INSTEAD OF Update
AS
BEGIN

if exists(select null from deleted)
begin
--am considering updating only 1 row
update tbl set theValue=((select theValue from deleted)+(select theValue from inserted))
end



i tried the writetext and updatetext functions and the problem is always related to both columns concatenation


Any solution?

thx
samham

View 3 Replies


ADVERTISEMENT

Managing Ntext, Text With A Long Text Data

Aug 25, 2005

Hi,I have a problem to insert(update) a long text (more than 64K) intoSQL 2000 (datatype - 'text'). It cuts the data and insert only 64K.MSDN says: "When the ntext, text, and image data values get larger,however, they must be handled on a block-by-block basis. BothTransact-SQL and the database APIs contain functions that allow applications towork with ntext, text, and image data block by block." Could somebodygive me an example how to do this, please.Thank you

View 2 Replies View Related

Concatenation Of Text

Feb 24, 2005

I have an instance where I need to concatenate some data that is stored in a text datatype. I can't cast it to a varchar/char because that may well truncate the data. I just read about UPDATETEXT, which I think I can use, but I need to use it for a bunch or rows and it looks like this works on one row at a time. Anyone have experience with this?

View 7 Replies View Related

Concatenation Of Numeric Text

May 12, 2008

How do I concatenate two numeric text values to return a string?

For examples Concatenate '03' and '2008' to '032008'?

Both values are char data type

thanks!

View 1 Replies View Related

Concatenation Of Integer Data Into Text

Jun 9, 2006

I am a TSQL Newbie trying to concatenate two columns (DocumentNo & SequenceNo) that were created with a €œsmallint€? data type constraint in a full-text search database. I want to end up with a column containing varchar data such as €œ5-2€? where this row of data contains information about the 2nd document in a series for a person or group designated as 5.

If I could change the data type for the columns to varchar I think I could query them like this:

SELECT ("DocumentNo" + '-' + "SequenceNo") AS DocumentNoFull
FROM Full_Documents
ORDER BY DocumentNo, SequenceNo

When I try to concatenate with this query the result is a mathematical addition of the numbers, not what I am trying to achieve (which is to combine the two numbers to produce a text string).

Due to the full-text search parameters for the database I have not been able to modify the data type constraints on the two relevant columns. Is there a way to concatenate the two €œsmallint€? columns and create a new column with text data (e.g., 5-2) for each row in the table?

My research suggests that €œcasting€? could be used to convert between data types, but I have not been able to figure out how to apply it to my situation. Any help would be appreciated.

View 10 Replies View Related

Ntext And Text In MSSQL 7.0

Mar 25, 1999

Hello everybody,

When I attempt to return a ntext or text field from a recordset to a client I receive the following error:

Microsoft OLE DB Provider for ODBC Drivers error '80020009'

Why won't ASP permit me to render this field.

Sincerely,

Arthur Lambiris

View 1 Replies View Related

Text And Ntext Fields

Jul 23, 2005

I've just gotten my data into SQL Server, and changed the connection stringon the program.There was a memo field (Access 2000) and we put that in a text field (with adefault length of 16?).Now, when displaying the data online (through asp pages), there are bigwhite-space gaps in the pages (that display the memo field data), imageshave a "double" url(http://www.mysite.com/thisfolder/ht...thelinksite.com)there are lots of place with " ".The field data has html tags in it, if that has anything to do with it.It seems like I've heard that there are issues with text fields. Is thiswhat they meant? Is there anything I can do?Thanks, JA

View 4 Replies View Related

Converting Text Dat To Ntext Data

Mar 26, 2006

Hi all,

My organization have a web-based application and needs it to support multilingual so we will be adapting our app to use unicode. However, one of our problems is to convert existing data from text to ntext. I couldn't find anything that document this. What is the best way to do that? I would like to be able to migrate the data from an existing text column to another ntext column in the table.

If I can't do that, what are the options? If it's possible, I would like to be able to do this in sql script.


Thanks a mil, in advance.

Eddie

View 2 Replies View Related

Ntext && Text Storage - How Do These Work?

Nov 28, 2004

Howdy,


Can some one please explain how the storage of a huge text or ntext object ( say a string of characters 100 KB in size ) is carried out please?

With a data page maximum size of 8000 bytes, how does SQL handle the storage of such an string - it would obviously obverlap multiple rows etc.
Does the application writing it to the database have to split the object over multiple rows and manually keep track of which bit is in which row so it can be re-created later in correct sequence by adding the bits back together, or is it done some how differently?

Any help most welcome as this is a bit confusing.

Cheers,

SG.

View 2 Replies View Related

Field Too Small; Cannot Use Text Or NText; Ugh, Little Help.

Sep 9, 2006

My Stored Proc runs through a loop and concats the contents of each field into one big nvarchar. Procedure works fine on a smaller scale but now it is being implemented on a very large table and the results of the sequel overflow the nvarchar limits. I looked into using text and ntext but both cannot be declared locally. Does anyone know how I can work aroudn this limitation?

Summary:The problem is that the temporary variable I am using (nvarchar) is too small to contain the robust size that the SQL is concating into it. The final field it winds up in is a text field and will be able to handle the amount of data, its just getting the data there is the issue..... Your thoughts please....

View 7 Replies View Related

SPROC Cannot Pass Text Or Ntext

Apr 2, 2004

Hi there! I've read through several of these forums and am impressed by the talent out there. I'm hoping someone could share some insight on a little complication I've got.

I have a sproc that essentially is pulling all mail items from a profile, reading them in and storing them in a table. It is all working fine MINUS the fact that I cannot pass the message because it won't allow me to pass text or ntext.

If anyone has any ideas I would truly appreciate it. In the meantime I'll be searching through the forum looking for a way to make it happen.
Thx, Camey

Here's my code:

CREATE PROCEDURE USP_News_GETmail
AS

declare @status int
declare @msg_id varchar(64)
declare @originator varchar(255)
declare @cc_list varchar(255)
declare @msgsubject varchar(255)
declare @msgtext varchar(255)
declare @messages int
declare @resultmsg varchar(80)
declare @filename varchar(12)
declare @current_msg varchar(64)

declare @post_id int
declare@topic_id int
declare@forum_id int
declare@poster_id int
declare@post_time int
declare@poster_ip int
declare@post_username char(25)
declare@enable_bbcode smallint
declare@enable_html smallint
declare@enable_smilies smallint
declare@enable_sig smallint
declare@post_edit_time int
declare@post_edit_count smallint
declare@bbcode_uid char(10)
declare@post_subject char(60)
declare@post_text text

Set @msg_id = NULL
while (1=1)
begin
exec master..xp_findnextmsg @msg_id = @msg_id output
if @msg_id is null break

exec @status = master.dbo.xp_readmail
@msg_id,
@originator=@originator output,
@cc_list=@cc_list output,
@subject=@msgsubject output,
@message=@msgtext output

select @topic_id= 2000,
@forum_id = 1,
@poster_id= 3,
@post_time= Convert(int,getdate()),
@poster_ip= 1000196,
@post_username= 'yahoo-alibre',
@enable_bbcode= 1,
@enable_html= 0,
@enable_smilies= 0,
@enable_sig= 0,
@post_edit_time= NULL,
@post_edit_count= 0,
@bbcode_uid= NULL,
@post_subject= @msgsubject,
@post_text= @msgtext




SET IDENTITY_INSERT phpbb_test_posts ON

DECLARE @num int
SELECT @num=max(post_id)
FROM phpbb_test_posts
SELECT @num = @num + 1

INSERT INTO phpbb_test_posts (post_id,topic_id,forum_id,poster_id,post_time,pos ter_ip,post_username,enable_bbcode,enable_html,ena ble_smilies,enable_sig,post_edit_time,post_edit_co unt)
VALUES (@num,@topic_id,@forum_id,@poster_id,@post_time,@p oster_ip,@post_username,@enable_bbcode,@enable_htm l,@enable_smilies,@enable_sig,@post_edit_time,@pos t_edit_count)


INSERT INTO phpbb_test_posts_text (post_id,bbcode_uid,post_subject,post_text)
VALUES (@num,@bbcode_uid,@post_subject,@post_text)

exec master..xp_deletemail @msg_id


end
GO

View 4 Replies View Related

NText Column Text Encoding/decoding

Sep 19, 2007

Hi,

I have a table column type as nText, however there are some Chinese character stored in that field and it is a messed up as it is not readable.

In my vb.net code, I did Convert to unicode by getting the byte of each character and encode it with UTF8 e.g:


Public Shared Function ConvertToUnicode(ByVal s As String) As String


' Convert To Unicode

Dim MyBytes As Byte() = Encoding.Default.GetBytes(s)

Dim GBencoding As Encoding = System.Text.UTF8Encoding.UTF8

Return GBencoding.GetString(MyBytes)

End Function


This works well but ,the problem is that it slows down the process quite alot, and I wonder are there any text encoding method I can use in SQL that can run when i do the SELECT Statement?


SELECT
Convert(MyNTEXTColumn)
....
something like that?

Thanks.
Jon

View 4 Replies View Related

How To Handle Text, Ntext Data Types Of SQL Server

Jan 8, 2004

i have created asp.net page, one feild of this page text area.
when i insert some text through this page in "text feild" of SQL server on few words of this feild cut and inserted to text feild of SQL server but all text that i have written in text area feild.

can u please help me how to handle so that i can all text in text feild of SQL server data type text/next.

View 2 Replies View Related

Text, Ntext, Or Image Node Does Not Exist Error

Apr 17, 2006

Hai Friends...

I am using sql server 2000. i have one table with columns

empid notnull
empfname not null
empmname null
emplname not null

while i am writing a simple procedure to get the employee middel name(empmname) it is giving the error message like this


Server: Msg 7105, Level 22, State 6, Procedure emp_statistics, Line 11
Page (1:70), slot 18 for text, ntext, or image node does not exist.

Connection Broken



plase help me Urgent

Thanks and Regards

Krishna Mangamuri

View 8 Replies View Related

Replicate Ntext Text Image In Transaction Replication

May 16, 2007

Hi!

i have a problem with my replication.

I have two SQL 2005 SP2 Server and want to use the transaction replication with updateable subscriber. Now the problem is that i can do any changes on the master server. But if i want to change a record on the subscriber which contains a ntext, text, oder image column - then i geht the error that the field will be NULL on the master.



Is there any solution to fix this problem? I dont wan`t to change the datatype vom ntext to varchar(max) !!



greetings

Holger

View 3 Replies View Related

Manipulating Text,nText Data Types Filed In Tsql

Jul 12, 2006

I have to run a dynamic sql that i save in the database as a TEXT data type(due to a large size of the sql.) from a .NET app.  Now i have to run this sql from the stored proc that returns the results back to .net app. I am running this dynamic sql with sp_executesql like this..
EXEC sp_executesql @Statement,N'@param1 varchar(3),@param2 varchar(1)',@param1,@param2,GO
As i can't declare text,ntext etc variables in T-Sql(stored proc), so i am using this method in pulling the text type field "Statement".
DECLARE @Statement varbinary(16)SELECT @Statement = TEXTPTR(Statement)FROM table1 READTEXT table1.statement @Statement 0 16566
So far so good, the issue is how to convert @Statment varbinary to nText to get it passed in sp_executesql.
Note:- i can't use Exec to run the dynamic sql becuase i need to pass the params from the .net app and Exec proc doesn't take param from the stored proc from where it is called.
I would appreciate if any body respond to this.
 
 
 

View 2 Replies View Related

SQL ERROR - I Need DISTINCT But Can Use It With Image,ntext, Text - How To Work Aroud???

Oct 10, 2006

SQL ERROR - I need DISTINCT but can use it with image,ntext, text - How To work around???  ! more - How to Work around - MIN() I cant use it when having text in SELECT statement  The text, ntext, or image data type cannot be selected as DISTINCT.



Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: The text, ntext, or image data type cannot be selected as DISTINCT.

Source Error:





An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below. 

View 2 Replies View Related

Converting CHAR/VARCHAR/TEXT Into NCHAR/NVARCHAR/NTEXT!!!

Jan 28, 2005

Hi,
We are in process of converting all of the data type of the fields from CHAR/VARCHAR/TEXT into NCHAR/NVARCHAR/NTEXT (DBCS). Having more than 900 store procedure its look like real pain to make modification in all of the SPs.

After failed to find any help from GOOGLE, I am posting this request. I am basically looking for any automated tool which are convert data type in SP based on the field of the table used in the SP. Or at least which can provide me some sort of list which can helpful for doing manual reactoring.

PLEASE HELP ME!!!

Thanks,

Firoz Ansari

View 2 Replies View Related

Using Inserted / Deleted Tables With Text / NText / Image Data Type

Oct 6, 2004

Hi folks,

Table:

a int,
b int,
c int,
d text

I need to change my AFTER - Trigger from this (example!):

select * into #ins from inserted

to something like

select *(without Text / nText / image -columns) into #ins from inserted.

So I tried to build a string like this: (using INFORMATIONSCHEMES)

select @sql = 'select a,b,c into #ins from inserted'
exec(@sql)

a,b,c are not of Text, nText or Image datatype.

After executing the trigger, I get an error, that inserted is unknown.

Does anyone know how to solve this ?

Thx.

View 5 Replies View Related

Page (1:404399), Slot 5 For Text, Ntext, Or Image Node Does Not Exist.

Apr 7, 2008

I wonder if anyone can help.

I do not understand the error message but I do know it is associated with a specific table and one of its indexes. If I try to drop the index that is the error message I get.

I have copied the data from the table to a new table and rebuilt the indexes on the new table and everything is working fine.

The bad table is now renamed to myTable_BAD. I now want to delete it but can't as everytime I enter
drop table myTable_BAD

I get Page (1:404399), slot 5 for text, ntext, or image node does not exist.

So here is my question

How can I delete this Bad table?

View 9 Replies View Related

SQL Server 2005 - Transactional Replication Involving Depricated Text And Ntext Data Types

Dec 2, 2005

I'm currently trying out transactional replication with updatable subscriptions across two 2005 servers.

View 3 Replies View Related

Function That Replaces Ntext And Compares Ntext With Nvarchar

Nov 28, 2007

I am running this query to an sql server 2000 database from my aspcode:"select * from MyTable whereMySqlServerRemoveStressFunction(MyNtextColumn) = '" &MyAdoRemoveStressFunction(MyString) & "'"The problem is that the replace function doesn't work with the ntextdatatype (so as to replace the stresses with an empty string). I hadto implement the MySqlServerRemoveStressFunction, i.e. a function thattakes a column name as a parameter and returns the text contained inthis column having replaced some letters of the text (the letters withstress). Unfortunately, I could not do that because user-definedfunctions cannot return a value of ntext.So I have the following idea:"select * from MyTable whereCheckIfTheyAreEqualIngoringTheStesses(MyNtextColum n, '" & MyString &"')"How can I implement the CheckIfTheyAreEqualIngoringTheStessesfunction? (I don't know how to combine these functions to do what Iwant: TEXTPTR, UPDATETEXT, WRITETEXT, READTEXT)

View 2 Replies View Related

Converting Text Data To Ntext Data

Mar 27, 2006

Hi all,

My organization have a web-based application and needs it to support multilingual so we will be adapting our app to use unicode. However, one of our problems is to convert existing data from text to ntext. I couldn't find anything that document this. What is the best way to do that? I would like to be able to migrate the data from an existing text column to another ntext column in the table.


I brief you about my system, I used List manager system to store the messages and distribute to all members. Right now,by design the Lyris system keep the message in the text field which mean it 's not support multilanguage directly because of unicode field. We needs to create new Db which has the data structure as same as Lyris but just one difference is keep the message in unicode format (ntext) which we need the sql script to automatically update the new record get from Lyris to new DB.


If I can't do that, what are the options? If it's possible, I would like to be able to do this in sql script.


Thanks a mil, in advance.

Eddie

View 2 Replies View Related

Concatenation

Jun 12, 2008

I need to concatenate two date fields so they appear in a drop-down list like this:   8:00 AM - 10:00 AM
I'm using MS SQL 2005 and my query looks like this:  SELECT ClinicTimesID, ClinicID, (CTStartTime + ' - ' + CTEndTime) AS TimeSlot FROM Clinics_Times WHERE (ClinicID = 1) and I get this error:  Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Can I strip out the date so that only the time appears or is it even possible to concatenate these fields?  If so, how?
Thanks!

View 1 Replies View Related

Concatenation

Sep 8, 2005

Hello all, I'm trying to combine two columns of data into a third column using a formula on the thrid column. Each of the columns could contain nulls and each of the columns could contain padding after or before the data. I'm trying to use the following formula yet SQL is throwing an error. Can someone provide another set of eyes to check this out? ISNULL(LTRIM(RTRIM([user_Define_4a])),’’) + ISNULL(LTRIM(RTRIM([user_Define_1])),’’) Thanks

View 2 Replies View Related

DTS Concatenation - Please Help

Nov 17, 1999

I am importing via DTS a .csv file. I have 2 issues:

-One field from the source needs to be inserted into two existing fields.

-Two fields from the source, First_Name and Last_Name need to be
concatenated to a destination field, Full_Name.

I do not know VB but I do know SQL.

Can anyone help?

View 1 Replies View Related

Concatenation

Mar 7, 2007

Hi. I want to make a query that concatenate the address of the person with a comma inbetween and neglecting the null value.

table - pspersonaldata
dcno name streetbldg1 streetbldg2 streetbldg3
1 jon santol1 null santol3
2 mike mangga1 mangga2 null
3 jay langka1 langka2 langka3
4 joy null buko2 buko3
5 jean null null null

expected output is:

name address
jon santol1, santol3
mike mangga1, mangga2
jay langka1, langka2, langka3
joy buko2, buko3
jean null

thanks.
-Ron-

View 14 Replies View Related

Concatenation

Oct 3, 2007

I am completely new to SQL and I have some syntax questions. I am trying to concatenate 4 fields and some padded constants to form a new key field to perform joins. The result should be a twelve character field without spaces. My problem is that the current fields use spaces as place holders and I need to replace the spaces with β€˜0’.

[RD_ID] nvarchar length 5
[RDWY_ID] nvarchar length 1
[MLGE_TYPE] nvarchar length 1
[OVLAP_MLGE_CD] nvarchar length 1

Concatenate 12 characters

1st β€˜0’ (constant)
2nd, 3rd, and 4th, from [RD_ID] (without the suffix)
5th and 6th from [RD_ID] suffix or replace spaces with β€˜00’
7th 1 or 2 from [RDWY_ID]
8th Z from [MLGE_TYPE] or replace space with β€˜0’
9th 1 – 9 from [OVLAP_MLGE_CD] or replace space with β€˜0’
10th β€˜S’ (constant)
11th β€˜0’ (constant)
12th β€˜0’ (constant)

Results should resemble
0001CQ100S00 or 000100100S00

This is the query I used in Access.

LRS: "0" & IIf((Len(LTrim(RTrim([HITIS2_TVCLEAR2]![RD_ID])))=3),LTrim(RTrim([HITIS2_TVCLEAR2]![RD_ID])) & "00",LTrim(RTrim([HITIS2_TVCLEAR2]![RD_ID]))) & [HITIS2_TVCLEAR2]![DIR_RDWY_ID] & IIf([HITIS2_TVCLEAR2]![MLGE_TYPE]=" ",0,[HITIS2_TVCLEAR2]![MLGE_TYPE]) & IIf([HITIS2_TVCLEAR2]![OVLAP_MLGE_CD]=" ",0,[HITIS2_TVCLEAR2]![OVLAP_MLGE_CD]) & "S00"

Thanks for any help.

View 6 Replies View Related

Concatenation

Feb 27, 2008



My file is in this format

Col1 Col2 Col3
---------------------------------------------------------------------------
Andrews S 93845877712 P
Sylvia 9999876669 J
Bill K 7657654677 L

I need the output like this
Col1 Col2 Col3
--------------------------------------------------------------------------
AndrewsS 93845877712 P
Sylvia 99999876669 J
BillK 76576546677 L

The character on the left of Col2 has to be joined to Col1 and character on the right of col2 has to be joined to Col3. Can anybody suggest a query for this.

Thanks,

View 3 Replies View Related

Concatenation

Apr 8, 2008



I need to concatenate the strings of the grouped result set in my report. Lets say if I have

ID Text
-----------------
1 text1
1 text2
1 text3


and if I am grouping by ID, the resulted text should be "text, text2, text3". Any ideas on this? Its kind of emergency

Thanks
Dinesh

View 5 Replies View Related

Dynamic SQL - Concatenation!

May 1, 2008

Hi All,
I've been trying to create a dynamic query using the 'Like' clause and '%'.
my code snippet looks like this:
while (@@FETCH_STATUS = 0)begin   set @likeString = @likeString + ' item_Text LIKE ''%'+@word+'%'' OR '   fetch next from theLike   into @word end
 
-- strip off last ORset @likeString = ltrim(rtrim(substring(@likeString, 0, (len(@likeString) - 3))))-- ================================================-- create query to find keywords in the index and store in temp table-- ================================================set @query = 'INSERT into #resulttable (itemcount, item_id) SELECT COUNT(d.item_id), d.item_id FROM tp_index_details AS d INNER JOIN tp_index ON d.idx_id = tp_index.idx_id 'set @query = @query +' WHERE (d.idx_id IN (SELECT idx_id FROM tp_index AS i WHERE ( 'set @query = rtrim(@query) + @likeStringset @query = @query + ' ) AND (subscription_id = 1000))) GROUP BY d.item_id ORDER BY d.item_id DESC'
The problem is the @query string gets truncated. My question is how to get the quotes around '%' variables to work in a string?
Thanks for any help!
regards
Davej

View 4 Replies View Related

SQL And Proper Concatenation Within VB

Jun 9, 2008

Hi all - I have posted inquiries on this rather vexing issue before, so I apologize in advance for revisting this. I am trying to create the code to add the parameters for two CheckBoxLists together. One CheckBoxList allows users to choose a group of Customers by Area Code, the other "CBL" allows users to select Customers by a type of Category that these Customers are grouped into. When a user selects Customers via one or the other CBL, I have no problems. If, however, the user wants to get all the Customers from one or more Area Codes who ALSO may or may not be members of one or more Categories; I have had trouble trying to create the proper SQL. What I have so far:Protected Sub btn_CustomerSearchCombined_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_CustomerSearchCombined.Click        Dim CSC_SqlString As String = "SELECT Customers.CustomerID, Customers.CustomerName, Customers.CategoryID, Customers.EstHours, Customers.Locality, Category.Category FROM Customers INNER JOIN Category ON Customers.CategoryID = Category.CategoryID WHERE "        Dim ACItem As ListItem        Dim CATItem As ListItem        For Each ACItem In cbl_CustomersearchAREA.Items            If ACItem.Selected Then                CSC_SqlString &= "Customers.AreaCodeID = '" & ACItem.Value & "' OR "            End If        Next        CSC_SqlString &= "' AND " <-- this is the heart of my problem, I believe        For Each CATItem In cbl_CustomersearchCAT.Items            If CATItem.Selected Then                CSC_SqlString &= "Customers.CategoryID = '" & CATItem.Value & "' OR "            End If        Next        CSC_SqlString = Left(CSC_SqlString, Len(CSC_SqlString) - 4)        CSC_SqlString &= "ORDER By Categories.Category"        sql_CustomersearchGrid.SelectCommand = CSC_SqlString    End SubAny help on this is much appreciated, many thanks -- 

View 5 Replies View Related

Problem With Concatenation In SP

Sep 10, 2004

Hi,
I'm trying to mak emy query dynamic such that depending upon certain conditions, the conditions in the WHERE clause change. I have my SP as shown below and it doesn't seem to work correctly this way and seems like it is not even taking it as a condition. Please advise on what is going wrong here. I'm building the @Condition variable dynamically and appending it to the where clause below. Any help wud be greatly appreciated.

Thanks


CREATE PROCEDURE dbo.CabsSchedule_ViewSchedule
(
@SiteCode smallint = 0,
@YearMonth int = NULL,
@ByYearMonth bit = 1
)
AS

DECLARE @tempYearMonth int
DECLARE @Condition varchar(1000)
SET @tempYearMonth = 0

IF @YearMonth IS NULL OR @YearMonth = 0
BEGIN
EXECUTE CabsSchedule_GetYearMonth @tempYearMonth, @YearMonth OUTPUT
END

IF @ByYearMonth = 0
BEGIN
DECLARE @Year int
DECLARE @Month int
SET @Year = CAST(SUBSTRING(CAST(@YearMonth AS VARCHAR(6)),1,4) AS INT)
SET @Month = CAST(SUBSTRING(CAST(@YearMonth AS VARCHAR(6)),5,2) AS INT)
SET @Condition = ' DATEPART ([month], FullDate) = ' + CAST(@Month AS VARCHAR(2)) + ' AND DATEPART ([year], FullDate) = ' + CAST(@Year AS VARCHAR(4)) + ' AND '
END
ELSE
BEGIN
SET @Condition = ' YearMonth = ' + CAST(@YearMonth AS VARCHAR(6)) + ' AND '
END

SELECT BillPeriod =
CASE
WHEN BillPeriod = 32 THEN 'NB'
WHEN BillPeriod = 33 THEN 'Holiday'
ELSE Convert(nVarChar(7), BillPeriod)
END,
WorkDay =
CASE
WHEN WorkDay = -1 THEN ''
WHEN WorkDay = 0 THEN 'Holiday'
ELSE Convert(nVarchar(7), WorkDay)
END,
JulianDate, CalendarDay, CalDayBillRcvd, Remarks, FullDate
FROMdbo.CabsSchedule
WHERE YearMonth = @YearMonth AND SiteCode = @SiteCode
GO

View 7 Replies View Related







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