Can somebody provide me an argument on how nicely formatted and indented procs perform better. I am currently formatting a 1000 line proc just to understand what it does ... Maybe your argument will help convince my development team to write neat procs :)
Is there a way to namespace groups of stored procs to reduce confusion when using them?
For C# you can have ProjectName.ProjectSection.Classname when naming a class. I am just wondering if there is a way to do the same with SQL stored procs. I know Oracle has packages and the name of the package provides a namespace for all of the stored procs inside it.
Hi,Is there a way to get stored procedure texts out in a formatted waylike defncopy in Sybase????? The way they print it out reallysucks............RegardsSubhas
I have a table for articles that I want as the basis for a blog. I have a field of description where the actual article will go, I have only ever really used tables to put in 'blocks' of text, how would I go about storing/displaying data that is in my database table in a more formatted way, for example line breaks, indents etc?
Hi, I am trying to write the output of an sql query to a text file using bcp. Now the problem am facing is i have to format the text like i the following order... <DATETIMESTAMP>08:39 Thursday, March 15, 2007</DATETIMESTAMP><CATEGORY>Quarterly Sales</CATEGORY><HEADLINE>Quarterly Corporate Earnings (03/15/07)</HEADLINE><BODY> Quarterly Corporate Profits (03/15/07) PER-SHARE ($) NET EARNINGS (mil$) REV. (mil$)COMPANY CURRENT YEAR-AGO CURRENT YEAR-AGO CURRENT YEAR-AGOabc 0.33 n/a 8.60 (13.30) 144.40 112.50 bcdf 0.16 (0.15) 7.80 (7.40) 101.90 81.20 gha n/a n/a (90.00) (80.00) 488.00 462.00 qwqw (0.10) (0.15) (3.30) (4.30) 2.90 2.20 Copyright(c) 2007 mycompany.com, Inc. All Rights Reserved</BODY> Would somebody please advice whther this sort of formatting is possible with bcp..Please give some pointers am completely stuck....the company data is coming from a database table...am using sql 2005...
I get this message in the SQL Server logs after I restore a db. I copied this backup from another server is that why it's telling me it formatted incorrectly? The strange thing is in QA it restores successfully but when I look @ EM it's remains in Loading mode and never completes
The backup data in 'D:SQLServerMSSQLackupjan_prod_db_20050214173 0.BAK' is incorrectly formatted. Backups cannot be appended, but existing backup sets may still be usable.
Hi All, I am kindly seeking for help. I have a table(MyTable) which is defined as (date datetime, ID char (10), and R, P,M,D&Y are all float) and the layout is as following: Date ID R P M D... Y 1/1/90 A 1 2 3 4... 5 1/2/90 A 2 3 4 5... 1 ... 2/11/05 A 3 4 5 6... 2 1/1/90 B 1 2 3 4... 5 1/2/90 B 2 3 4 5... 1 ... 2/11/05 B 3 4 5 6... 2 ... The expected query results look like: ( this results from Date, ID and R fields) Date A B 1/1/90 1 1 1/2/90 2 2 ... 2/11/05 3 3
The SQL I wrote: select date, ID, A=sum(case when ID=A then R else 0 end), B=sum(case when id=B then R else 0 end) from MyTable Group by date
I would also like to get another set of results with the same format but from date,ID and P fields: Date A B 1/1/90 2 2 1/2/90 3 3 ... 2/11/05 4 4
select date, ID, A=sum(case when ID=A then P else 0 end), B=sum(case when id=B then P else 0 end) from MyTable Group by date
The problem with that is if I have thousands of ID in MyTable I have to "hard code" thousands times and the same problem with the fields/columns. Is there any easier way to do this? I also would like to insert the results into a table/view which will be refreshed whenever MyTable gets updated.
Any suggestion/comments are highly appreciated! shiparsons
I have 265 word documents which I use with mail merge to create a master document.We are going to auto generate this master document going forward so I want to store these 265 word documents, these range in size from 10kb to 50kb. As I mentioned these are formatted and also contain a merge field/marker so what I will be doing is using a value in the database, my application will take the document which is stored as a string/blob and will replace the "merge field" with the value from the database.
I can write an application to import each of these documents but I am not sure whats the best way to store them in order to be able to find and replace the merge marker.Also I will be joining a number of these together to make the master document. So for example I take 10 of these and I replace the marker fields in these with the values from the database, I will then push that string out to a PDF/Word document for printing.
I need to export data to a worksheet and format the resultant sheet appropriately. I kow server side automation is a no-no. What would be the best alternative to accomplish this?
Hi, that's the problem: I have a GridView, bound to a SQLDataSource, with an stored procedure as a Select query. The Select Parameters are bound to controls in the web form, acting like some filter fields. When I submit the page, everythings works fine, except when I try to set some value in the DateTime fields. .Net is enclosing the date with extra single quotes, as I could see in the Profiler: exec sel_despesa_procura @codigo=NULL,@fornecedor=NULL,@descricao=NULL,@vencto_ini=''2005-10-10 00:00:00:000'',@vencto_fim=''2005-10-20 00:00:00:000'',@pagto_ini=NULL,@pagto_fim=NULL,@valor=NULL,@valor_pago=NULL,@centro_custo=NULL,@pago=N'0,1' The fields are defined as follows: <SelectParameters>...<asp:ControlParameter ControlID="txtFiltroVencIni" Name="vencto_ini" PropertyName="Text" Type="DateTime" /><asp:ControlParameter ControlID="txtFiltroVencFim" Name="vencto_fim" PropertyName="Text" Type="DateTime" />...</SelectParameters> The stored procedure doesn't even execute, due to the bad formatted arguments. It returns the error: Msg 102, Level 15, State 1, Line 1Incorrect syntax near '2005'. I'm going to change the parameter type to varchar, as a workaround, but I'd like to solve this problem.
Using the stored proc XP_Sendmail i am able to send mails successfully. But i need to format the mail.. so for formatting i am using HTML tags.. so when i am sending the mail the html tags are getting displayed as it is. So pls can any body tell me how i can send the HTML formatted mail.
What does this error message mean ? We have SQL2000, with database FULL RECOVERY. Other databases on the server are fine. Backups stopped working a week ago. Can't remeber anything changing +++++++++++++++++++++++++++
The backup data in 'D:BackupTI backup.BAK' is incorrectly formatted. Backups cannot be appended, but existing backup sets may still be usable. [SQLSTATE 42000] (Error 3266) BACKUP DATABASE is terminating abnormally. [SQLSTATE 42000] (Error 3013). The step failed.
I have some textual data that comes preformatted with some extra spaces and line feeds. I am attempting to put it in a Report using SSRS 2005.
When ever I view the report in HTML Mode all of the extra whitespace is suppressed into a single space. However when I export to PDF or Word it all comes back. I have tried using the .Replace() method to put in and <BR> tags into my code, but then it just displays the extra text and doesn't display it as HTML.
Is there anyway either replace the items with the appropriate HTML, or add the "PRE" whitespace CSS attribute to a Textbox so that the text displays the same in HTML and in a PDF?
I am developing a resume storage system, and don't know the best way to store the resumes that come in to our company in both MS Word and text files. Should I store the files in the original format they come in, and reference the file name in the databse that points to a directory where they are stored, or should I store the text of the resumes directy in the database. There are 2 things that I must follow.
1: I need to have the documents keep their formatting. 2: I also need the capibility of conducting a full text search to pull out key words from the documents.
I'm running a query with osql, and I'm trying to get some clean output that is comma delimited. So far my line looks like this:osql -E -n -d mydb -i custom.qry -o "c:output esults.csv" -h-1 -s ","This works off a table with only two columns. I'm still left with a lot of extra spaces between the first column output and second column output, and at the bottom the text "(50 rows affected)".So instead of this:data1a (lots of spaces here) ,data1bdata2a (lots of spaces here) ,data2bdata3a (lots of spaces here) ,data3b(50 rows affected)I want to see this:data1a,data1bdata2a,data2bdata3a,data3bThanks very much for any help. :)
What is the recommended method of returning a formatted date from a stored procedure?
The date is held in a date time field. I wish to return the date formatted as:
dd/mm/yyyy hh:mm
for display in a bound text box on a win form. JUst selecting the date and binding it to the text box shows:
dd/mm/yyyy hh:mm:ss
I do not want the :ss to show. A textbox does not have a format property (that I can see). I suppose I could create my own textbox inheriting from the standard and apply a display format property. I thought it may be easier to select as required in an sp. The textbox is read only on the form.
I was looking at:
select jobHeaders.DateTimeJobTaken AS [Job Taken], CAST(datepart(dd,jobHeaders.DateTimeJobTaken) as char(2)) + '/' + CAST(datepart(mm,jobHeaders.DateTimeJobTaken) as char(2)) + '/' + CAST(datepart(yyyy,jobHeaders.DateTimeJobTaken) as char(4))
from jobHeaders
but this gives : 8 /3 /2004 with spaces.
Before looking further I thought one of you guys may have the answer.
I need to create a query (SQL 2000) that renders a formatted excel (xml or xls) file for each row that is outputted.
The details, I have a Campaign table that contains information for Auto and Life "Leads" and the data is submitted by telemarketers directly into the database. I need to render a file for each line, and it would be good if It were an Excel XML or XLS file, because that's what we've been using for a while.
The latest similar question is almost a year old and hasn't been definitively answered. I'm designing a certificate type report where the declaration text uses static and dynamic text generated in an expression for the textbox. The problem is that there doesn't seem to be an obvious way of formating sections of the text expression with different font sizes, weights and attributes to depict the effect desired. E.g. I want one textbox to say:
This Certifies that {a field value} was blah blah blah by {another field value} etc.
Can this be done in a regular textbox? If not, are there any work-arounds to accomplish the same effect. BTW, I'm working in RS 2005 flavor with VS 2005 Report Designer.
I am considering whether SSIS can be used to deal with a formatted report that consists of a number of pages delimited by a control character with rows deleimited by CRLF. There are a number of header records that will need to be removed on each page and each line consists of data in fixed width columns.
The files will be fed to us on a regular basis so we will require an automated solution
Can I use one of the import objects available within SSIS directly to deal with this kind of file or will I have to bite the bullet and start coding a solution using C# or vb.net ?
CREATE PROCEDURE PROC1 AS BEGIN SELECT A.INTCUSTOMERID,A.CHREMAIL,B.INTPREFERENCEID,C.CHR PREFERENCEDESC FROM CUSTOMER A INNER JOIN CUSTOMERPREFERENCE B ON A.INTCUSTOMERID = B.INTCUSTOMERID INNER JOIN TMPREFERENCE C ON B.INTPREFERENCEID = C.INTPREFERENCEID WHERE B.INTPREFERENCEID IN (6,7,2,3,12,10) ORDER BY B.INTCUSTOMERID
END
IF I AM USING THIS PROC AS I/P TO ANOTHER PROC THEN IT GIVES NO PROBLEM AS I CAN USE ?
BUT IF , I USE ANOTHER PROC SIMILAR TO THE FIRST ONE WHICH GIVES SLIGHTLY DIFFERENT RESULTS AND GIVES TWO SETS OF RESULTS,THEN WE HAVE A PROBLEM,HO TO SOLVE THIS :-
CREATE PROCEDURE MY_PROC AS BEGIN SELECT A.INTCUSTOMERID,A.CHREMAIL,B.INTPREFERENCEID,C.CHR PREFERENCEDESC FROM CUSTOMER A INNER JOIN CUSTOMERPREFERENCE B ON A.INTCUSTOMERID = B.INTCUSTOMERID INNER JOIN TMPREFERENCE C ON B.INTPREFERENCEID = C.INTPREFERENCEID WHERE B.INTPREFERENCEID IN (23,12,10) ORDER BY B.INTCUSTOMERID
END
SELECT A.INTCUSTOMERID,MAX(case when A.intpreferenceid = 23 then '1' else '0' end) + MAX(case when A.intpreferenceid = 12 then '1' else '0' end) + MAX(case when A.intpreferenceid = 10 then '1' else '0' end) AS PREFER FROM CUSTOMER GROUP BY A.INTCUSTOMERID ORDER BY A.INTCUSTOMERID END
WHICH NOW GIVES ME TWO SETS OF DATA , BOTH REQUIRED THEN HOW TO USE ONE SET OF RESULTS AS I/P TO ANOTHER PROC AND OTHER SET OF RESULTS AS I/P TO YET ANOTHER PROC .
Ok, when I bind a textbox in my FormView I'm changing the format to currency (<%# Bind("TotalValue","{0:c}") %>). When I click Update I get "Input string was not in a correct format" since TotalValue is Int32 data type.
Shouldn't it convert it back to Int32 when it updates the db? Or do I have to do it manually, and if so how?
In SSRS I am trying to get a textbox value to hold text with a mixture of formatting, along the lines of "name (country)" where the "name" part is bold and the "(country)" is normally formated.
1. Have a query that fetches a real value (e.g. 4.3345643)
Let say the field is called TheReal.
How can I format the value in the select statement so I get a thousand separator(s) and two decimals in the resultset.
2. In the same query I have a left join as well. Table 2 retur (sometimes) <NULL>. Is it possible to force this <NULL> value to be a fixed string value instead in the select statement.
I am unable to send a message to a target service on a different SQL Server instance. Using the SQL Profiler, I get the following error from the target machine:
Broker::Connection: Connection handshake failed: An OS call failed: (80090326) 0x80090326(The message received was unexpected or badly formatted.). State 106.
On the initiator side, the transmission_status shows the following error:
An error occurred while receiving data: '64(The specified network name is no longer available.)'.
Any ideas on why the target thinks the message is "unexpected or badly formatted"? Btw, I am specifying the default message type and contract for the services.
I have an Excel workbook that needs to be imported. It has three sheets, but it's really the first that is giving me fits. Each of the three worksheets have header info and instructions on the first 8 rows. Worksheet 1 then has, on row 9, the column names for the group informtion. Row 10 has the group information. Row 11 has detail column headers. Row 12 and later have detail information. Worksheets 2 and three do not have detail information, just row 9 with the column names for the group informtion and Row 10 with group information.
Here is how I am thinking of handling this. Run a script, outside of SSIS to save each sheet as a CSV file to a folder. I believe that this must be done because some of the first 8 rows are blank and according to the docs, SSIS cannot have blank rows in imported Excel sheets. Loop over the files in the folder. For each file, exclude the first 8 rows. if the file name is the first worksheet then get the next two rows and process group info get the rest of the worksheet and process detail information if the file name is not the first worksheet then get the next two rows and process group info
My questions are: Does this seem feasible? Is there an easier way to do this? Any hints or tricks that might be helpful? Any pitfalls that I should watch out for?