Checking Contents Of Column And Replacing Contents If First Character Is A Letter

Jun 25, 2007

Hi All,
I have come up against a wall which i cannot get over.
I have an sql db where the date column is set as a varchar (i know, should have used datetime but this was done before my time and i've got to work with what is there). The majority of values are in the format dd/mm/yyyy. However, some values contain the word 'various'.
I'm attempting to compare the date chosen on a c# .net page with the values in the db and also return all the 'various' values as well.
I have accomplished casting the varchar to a datetime and then comparing to the selected date on the .net page. However, it errors when it comes across the 'various' entrant.
Is there anyway to carry out a select statement comparing the start_date values in the db to the selected date on the .net page and also pull out all 'various' entrants at the same time without it erroring? i thought about replacing the 'various' to a date like '01/01/2010' so it doesn't stumble over the none recognised format, but am unsure of how to do it.

This is how far i have got: casting the varchar column to datetime and comparing.  
SELECT * FROM table1 WHERE Cast(SUBSTRING(Start_Date,4,2) + '/' + SUBSTRING(Start_Date,1,2) + '/' +SUBSTRING(Start_Date,7,4) as datetime)  '" + date + "'"
Many thanks in advance!

 

View 7 Replies


ADVERTISEMENT

Updating /replacing Contents Of The Table

Jun 11, 2007

Is it possible to do an update * where in we update all the contents of the table after selecting specific rows of the same table.

for ex:

create table #Result(rowid int identity(1,1),cust_no int,companyname varchar(100),address varchar(200),zip varchar(9));

insert into #Result(cust_no,companyname,address,zip)
where (customertype='r' and customer.comp_id ='11')
group by customer.cust_no, customer.company


select * from #Result where customerstatus='s';

after this i want to update/replace the #Result with whatever results I have from the select statment.

Thanks for your replies.

View 5 Replies View Related

T-SQL (SS2K8) :: Replacing String Values With Contents Of Variable

Dec 19, 2014

So I have the following column named String in a table:

<key>Children</key><integer>2</integer>

This of course can vary for the different records. What's the best way to replace the 2 with the contents of my variable with TSQL?

declare @children int
set @children = 4

I want to do something like this:

SELECT <key>Children</key><integer>@children</integer>

View 4 Replies View Related

Added Space Character On The Header/Footer Contents Of An Exported Report In Excel

May 21, 2008

A space was added as the first character of the contents in the Left, Center and Right section of the Report Header and Footer exported to Excel. Example :

In the RDL, Header values are:

Left = "Product Report" ; Center = "Confidential" ; Right = "Page n of n"

In the exported report to Excel, Header properties (-->File.-->Page Setup--> Header/Footer Tab) are:

Left = " Product Report" ; Center = " Confidential" ; Right = " Page n of n"

Is there a way to eliminate that space character?


Thanks in advance.

View 8 Replies View Related

Replacing First Letter Only In Column

May 17, 2006

Hello. We have a list of 1000+ sku numbers. 90% of them start with u. I need to replace the u with T.

Concerns:
It has to only replace the first letter, if there are other "u"s in the sku, they need to remain.
Not all skus start with u, those that don't should remain the same.

I have searched and searched because I'm sure someone has requested the exact same thing but I can't find anything that is identical.

I have this so far but I know its not correct:
set sku = replace(left(sku,1),'u',right(rtrim(sku),1)+
'T')

Can someone help lead me down the right path?

Thanks in advance!!!

View 4 Replies View Related

Right Justify Contents Of A Column

Aug 17, 2007

I am new to SQl and need to create a numeric field (15,2) that is right justified. Any help would be greatly appreciated.

View 2 Replies View Related

How To See Contents Of Image Column

Jul 20, 2005

Hello,In my MS SQL SERVER database i have an column with datatype image. Somerecords do have data in this column, some others don't. When i look at thistable in Enterprise Manager then i see in every field '<image>' so no way tosee directly wheter a filed has data or not. Is there a way to changedisplay of this column so i can see the binairy data in it?Marcel

View 1 Replies View Related

Printing Column Contents Vertically

Jun 15, 2007

Hi All,

I would like to print a report that is 64x64 matrix. I want the columns to be narrow and the headings for the columns to be vertical like is possible in excel. The text for the heading fields also comes from a stored procedure.



I have hunted and pecked around but I cannot seem to find an option that sets the orientation of the text for a text box to vertical.



Is there one?



If not, does anyone have a suggestion as to how I can make these column headings vertical and nicely fomatted all the time? Again, looking for the same effect as in excel.



Thanks

View 4 Replies View Related

SQL 2012 :: Matching Column IDs Based On Field Contents

Apr 2, 2015

I have tables in my database, tblNames1, tblNames2, tblNames3, and a main addresses table (currently empty). Once I've imported the address data I need to match the addressIDs in the names tables to the Primary ID in the address table based on the values of a field CompanyName (which is common to all the tables) My issue is that I have a huge CSV file with the master address information but obviously SQL server needs to assign foreign keys so the names tables can linked to corresponding rows in address table. It's a a many to 1 relationship as their will be one address with multiple name entries. All the names are normalized so everything can be matched up...

View 9 Replies View Related

Contents Of The Tran Log

Oct 11, 1999

All,

Can everyone tell me how I can view the contents of a transaction log in SQL Server 7.

Many Thanks
Mathew hayward

View 3 Replies View Related

Get Contents Of Xml File

Jul 5, 2007

Is it possible is SSIS to get the contents of an xml file and pass it on to a stored procedure?
Thanks

View 1 Replies View Related

Copying A Database And All Contents

Mar 25, 2008

Can anyone advise me of a convenient way to make a copy of a database in SQL2005.  I need to make a complete copy - including all Stored procedures, functions tables and table contents.
I want the place the copy ont he sae SQL server but obviously under a different name.
 

View 1 Replies View Related

Need Help Splitting Contents Of A Field In T-Sql

May 22, 2006

I have a table with about 2 million records.
One of the fields has data seperated by a comma. I need to be able to grap the data for each record and split those items into their own table in seperate rows. This is easy in Asp but the page will timeout before it can process all the records.
Any Ideas?
Thanks,Rick

View 4 Replies View Related

Read The Contents Of CD..(urgent)

Apr 17, 2002

Hai.
Here i am sending my query.This is urgent to my job.Please give me solution as
early as possible in SQL server.

Thanks.
My query is..
Check for CD drive on your system.If drive available ,display the name of the CD and read the contents of the CD,and search for given file in CD.
I want search this on local machine and on remote system.

Thanks.

with regards.
laxma P.reddy

View 2 Replies View Related

Error.log Contents Interpetation

Dec 15, 1998

Where can I get a reference document that will help me troubleshoot and interpet the MS SQL Server ERROR.LOG file? Something that would
describe in detail what the error is and various actions I could take to correct the errors. JLS

View 1 Replies View Related

List The Folder Contents Using SQL

Jun 15, 2004

Hi all,
I have built a Disaster Recovery Site for my DB.on periodic basis, trn files from production server reach DR server and DR setup will apply them locally.

If the flow is smooth then no issues, if one of the file does not reach DR
the entire setup will halt for the want of the file and I dn't have any means to
know which file is missing.

Both my production and DR site located remotely behind firewalls, i.e i can't
physically access the servers or remotely login to the server.

Can anyone tell me how to see the contents in a folder in the server using
SQL query .

Any help is highly appreciated

Thanks and Regards
Srinivas Varanasi

View 4 Replies View Related

Masking Cell Contents

Oct 11, 2004

Is there a way to mask the contents of a cell or column? I have a table that stores passwords and I would like to mask the password much like Access does with asterisks. I know I can restrict the column based on user but that creates other problems on the frontend.

View 1 Replies View Related

Ordering Rows For Contents

Apr 1, 2008

I have a series of records, that are displayed as contents in a .NET application,i know i can order the items to be dynamic, i.e I set the top item in the contents,
However I know this will get quite messy at the application level.

I would like to set up the default if I insert an item, into the table to make it the last in the list, select max(ordernum) + 1, i guess?

How can I set an on insert constraint, or what its called for this in SQL Server?

View 5 Replies View Related

Copy Contents Of One Field To Another

Jan 3, 2008

I have a SQL table and a field called SpecReq. I want to copy the contents of SpecReq in each record to another field in the record called MeetTitle.

Can I do this with an update query or do I need to use Analyser ? Also what is the syntax please

View 2 Replies View Related

Merging Contents Of One Db To Another Huge Db.

Feb 15, 2007

I am storing data temporarily in a database... and periodically needto update that huge database, so just has to copy that temp DB to theoriginal one.Using sql may take a few hours to finish this operation. I think youcan do "export" from temp database into a file and "import" into thehuge database. That will be binary data exort and import and hencewill be faster. But, I am not sure if all databases will support thatthough.So, is there any other solution?

View 1 Replies View Related

Contents Of Image Fields

Jul 22, 2007

Hi,I have a SELECT FROM TABLE query and in that table there is a field of typeimage. Result of this select goes throug internet do its destination. But infact I need only to know if in this field is or not an image. Is there anyfunciotn which gives me information about contents of image fields?Regards, Paul

View 1 Replies View Related

How To Display Contents Of TempDB

Oct 20, 2015

SQL SERVER 2008 R2

TempDB in one of our servers is using too much memory. How to display the contents of TempDB?  

View 8 Replies View Related

Report Snapshot Contents

Feb 13, 2008



I have a report that has a snapshot enabled. I made some changes to my report and redeployed it, but when I view the report from the Report Manager web site the old version is getting used. Apparently the snapshot includes the rdl and the data and not just the data. Can anyone else confirm this? If this is the case, a new snapshot must be created after the report format is modified.

Dean

View 1 Replies View Related

Print Table Contents

Jul 19, 2006

Hello

I want to have a print of table records in sql server express.

I went several locations, but File|Print item didn't on.

How can i print table contents in sql express environment ?

Thank you for helping me.

View 3 Replies View Related

Getting Datasource And DSV Contents Programmatically

Jan 14, 2008



Hello to everyone.

I have two questions.
1) As you know it's possible to get information about models by using the schema rowsets in c#. I wondered that it is possible to get datasource and datasource views contents programmatically? And if you have some pieces of code please write here.

2) In the topic http://www.sqlserverdatamining.com/ssdm/Default.aspx?tabid=61&Id=6 it says that visio can help us to draw algorithms visual outputs. Could anyone send me or paste the links of screenshots of sucessful rendering.

3) i have an error in my sql server management studio. It gives an error message whenever i clicked on an of menu items in the left pane.(www.ahmetselman.com/error.jpg) in this url you can see my screenshot. Has anyone here, faced this problem? Why i got this error?

View 3 Replies View Related

Move A Table (and Its Contents!) To Another Database

Jan 23, 2007

 
Hi,
I am relatively new to this stuff.
I am using Microsoft SQL Server Management Studio Express  (9.00.1399.00)
Can someone tell me the way to get a table and its content to another database (I use two at webhosts4life)
Or perhaps a way to export the data of a table so I can do it at a later stage.
 
Is that at all possible with this program or do I have to use the non-express version?
 
Thanks in advance,
Lex
 

View 4 Replies View Related

Looping Thru A Table And Updating The Contents

Nov 8, 2007

Hello, Its hard trying to explain this.
I have 3 tables
Table 1 is where the users are stored, each user has a username and a userrank
Table 2 is where the points that decides the userrank are stored
Table 3 contains the available userranks like this
 
Table 1 (user_list) looks briefly like this:username nvarchar(20),userrank int, -- Reference to Table3 id... alot more fields
Table 2 (settings_profile) looks like this:username nvarchar(20),total_active_points int,... some more fields
Table 3 (data_ranks) looks like this:id int primary key auto inc,rankname nvarchar(20),min_pts int,max_pts int
 
Points get added to table 2 whenever they do something that generates points on the site. Points also get withdrawn every 7 days, so a user can only collect points for 7 days, on the 8th day, all points he earned on the 1st day is reduced from the current points with this code:
WHILE (SELECT @username = username, @id = id, @temp1 = ap_sentmails, @temp2 = ap_createdthreads, @temp3 = ap_createdanswers, @temp4 = ap_signguestbook, @temp5 = ap_blogcomment, @temp6 = ap_createblogentry, @temp7 = ap_profilefirsttime, @temp8 = ap_profilephoto, @temp9 = ap_activateguestbook, @temp10 = ap_addnewfriend, @temp11 = ap_superguruvote, @temp12 = ap_forumtopicvote, @temp13 = ap_labervote, @temp14 = ap_funstuffitemvote, @temp15 = ap_movievote, @temp16 = ap_actorvote, @temp17 = ap_money_new WHERE (created < Dateadd(dd, -7, @todaysdate))BEGINSET @sum = 0SET @sum = @temp1 + @temp2 + @temp3 + @temp4 + @temp5 + @temp6 + @temp7 + @temp8 + @temp9 + @temp10 + @temp11 + @temp12 + @temp13 + @temp14 + @temp15 + @temp16 + @temp17UPDATE settings_profile SET total_active_points = total_active_points - @sum WHERE (username = @username)DELETE FROM konto_daylist WHERE (id = @id)END
Now my question is this, i want to loop thru the table A, collect all usernames inside of it, then run it against table b and table c to determine the current rank of the user.Something like this...
DECLARE @username nvarchar(20)DECLARE @pts int, @rank int
...something that starts a loop thru table A (user_list) and get the username into @username...
SELECT @pts = total_active_points  FROM settings_profile WHERE (username = @username)-- Determine the rank here, by compairing the points the user have against the pointstabel in table data_ranksSELECT @rank = id FROM data_ranks WHERE (pts_min => @pts AND pts_max < @pts)UPDATE user_list SET rank = @rank WHERE (username = @username)
...next persion in the loop...
This SP runs once a day and will first reduce the points from 8days ago, then it will run thru all the users and determine their new rank...
But how do i loop thru all the users? with a cursor?

View 10 Replies View Related

How To Save Contents Of Text Box To Database?

May 6, 2006

Hi,
For some reason I can't use the edit, update or insert features on my remote shared server, so I am looking to create a web page that has text boxes on it, that I can enter data into, that will be saved into my database.
 
This is opposed to entering the data directly into the database itself. I want to be able to use a webpage, for simply adding new data, and saving it so that the new data updates and saves over the top of the old data.
What are the steps involved in doing this?
Any example code for just one text box would be appreciated, I could then extend it to suit my needs. Tia.

View 2 Replies View Related

Obtaining Detail Of DTS Package Contents

Dec 17, 2002

I have quite a few DTS's to work through while analysing current SQL databases for a client. Problem is I can't seem to find a way in SQL (Enterprise Manager) to print the contents of a DTS package. This is quite frustrating in that I have to go an "Design" the package, then click on the properties for each step and copy and paste the contents into Notepad/Wordpad. Surely Microsoft have something to ease the pain?

If anyone can help me on this one, I would be extremely grateful.

View 4 Replies View Related

Contents Sort 3 Levels Of Data

Dec 21, 2007

I Have a table of Data (WikiData)

WikiIDint
ParentIDint
sTitlevarchar(50)
sDescriptionvarchar(MAX)

There will be three levels of data imposed at the Application Layer

Level 1: ParentID = 0
An Item Like Geography
Level 2: ParentID = a Level 1 WikiID
A sub Topic like Volcanoes
Level 3: ParentID = Level 2 WikiID
A bottom Topic like Pyroclastic Flows

I Need a SQL statement that Will Produce the Output where The output will be produced like this:
Level 1
Level 2
Level 2
Level 2
Level 1
Level 2
Level 2

I Built this but its wrong and has no order by Group by Statements
Select * from WikiData where ParentID = 0 or ParentID IN (Select * from WikiData where ParentID = 0)

View 12 Replies View Related

[howto] View Contents Of Log File

Apr 7, 2004

How to view contents of log file?
i found sp_helplog
however

sp_helplog is no longer supported.

help please

View 1 Replies View Related

Issue With Missing Field Contents

Oct 5, 2007

Hi there,

I have a problem in SQL 2005, can someone help?
I happened to create a new field, lets say: sSubject with type: nvarchar(50), null.
then manually I go in and add this field with data and SAVE it.
For some reason, few days later the apps cannot work. And I went into DB and found out that the mentioned field contents has become "NULL". What is going there in DB?

Thanks....cheers

View 2 Replies View Related

Compile/combine The Contents Of Several Records.

Dec 5, 2005

I have the following table;CREATE TABLE [x_Note] ([x_NoteId] [int] IDENTITY (1, 1) NOT NULL ,[Note] [varchar] (7200) COLLATE SQL_Latin1_General_Pref_CP1_CI_AS NOTNULL ,CONSTRAINT [PK_x_NoteId] PRIMARY KEY CLUSTERED([x_NoteId],) WITH FILLFACTOR = 90 ON [USERDATA] ,) ON [USERDATA]GOMy clients want me to take the contents of the Note column for each rowand combine them. In other words, they basically want:Note = Note [accumulated from previous rows] + Char(13) [because theywant a carriage return] + Note [from current record].What is the most efficient and relatively painless way to do this? Ithink it might require a cursor, but I'm not sure if there is a moreelegant set-based method to make this happen.

View 14 Replies View Related







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