Copy Within A Table - Plain SQL
Aug 9, 2006
Hi.
I'm quit new into SQL - have a problem - and hope someone here ca n help me.
I have a table TABLE1 with different fields. A part of it looks like this:
FIELD1 FIELD2 FIELD3
111111 121212 0
111111 121212 91
222222 232323 0
222222 232323 73
etc. etc.
I want to "copy"/write over '0' in FIELD3 with the number in FIELD3 from the line that has the same numbers (and unique for these two lines) in FIELD1 and FIELD2. The table will then look like this:
FIELD1 FIELD2 FIELD3
111111 121212 91
111111 121212 91
222222 232323 73
222222 232323 73
I can make a temporary table or a new field if necessary. I just don't know how to write the right SQL.
Thankful if anyone can help me.
View 5 Replies
ADVERTISEMENT
Apr 26, 2007
Hello. I am really new to sql server. I have a db in the server that I use for testing. i want to export it in plain sql so as to import it in another db system. How can I do it?
thank you a lot.
View 8 Replies
View Related
Oct 1, 2007
Greetings all.
I am currently working to improve the security on a legacy application we have at my company. The app was written in vb6 years ago. We now have the app running against a sql 2005 server. One of the function/screens in the application is used to administrate users. (each user has a sql user id) and one of the functions is to reset the password. The vb code uses a call to sp_password. Here is the problem. We setup a network sniffer and found the command being in plain text. While the user logon is encrypted ( SSL Fallback) the sp_password commands issued by the app are plan text. Anyone know of a way to make this encrypted?
Leif
View 3 Replies
View Related
Jul 23, 2005
I have a SQL Server 2000 table with a few fields of "text" data typethat contain rich text. I have to downstream this data and therecipient cannot handle rich text. I need to figure out a way toconvert it back to plain text. Any suggetions?TIA
View 4 Replies
View Related
Apr 19, 2007
How can I set the default body_format in database mail. I would like to send a warning with plain text format (from the alerts), that i'll get on my mobile phone, but the message's format is html... always...and I don't get the sms-s.
View 5 Replies
View Related
Nov 29, 2007
Hello List,
sorry to raise this again here. I have seen a lot of posts on this board about plain text rendering but never really a satisfactory answer. So my question is: Has anyone succeeded in developing a custom rendering extension which is able to render a report as plain text?
I am a Technical Lead in a project to convert and migrate reporting from Unix/C to Reporting Services 2005. One requirement is, to render the reports in plain text for archiving purposes. I know that there are a million options out there to archive in PDF and whatever. Well, we need plain text. No way around it! It is a governmental requirement!
I am about to pull the plug on SSRS 2005 just because we are not able to fulfill this requirement. And we are talking about a big project converting >700 reports!
Challenges we are facing:
Reporting components are rendered as they appear in a compnent list, one after each other. If you now have two multiline components side by side, i.e. two lists, the first list component in the array gets rendered and then the other. This makes it almost impossible to render the lines in those two components side by side. In the sample below, the Report Header would be rendered, then the Address block, then the Other Data block, then the Order History Table and then the Account Statement table.
Positioning of text boxes is almost impossible. We are able to find out how many centimeters/inches/millimeters/points a control is located from the left border. But how can we translate this into i.e. how many spaces will we need to add for padding?
The column width can't be determined. SSRS adds a line break if the cell text is longer than the column width.
We have reports which look something like this:
Code Block
Code Block
REPORT NAME
MANAGER NAME
ACCOUNT
REPORT DATE
First Name: XXXXXXXXXXXX Other Data: XXXXXXXXXXXXXX
Last Name: XXXXXXXXXXXX More Data: XXXXXXXXXXXXXX
Address: XXXXXXXXXXXX More Data: XXXXXXXXXXXXXX
City: XXXXXXXXXXXX
Order History Account Statement
XXXXXXXXXXX XXXXXXX XXXXXX XXXXXXXXXXXXX XXXXXXXX XXXXXXXXXXXXX
XXXXXXXXXXX XXXXXXX XXXXXX XXXXXXXXXXXXX XXXXXXXX XXXXXXXXXXXXX
XXXXXXXXXXX XXXXXXX XXXXXX XXXXXXXXXXXXX XXXXXXXX XXXXXXXXXXXXX
XXXXXXXXXXX XXXXXXX XXXXXX XXXXXXXXXXXXX XXXXXXXX XXXXXXXXXXXXX
XXXXXXXXXXX XXXXXXX XXXXXX XXXXXXXXXXXXX XXXXXXXX XXXXXXXXXXXXX
I also got some advice that SSRS is probably the wrong tool. And I also read this in some of the "Plain Text" posts here. And I am actually surprised about this. People suggest to look for some other tool and not use i.e. email subscrptions, other rendering formats, SSRS security model, snapshot history, report models and all the other goodies only because we can't render in simple text?
If anyone has any information to share, I would very much appreciate it. We also looked at third party tools and plug ins but couldn't find any! If anyone knows of a company who would be able to help us, let me know!
I really would love to pull this project off with SSRS 2005 because I Iike the technology and SSRS provides a lot of functionality we want to leverage. I believe SSRS is the right tool for us and it covers 95% of our business requirements! But at this stage it doesn't look very rosy! Because of the Plain Text rendering!
Cheers
Peter
View 6 Replies
View Related
Jan 9, 2008
Hi all,
The following dbo.Tables of Northwind.mdf in my .SQLEXPRESS (SQL Server Management Studio Express) are missing:
dbo.Categories
dbo.CustomerCustomerDemo
dbo.CustomerDemographics
dbo.Customers
dbo.Employees
dbo.EmployeeTerritories
dbo.Order Details
dbo.Orders
dbo.Products
dbo.Regions
dbo.Shippers
dbo.Suppliers
dbo.Territories.
But, I have these dbo.Tables in a different Database "xyzDatabase". How can I copy each of these dbo.Tables to the another blank dbo.Table of Northwind Database?
I right clicked on the dbo.Categories and I saw the following thing:
dbo.Categories
New Table...
Modify
Open Table
Script Table as |> CREATYE To |>
DROP To |>
SELECT To |>
INSERT To |> New Query Editor Window
File....
Clipboard
UPDATE To |>
DELETE to |>
From the above observation,I think it is possible to copy the dbo.Table from the one Database to the Northwind Database that needs to be repaired. Please help and advise me how to do this task or tell me where I can find the Microsoft document that gives the details of this X-copy thing.
Thanks in advance,
Scott Chang
P. S. I am using VB 2005 Express to create a project to learn "Calling Stored Procedures with ADO.NET" (see Paul Kimmel's article in http://www.developer.com/db/article.php/3438221) that needs the dbo.Tables of Northwind Database and my Northwind Database has been screwed up for quite a while and needs a big repair.
View 3 Replies
View Related
Sep 23, 2014
Trying to troubleshoot an CLR/ RTF to Plain Text issue I am having.
I have 3 instances on one SQL server. Only one of the Instances is not working. Even tried deleting everything and resetting it up.
Here is the code I am testing with:
USE Test_Database
GO
DECLARE @RTF varchar(max)
SET @RTF = '{
tfansiansicpg1252uc1deff0deflang1033{fonttbl{f0 Calibri;}{f1 Arial;}}{colortbl
ed0green0blue0 ;
ed255green255blue255 ;}viewkind4paperw12240paperh15840margl1425margr1425margt1425margb1425sectdpgwsxn12240pghsxn15840
marglsxn1425margrsxn1425margtsxn1425margbsxn1425pardfs21sl276slmult1sa180{f1fs21
Test New Progress Notes - Praveen}par}';
SELECT dbo.clr_fn_ConvertRTF2PlainText(@RTF)
Here is what I am getting back:
The operation completed successfully
Not sure what to check as the other two instances are working fine.
I have CLR enabled in sp_Configure
clr enabled 0 1 11
View 2 Replies
View Related
Jun 3, 2008
Hi,
I got a qry that takes 10s. This is off course too long.
As I described in my earlier posts, I'm no sql hero, but I'm on a neverending quest to improve.
Currently I need a select statement over several (7) tables and return fields from almost all of them.
Furthermore I have optional restrictions on fields spread over all those tables, based on a set of parameters.
What I initially do is inner join all my tables and then have a big where clause that adds where-rules depending on the arguments given.
Like so:
select c.clr_id, n.clr_nm, co.long_nm, p.paint_cd, a.appl_desc, m.modl_nm, y.yr_num
from CLR c
inner join paint_cd p
on c.clr_id = p.clr_id
inner join clr_use_yr y
on y.clr_id = c.clr_id
inner join co
on co.co_id = c.co_id
inner join modl m
on y.modl_id = m.modl_id
inner join clr_appl ca
on c.clr_id = ca.clr_id
inner join appl a
on ca.appl_cd = a.appl_cd
inner join clr_nm n
on c.clr_id = n.clr_id
WHERE
(CASE @regn when '' THEN '' ELSE n.regn_cd END) like (CASE @regn when '' THEN '' ELSE @regn END)
AND (CASE @co when '' THEN '' ELSE co.long_nm END) like (CASE @co when '' THEN '' ELSE @co END)
AND (CASE @clrNm when '' THEN '' ELSE n.clr_nm END) like (CASE @clrNm when '' THEN '' ELSE @clrNm END)
AND (CASE @paintCd when '' THEN '' ELSE p.paint_cd END) like (CASE @paintCd when '' THEN '' ELSE @paintCd END)
AND (CASE @applDc when '' THEN '' ELSE a.appl_desc END) like (CASE @applDc when '' THEN '' ELSE @applDc END)
AND (CASE @useYear when '' THEN '' ELSE cast(y.yr_num as varchar(4)) end) like (CASE @useYear when '' THEN '' else @useYear END)
AND (CASE @modlNm when '' THEN '' ELSE m.modl_Nm END) like (CASE @modlNm when '' THEN '' ELSE @modlNm END)
It appeared to me that by getting those where clauses in the join, I would limit the calculations. So the joins where similar to this:
inner join paint_cd p
on c.clr_id = p.clr_id
AND (CASE @paintCd when '' THEN '' ELSE p.paint_cd END) like (CASE @paintCd when '' THEN '' ELSE @paintCd END)
The result though, was exactly the same.
So, where in my thinking am I wrong and what is the correct way to go about this?
View 9 Replies
View Related
Oct 16, 2007
Good Morning Kristen:
Thank You, You are the first person, that has given me a clear answer. I am going to explain in plain English What this SP is suppose to do.
I have to find any station_nbr that has more than one group_code and that the current date = (DATEADD(mm,DATEDIFF(mm,0,dateadd(mm,-0-datepart(day,0),getdate())),0) The current date starts with the first day of the previous month.
Example today is October 10, 2007 I need September 01, 2007 for this query.
To insert the record it needs to be active meaning that the current date is in between Beg_eff_date and end_eff_date, and the end_eff_date is = ‘12/31/3000’
I need to write SP(cursor) that reads line by line this table and that insert the answer: INSERT INTO #TP_TIES_OVerlaping_Dates.
Example:
Current_date: 09/01/2007
Group_Code Station_nbr beg_eff_date end_eff_date
0000003 00371101 03/12/2006 12/31/3000
0000016 00371101 07/08/2007 12/31/3000
The above explanation is for the first type of Error.
The second Type of Error:
If the Group Code ends with "W" and the End_effective_date = '12/31/3000' and the W_Beg_date is Part of the Temp Table(I to create the W_Beg_Date Column) -- is GREATER than the End_eff_date. I want to Insert this Record into the Table. I need to set sometype of Record Control to make the different between one error to another one.
I thank you so much for your help.....I hope this is clear to understand for everybody.
End
View 7 Replies
View Related
Jul 23, 2005
Does anyone have the logic to convert RTF formatted data in a textcolumn into plain ascii text that I can use in a varchar variable orfield?We have an app that allows formatted comments/notes to be stored in aSQL 2000 text column. Ideally, I would like a trigger that would copyany inserted comments into a seperate table, varchar field so thatthese are viewable in other apps that can not display formatted RTF.I would really like the logic to be all SQL based and not have to use aclient app to read/convert/insert the data in a batch mode.
View 1 Replies
View Related
Jul 20, 2005
Hi all. Iv'e tryed out xp_smtp_sendmail, and I like what I can see sofar. The thing I wonder about is if the xp supports sending both htmlAND plain text in the same mail. I'm on a sql2000 sp3 and I have noproblem with the xp when i either send plain text or html, but asstated above I need to send with both formats in one mail......For use when one does not know if the receiver uses a mail-client thatsupports html or not. If not does anyone know of a good way to attackthis problem?thanks in advanceKarl B
View 1 Replies
View Related
Sep 7, 2006
Hello All,
We are trying to figure out how to make a stored procedure call and pass some inputs using C# and plain ADO. We are able to call an empty stored procedure but cannot pass parameters into a stored procedure.
Does anyone have sample code in C# whereby we can open a connection and pass inputs into a stored procedure? The following is a sample code we are using:
ADODB.Parameter param = new ADODB.Parameter();
param=cmd.CreateParameter("@StoreID", ADODB.DataTypeEnum.adInteger, ADODB.ParameterDirectionEnum.adParamInput,sizeof(int) , 9);
cmd.Parameters.Append(param);
ADODB.Recordset rsInv = cmd.Execute(out objAffected, ref objAffected,-1 );
In the above example, we create a parameter of type integer and try to add it to the ADO Command object. It is supposed to return a recordset. It returns a recordset with record count -1.
Sincerely,
Dwight Kulkarni
View 3 Replies
View Related
Jan 26, 2006
Just wondering if there is an easy transact statement to copy table 1 to table 2, appending the data in table 2.with SQL2000, thanks.
View 2 Replies
View Related
Jul 28, 2006
In dexterity iam using table_compare() function to check if tables in datasource and dictionary are same but its not picking up the primary key change but it does pick up the column change
any suggestion
thanks
View 1 Replies
View Related
Feb 21, 2008
hi,
I am new to Integration services.I have one query ,Is it possible to import the data from text file in integration services.
I know that we can import the data from excel sheet and we can export it to table.But my question is whether we can do the same thing from the text file.If anyone come acroos the same thing send u r possible answers.Your help is much appreciated.
Thanks in advance.
View 1 Replies
View Related
Oct 1, 2001
How do I copy a column(or colums) from a table in one database to another table in a different database
View 1 Replies
View Related
Nov 23, 2007
Hi All,
I have 2 tables People & PeopleCosts.
PeopleID in People Table is the primarykey and foreign Key in PeopleCosts Table. PeopleID is an autonumber
The major fields in People Table are PeopleID | MajorVersion | SubVersion. I want to create a new copy of data for existing subversion (say from sub version 1 to 2) in the same table. when the new data is copied my PeopleID is getting incremented and how to copy the related data in the other table (PeopleCosts Table) with the new set of PeopleIDs..
Kindly help. thanks in advance.
Myl
View 3 Replies
View Related
Jan 20, 2007
Hi allI have two tables in SqlServer with Exactly Same Structure,I want to Copy all Records fromone of them to another one.I came across to "Insert....select..." statement But i have two problem
1) I don't know any thing about Columns name!!! i just know they have same structure and as far as i know , "Insert...select..." need the Column list to operate correctly, am i right?
2) these two table have One Prinary Key column with IDENTITY feature.
Any Help Greatly appriciated.Regards.
View 6 Replies
View Related
Dec 10, 2007
Hi i have set up two very simple tables, I want a user to be able to create a basic account ( data stored in User_Profile table with Id set as the Primery Key as Identity) I
want the user to be able to be able to return to their account at a later date
and then post multiple reviews of different bands they have seen at a later date.
I kept the tables in my example very simple so I could get my head
around the concept, but generally, I want to connect the Id (PK) value in
User_Profile table to the User_Id filed in the User_Review table,
so every review that user writes, will be connected directly to their Id.
Any help you could give would be fantastic a i have no idea where to start!!!
User_Profile
Id int, ( as primary Identity Key)
Name
City
Country
I have a second table called User Reviews
User_Revews
Revew_Id int , ( as primary Identity Key)
User_Id int, ( I want this to contain the Id value in
the User profile Table)
Review_Details
Thanks
Odxsigma
View 3 Replies
View Related
Nov 30, 2004
Hi, All,
I have agentID in product table.
Now I add agentID column in transaction table. Now I want to copy all agentID from product table to transaction table based on the order_id
in both table. Can you show me an example?
Thanks
Betty
View 3 Replies
View Related
Jun 21, 2007
I need to copy existing row data from one table into a new row in a different table, both in the same database. Can this be done in a stored procedure where the selected row is passed in as parameter value?
Thank you,
View 2 Replies
View Related
Apr 24, 2005
Hello everyone,
I have a local MSSQL server (I guess it's called MSDE), with some tables that I would like to use as a template for a set of new tables. I would simply like a Stored Procedure that takes these 3 tables, makes a copy of their structure (not data, since they will be empty), and name them by using a parameter given to the SP. I have made something that I thought would work, but after testing it a bit more, it seems to forget default values for the fields, which is of course not good enough :). I hope that someone can tell me how to duplicate these 3 tables, including every detail for the fields!
View 1 Replies
View Related
Apr 21, 2008
Hi,
I need to recover a table.
I have restored completed database to a temp DB.
I do know,how to use export and import.
Any one can help me?
Regards,
Vinoth
View 2 Replies
View Related
Jun 4, 2007
Hi.Like the title says - how do i do this?I was given the following example:INSERT INTO TABLE2 SELECT * FROM TABLE1 WHERE COL1 = 'A'The above statement threw the following error:An explicit value for the identity column in table 'TABLE2' can onlybe specified when a column list is used and IDENTITY_INSERT is ON.Then, after filling in all the column names in my above selectstatement I kept getting an error to the effect that the number ofsource and destination columns don't match. This is because one column"confirm_hash" does not exist in the destination table, just thesource table.could somebody show me how to get this to work?thanks!PS - MS SQL SERVER EXPRESS 2005
View 10 Replies
View Related
Oct 23, 2007
I want to put fields from four tables into one table. I created a new table, but how do i get the same fields from the other tables to this table along with primary and foreign keys.
Table Fields
Tbl_Date_Dimension [Date_Dimension_Year], [Date_Dimension_Period], [Date_Dimension_Fiscal_Week]
Tbl_Report_Level Report_Level_Id
Tbl_Customer Customer_Code
[Sales Fact] [Gross Turnover] , Quantity, Consolidated_Sales_Tables_Id
The new table is called Tbl_Sales_Growth
Here's the information on the new table:
Code Block
[Date_Dimension_Year] [int] NOT NULL,
[Date_Dimension_Period] [int] NOT NULL,
[Date_Dimension_Fiscal_Week] [int] NULL,
[Report_Level_Id] [int] NOT NULL,
[Customer_code] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Consolidated_Sales_Tables_Id] [tinyint] NOT NULL,
[Quantity] [decimal](18, 0) NOT NULL,
[Gross turnover] [decimal](18, 0) NOT NULL
) ON [PRIMARY]
View 2 Replies
View Related
Jan 8, 2008
Hi,
I have a number of large tables (50,000,000 + rows and 30+ columns) that are refreshed once per month with data from another system. Data is first loaded into a staging table, that has an indentical strcuture to the final table, cleansed and then copy to the final table.
The current copy process is simple but inefficient:
Truncate Table <final-table>
Insert Into <final-table>
Select * from <staging-table>
If possible I don't want to use DTS for this and I'd like to use a batch size of around 10,000 rows to help reduce the size of the log file because I have 3 of these types of Inserts running concurrently.
What is the fatest way to copy data from one table to another, within a stored procedure using SQL 2000 on a large, clustered server that uses logging?
Thanks,
Jason
View 5 Replies
View Related
Mar 1, 2008
hai friends.............. I want to know how to copy table from one database to another in a same sql server 2005? ex : i have one table called sample1 in database db1. we want to copy it and and paste it to database db2.how can i do this explain me elaborately. regards Samuel Chandradoss .J
View 2 Replies
View Related
Apr 3, 2008
How to copy one databse table into another database as a same table with same same tablename?
View 2 Replies
View Related
May 8, 2008
Hi
I have 2 MSSQL databases. I want to copy some tables of DB1 to DB2. how can I do it?
Also, how can I copy some columns of table1 of DB1 to table 2 of DB2?
Thanks for help
View 2 Replies
View Related
Feb 11, 2006
What is the best way to copy a table, with the foriegn keys, primary keys and indexes, from one database to another using SQL Server 2005?
In sql server 2000 I used the DTS, but in SQL server 2005 it does'nt bring over the foriegn keys, primary keys and indexes.Thanks
View 2 Replies
View Related
Feb 16, 2006
Hi everone,I have one table called temp and I am copying its content over to another table called final. The final table has 2 more coloumns than the temp table, 1 of which is a primary key, and the other one is calculated. What is the easiest way I can do this?Thank you for the answer.
View 1 Replies
View Related
Jul 27, 2007
HI All,
i have 2 databases x and y
a table in x named as table1
i am looking to copy 'table1' from database x to database y say named 'table2'
Database y doesnt have a table1
Version: SQL Server 2000
How to do this on Query Analyzer and/or Enterprise Manager???
Thanks
View 3 Replies
View Related