I need to do an update to several tables that would update just a few characters w/in a string. So if the String is 1122334455 I would need to update just '1122' and replace with '0000' - leaving '0000224455'.
I've tried the update/replace functions and they're not working. How would I do this or would I just create a trigger?
I moved a database from one server to another, in this database are references to a UNC path on the server. now I need to find a way to modify the server name that was in each row to reflect the new server name and path, ex:
\server1path1data to now say \server2path2data
how do I selectivly modify just some of the data? or do I have to basically re-write the entire column for each row?
After converting from SSIS 2008 to SSIS 2012, I am facing major performance slowdown while loading fact data.When we used 2008 - one file used to take around 2 hours average and now after converting to 2012 - it took 17 hours to load one file. This is the current scenario: We load data into Staging and Select everything from Staging (28 million rows) and use a lookups for each dimension. I believe it is taking very long time due to one Dimension table which has (89 million rows).Â
With the lookup, we currently are using partial cache because full cache caused system out of memory.Lookup Transformation Editor - on this lookup -Â how to increase the size on partial Cache size 64-bit? I am being stuck at 4096 MB and can not increase it. In 2008, I had 200,000 MB partial cache size.
I need to create a function that replaces the data in a column with an 'X' based on the LEN of the data in the column. I created one that does a replacement, but it fills the column based on the max data length, and not the current length of the string or integer. An example of what I'm trying to accomplish.
Original data in a varchar(30) column: thisisavalue thisisanothervalue thisisanothervalueagain shortval
replaced with xxxxxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxxxxxx
My current function is replacing the data like this: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
There are 4 tables in a database. such as university, student, professor and worker. university table contains fields named- university_name, student_name, professor_name and worker_name. and student, professor and worker tables contain person_id and person_name.
Now, I want to replace the student_name, professor_name and worker_name data from university table with student table's person_id, professor table's person_id and worker table's person_id.
I am working with a database containing time series data. In many, cases there is missing data. For example, while there might be a value for 2001-01-01T23:00:00, there is none for 2001-01-01T23:0100 (one minute later). I would like to replace the missing data with data from the previous record (if the previous record is the same date). Is that possible with T-SQL?
In this project I m using SQL Server 2005 express edtion.I can run select queries but I couldnt run insert and update query.Is there any protection for adding data to the Sql Server express edition ?
i wonder what is the best approach to use !!!i have creditLimit column in Customer Table the default value will be 500 and this limit to allow users to send sms from my website ..... every month they will be allowed to send 500 sms referring to the credit limit column.... now !!if the user sent today some sms and after few days sent another 20 and after one week he sent 150 SMS as a total so that means he has only 350 SMS as credit to use this month!!!so what is the best approach to implement this solution ? shall i have another field in the table called 'CreditUsed' and that will be updated each time the user will send SMS and this value will be compared with the credit limit ORi use the formula for the column to calculate the credit left and do the maths !!!what is the best approach as you think ???thnaks for reading this question !!
i am running this script SELECT dbo.SHOVEL_A.HOLEID, dbo.Shovel_Hole.HOLEID AS shovel_id, dbo.SHOVEL_A.PROJECTCODE, dbo.Shovel_Hole.Shotname, dbo.Shovel_Hole.B_FEET, dbo.Shovel_Hole.S_FEET, SQRT(square(dbo.SHOVEL_A.EAST - dbo.Shovel_Hole.EAST) + square(dbo.SHOVEL_A.NORTH - dbo.Shovel_Hole.NORTH)) AS distance_total FROM dbo.SHOVEL_A FULL OUTER JOIN dbo.Shovel_Hole ON dbo.SHOVEL_A.POLYGONO = dbo.Shovel_Hole.Shotname AND distance_total <= dbo.Shovel_Hole.B_FEET GROUP BY dbo.SHOVEL_A.HOLEID, dbo.Shovel_Hole.HOLEID, dbo.Shovel_Hole.Shotname, dbo.Shovel_Hole.B_FEET, dbo.Shovel_Hole.S_FEET, dbo.SHOVEL_A.PROJECTCODE, SQRT(square(dbo.SHOVEL_A.EAST - dbo.Shovel_Hole.EAST) + square(dbo.SHOVEL_A.NORTH - dbo.Shovel_Hole.NORTH)) HAVING (dbo.SHOVEL_A.PROJECTCODE = 'PRODL') AND (dbo.Shovel_Hole.Shotname = '20040524029')
but i have a result with the message that my colum name distance_total is wrong, so how can i fix that?
We are thinking of using general purpose column names in our application schema. We want to give the option to the end user to customize the filed names to fit their business . We want to build the functionality on the generic names so that it will work for multiple customes.
Example: We may want to have 10 Strings, 10 numbers and 5 booleans pre defined and reports running off of the table. The customer can name first number as pressure, second one for length and map their data to the table. Other customer can use the first number for temperature and the second one for width.
Is there a way to do it in SQL server w/o having a lookup table for column name aliasing?
I would like to replace data of some tables from STG to DEV database daily using SSIS package. Should I use "Transfer SQL Server Objects Task" to do that? Thanks.
Hi, I was wondering if it is posible as in derived columns to replace an input column with the output one in Data Conversion? What I can see that when a data conversion is done, only we can do it in a new column and not in the same one we are using as input. Do you know if this it is posible?} Thanks for your help!
I am working with a database named €œDocuments€? that contains 4 categories of text documents, each having its own number designation in an integer datatype column named SectionTypeId:
1 = Text 2 = Report 3 = Background 4 = Index
I would like to create a new column named €œDocType€? in which the integer data type for each document is replaced with a varchar data type letter (1 = T, 2 = R, 3 = B, 4 = I). I was able to easily create the new column and cast the data type from integer to varchar:
--CREATE NEW COLUMN €œDocType€? WITH VARCHAR DATATYPE
ALTER TABLE FullDocuments ADD DocType VARCHAR(1) NULL Go
--UPDATE NEW COLUMN WITH CAST STRING
UPDATE FullDocuments SET DocType = CAST(SectionTypeID AS VARCHAR(1)) Go
But I have problems with the REPLACE method for replacing the numbers with letters. First I tried this based on the examples in MSDN Library:
--REPLACE NUMBERS WITH LETTERS
UPDATE Fulldocuments REPLACE (DocType,"1","T")
Which produced an error message: €œIncorrect syntax near 'REPLACE'.€?
Thinking that the datatype may be the problem, I tried this to convert to DT_WSTR data type prior to replace:
Hi All, I have a column called TIER in my database which is a long string. There are piece of these strings that are separated by spaces like this: 'A3A00 A2B00 B1A00 C2C06 C3A06 C5A00 D2C00 G6B00 M2B00 M3B00 P7A00 T2A00 G4C00 G3C00 T5A06' How do I select the last 2 characters of the piece of string when the first 2 chacters are M2? I have the following: This is retruning me all the rows that have 'M2'. declare @code varchar (2)set @code = 'M2'select tier from companywhere tier like '%'+@code+'___ %' Any help is appreciated. Thank you in advance.
HI, how can i drop the identity on a column from the table. I have no access to the sql enterprise manager, i have to do it thru query analyser only. regards, varadish
i have a problem, i have a query which does a search based on a parameter, thing is i want to order them according to how relevant the results are such as 5 for beingan exact match, 0 for being no match. using a series of liek statements.
so that the most relevnat results are displayed at the top.
how do i achieve this - im a bit confused about this.
I have about 5 statements like the update below, depending on the PID different columns will be update "C2005, G2005,E2005...."
I would like to use 1 update statement in stead of 5 to update all columns below are 2 original update statements and my attempt at when then update. Note a different column is updated depending on the PID.
If when then isnt possible, any other suggestions are welcomed. Thanks UPDATE #Sec SET C2005 = Pos.USD / 1000 FROM #Sec INNER JOIN Pos ON #Sec.ID = Pos.ID WHERE (Pos.PID = 'B')
UPDATE #Sec SET G2005 = Pos.USD / 1000 FROM #Sec INNER JOIN Pos ON #Sec.ID = Pos.ID WHERE (Pos.PID = 'G')
UPDATE #Sec WHEN (Pos.PID = 'C') THEN SET C2005 = Pos.USD / 1000 end WHEN (Pos.PID = 'G') THEN SET G2005 = Pos.USD / 1000 end WHEN (Pos.PID = 'E') THEN SET E2005 = Pos.USD / 1000 end FROM #Sec INNER JOIN Pos ON #Sec.ID = Pos.ID
Im Working with stored procedure. How can i compare Columns with specific values. I want to get the greater values of those column and inserted it to other columns. i want something like these CASE WHEN a> b,c,d THEN a WHEN b> a,c,d THEN b WHEN c> a,b,d THEN c WHEN d> a,d,c THEN d
is there any ways to implement this? i got an error.. thanks please help..
SELECT @initial = CASE WHEN type = 1 THEN SUM(amount) END, @incomings = CASE WHEN type = 2 THEN SUM(amount) END, @outgoings = CASE WHEN type = 3 THEN SUM(amount) END, FROM Transactions WHERE date = '05/14/2006' AND STATION = 'apuyinc' GROUP BY type, amount
What I am trying to do is to sum all of the incomings transactions into @incomings, all of the outgoing transactions into @outgoings and the initial transaction into @initial where The incoming transactions is type 2, outgoing transactions is type 3
I currently have a LoginStatus and LoginName control on my asp.net 2.0 master page. When successfully logged in a message displays "You are logged in as" LoginName. Since I am using the user's e-mail address as the UserName the message will display as "You are logged in as johndoe@foo.com". What I want to do is have the message display as "You are logged in as " FirstName LastName. FirstName and LastName are two new fields that I added to the table, aspnet_Users. What I have done is to use the FormView control to display FirstName and LastName; however this always displays the first record in the aspnetdb database. Is there a cleaner way (than the FormView control) to display the requested data, using the currently logged in user? I have access to Microsoft Expression Web and Visual Studio 2005, but I prefer Expression Web. Thank you in advance
Hi I have a table named UserMaster having a column Sex for male and female.Sex MaleMaleFemaleFemaleFemale I want to replace all Male with Female and all Female with Male with a single query. Can any one please help me out
In SQL7, if you add a column to a table, is it necessary to recompile all stored procs that reference that table? Under 6.5, this caused problems at our site unless the Procs were 'refreshed'. Is this only necessary where select * is used? Thanks