Preserve SQL Format In Query Editor?

Dec 11, 2007

Not exactly a TSQL question. Query Editor in Management Studio keeps reformatting my sql code every time I hit save, making the code much harder to read. Is there a way to preserve line breaks and indentation in the SQL when creating a view? Thanks.

View 1 Replies


ADVERTISEMENT

Using Flat File Connection Manager Editor With Delimited Format

Jan 23, 2007


Hello everyone:

I am new with SSIS and I have a problem that I don€™t know solving it.
I have a simple package with a delimited flat file source which is loaded into a table in a SQL Server database.
Below is the import format:
- Row delimiter: carriage return and line feed {CR/LF}
- Column delimiter: Comma {,}
- Text qualifier: €œ

In the source file, the data looks like this:
€œstring1 €?, 34, €œ€?, , ,€? string2 €œtext1€? string2€? , €œ €œ,

This package with DTS works, but now with SSIS does not, when I see the €œprevious rows€? in the Flat File Connection Manager Editor, the last column has incorrect information and when I create a new file without spaces and without twice €œ€? in the same string, it works. I don€™t know what I am missing with SSIS.

Regards,
Fanny Tejera

View 8 Replies View Related

Uppercase T-sql Keyword In Query Editor

Oct 16, 2006

In Query Editor I type statements like this:



"select * from ...."



Does Query Editor support a "macro" facility where I could, via keystorke, uppercase all t-sql keywords? (so it would look like SELECT * FROM...)



TIA,

barkingdog



P.S. You think I'm lazy? I knew a programmer who was so lazy that his password was one character long!

View 7 Replies View Related

Sql2005 Query Editor And Sql Logins

Sep 14, 2006

Under sql 2000 I could connect to a server as a speciifc sql user. How can I emulate that under sql 2005 Query Editor. (It doesn't appear to let me define the user to log in as.)



TIA,

Barkingdog

View 4 Replies View Related

Problem With MDX Query In SSRS MDX Editor...

Jan 9, 2008

I have an MDX query that is running fine in SQL Mgmt Studio, but crapping out in the MDX editor in SSRS. How do I resolve this?

My query & partial results are given below:


SELECT NON EMPTY {

[Product].[Category].[All],

[Product].[Category].&[1],

[Product].[Category].&[2],

[Product].[Category].&[3],

[Product].[Category].&[4] } *

{ [Measures].[Sold Amt USD], [Measures].[Sold Qty] } * { [Time].[Year].&[2007], [Time].[Year].&[2006] }

ON COLUMNS,

NON EMPTY {

[Customers].[Customers].[Cust Group].&[Specialty].&[100001291 Customer Name] }

*

[Customers].[Area].[All].CHILDREN * [Time].[Month Full Name].[All].CHILDREN

ON ROWS

FROM [Sales And Margin Cube]

WHERE ( [Customers].[Customer Group].&[Specialty] )















All
All
All
All
Prod1
Prod1
Prod1
Prod1
Prod2
Prod2
Prod2
Prod2
Prod3
Prod3
Prod3
Prod3
Prod4
Prod4
Prod4
Prod4




Sold Amt USD
Sold Amt USD
Sold Qty
Sold Qty
Sold Amt USD
Sold Amt USD
Sold Qty
Sold Qty
Sold Amt USD
Sold Amt USD
Sold Qty
Sold Qty
Sold Amt USD
Sold Amt USD
Sold Qty
Sold Qty
Sold Amt USD
Sold Amt USD
Sold Qty
Sold Qty




2007
2006
2007
2006
2007
2006
2007
2006
2007
2006
2007
2006
2007
2006
2007
2006
2007
2006
2007
2006

100001291 Customer Name
Region 1
1-Jan
419,627
376,299
1,418
1,665
202,032
291,389
374
632
1,737
692
2
1
17,181
18,019
18
24
130,131
906
194
1

100001291 Customer Name
Region 1
2-Feb
905,706
411,105
3,062
2,011
497,540
258,067
815
519
12,171
(null)
12
(null)
30,432
10,479
32
13
223,008
25,653
339
35

100001291 Customer Name
Region 1
3-Mar
982,528
763,321
2,826
2,062
384,939
329,926
675
605
5,327
769
8
1
9,797
27,056
9
33
497,903
335,283
740
519

Thank you,

NL

View 3 Replies View Related

Query Editor: How To Display Individual Row Vertically

Nov 20, 2006

In query editor I displayed a single row from a table. The row is so long that I need to scroll horizontally back and forth to check out it's fields. Using t-sql (or otherwise) can I display the row like this: (vertically)



Field Name 1: < data value 1>

Field Name 2: < data value 2>

Field Name 3: < data value 3>

Field Name 4: < data value 4>

etc.



TIA,

barkingdog



View 5 Replies View Related

Build Query Dialog For OLEDB Source Editor

Mar 23, 2006

Can i extend the "Query Builder" dialog of OLEDB Source Editor for developing custom source component?

View 1 Replies View Related

How To Preserve Entire Database

Jul 12, 2005

Hi, I'm a noob who sucks at programming, and sucks even more when it comes to database.

I'm operating a small website with an SQL Server database that drives my shopping cart. I want to close this website down, but I don't want to lose all the data in the database in case I want to do something in the future.

How do you backup the entire database into a file so i might be able to import it at later times? Do I have to do this with SQL, T-SQL, or the manager?

View 3 Replies View Related

Datatypes That Preserve Rich Text

Feb 1, 2007

Hey there - I have a textbox (C# 1.1 OR 2.0) that I want to take it's contents and post to a datatype of some sort in SQL2k5 and have it preserve the breaks (return keystrokes) so when the data is presented, it can hold a paragraph form. Is this possible?something like this: <asp:TextBox id="txtContent" runat="server" TextMode="MultiLine" Rows="10"></asp:TextBox>Right now, I'm using nvarchar(4000) as the datatype but if I were to type, say 3 paragraphs, the data returned in the datagrid I bind that data to shows only one long string of data. For the time being, I have been puttting HTML formatting tags in the content I'm posting to the DB, but ultimately don't want to have to do that. I don't want to have to use a Text Editor (like FTB or FCKeditor) if necessary because they seem very much involved for the simple need I have which is to preserve paragraph formatting.So, is there another datatype in SQL2k5 that I should be using? Or are there simple code snippets I can utilize that will recognize a carriage return as a </p><p> tag?I'm trying to migrate to 2.0 as much as possible, so any C# code would be greatly appreciated in 2.0!Thanks for your help!iSheahan 

View 1 Replies View Related

How To Preserve Users When Restoring A Database

Jul 20, 2005

Hi,I restored a database 2 months ago. After the restore, I lost all my"users" for that database. It has been a while, so I don't rememberthe detail of what I did.How can I reserve all the users when restoring a database from a file?Did I do something wrong?Thank you in advance,Eddy

View 1 Replies View Related

How Do I Move Data And Preserve Foreign Key Relationships

Feb 21, 2005

How do I move data from one server and append to the same table structure on a second server and preserve the foreign key relationships. In other words TableB.TableA_ID references TableA.ID. The IDENTITY ID numbers themselves will change but they must continue to match up on the destination server the way they did on the source server.

I can do this using procedural programming but that is usually not the way to go.

(btw, this is a cleaned up version of a question I tacked on to another thread)

View 7 Replies View Related

Installing SQLServer2005 But Preserve Current SQLServer2000

Oct 1, 2006

I have a default installation of SQLServer2000 on a host runningWin2003. I want to install SQLServer2005 on the same machine, butpreserve the original SQLServer2000 installation. How do I do this --install into new directory? new directory and named instance? justnew named instance? What stumbling blocks could I run into?

View 2 Replies View Related

Preserve ROWGUID Column During Publication Delete

Apr 30, 2007

Hello,



I am looking to preserve the ROWGUID column that is created automatically when a table is added to a publication as I have noticed that the column is removed and readded (with new values) each time the publication is deleted and recreated. We are planning on using the values in the rowguid column for a non-replication purpose, and don't wish the column to be removed or the values to be reset in the event the 'owning' publication is dropped for whatever reason. I've done some research and have identified the preserve_rowguidcol column of the sysmergearticles table as a candidate for achieving the desired goal. Before moving forward, I wanted to ask for input regarding this. Are there any best practices I've overlooked on this topic? Neither Google nor this forum's search results yield any real discussion on this topic.



Thanks!



DanD

View 7 Replies View Related

SQL Server 2012 :: How To Preserve Tags In Varchar Output

May 6, 2015

I have following XQuery:

declare @xmldoc as xml
select @xmldoc = '<Text>This is firstline<Break />This is second line<Break />This is third line</Text>'
select @xmldoc.value('(/Text)[1]','varchar(max)')Result is: "This is firstlineThis is second lineThis is third line"

My problem is, that the <Break /> tags within the text are removed in the conversion to varchar. How to preserve the such tags in the varchar output? Or to get the <Break /> tags "translated" to e.g. CHAR(10)?

View 2 Replies View Related

Preserve Leading And Trailing White Spaces On Report

Dec 27, 2007

I spent huge amount of time figuring out how to preserve lading and trailing white spaces on report display without success. Can anyone help me here?

My problem is I have data with leading and or trailing white spaces and I need to show it as is. In designer preview it shows correct values. As soon as report is published and accessed on web, it truncates the whitespaces . I had a look at source, it shows values are correctly fetched(with spaces) but are ignored while rendering. I also tried replacing blank space with &nbsp;, however it reads this as &amp;nbsp;.

I am using asp.net 2.0 and SQL serer 2005 reporting services.

View 4 Replies View Related

OPENROWSOURCE Need To Preserve CR/LF While Importing Text File To Varchar(max)

May 14, 2008

I have the following code tha imports the contents of a text file into a varchar(max) field.

Unfortunately the CR/LF are stripped out when I look at the field.

How can I preserve them?





Code Snippet
DECLARE @obj VARCHAR(MAX)
SELECT @obj=BulkColumn
FROM
OPENROWSET(BULK 'C:qsiObjectCreation.sql',SINGLE_CLOB) AS ExternalFile
insert into scriptor (script) values (@obj)

View 2 Replies View Related

Transact SQL :: Preserve And Return NULL For Non Matching Values From A Table Valued Function

Jun 29, 2015

I have tables and a function as representated by the code below. The names  for objects here are just for representation and not the actual names of objects. Table RDTEST may have one or multiple values for RD for each PID. So the function GIVERD will return one or multiple values of RD for each value of PID passed to it.

When I run the following query, I get the required result except the rows for CID 500 for which PID is NULL in table T1. I want the rows for CID 500 as well with PID values as NULL.

SELECT  A.CID, 
A.ANI,
A.PID,
B.RD
FROM T1 AS A CROSS APPLY GIVERD(A.PID) B

CREATE TABLE [DBO].[RDTEST](
[PID] [INT] NULL,
[RD] [INT] NULL
)

[Code] ....

View 4 Replies View Related

Way To Format Query

Oct 22, 2013

I have to fetch some rows within a Crystal report. I need to select

from Orderhist a where
order# a = order# cr
and trncde is in 'pwb' 'pdb' 'pbb'

but i need then that trncde as a report field. also the order# cr is a formula field because its a subscript embedded 8 char within a 24 char. this is already available to the cr but can u do the where = on a formula field?

View 1 Replies View Related

How Can I Use Format As HH:MM:SS From Seconds Within The SQL Query

Nov 8, 2007

I have the following SQL query where i want thease to be populate to GridView, but the Duration field is in Second format, I want it would be in HH:MM:SS format.
cmd = "select subscriber_id as Subscriber_no,,amount,duration from MyTable" ;
Please help me how to format this within the Query to display in GridView.

View 3 Replies View Related

Query Criteria Format

Feb 9, 2004

I have a text box that is used to submit stock symbols that are to be saved in a sql table. The symbols are to be separated by a space or a comma (I don't know which, yet). I want to retrieve the symbols later to be used in a query, but I don't know how to get the symbols in the proper string format for the query, eg

The symbols are stored in the tables as: A B C D
The query string criteria would look like: IN('A', 'B', 'C', 'D')

The IN('A', 'B', 'C', 'D') citeria would be the values in the @Symbol variable in this SPROC

SELECT a_Name_Symbol.Symbol, a_Financials.Revenue
FROM a_Financials INNER JOIN
a_Name_Symbol ON a_Financials.Symbol = a_Name_Symbol.Symbol
WHERE (a_Name_Symbol.Symbol @Symbol)
ORDER BY a_Name_Symbol.Symbol

Is there a slick (ie easy) way to change the contents entered in the text box (A B C D) into IN('A', 'B', 'C', 'D') ?

Thanks,

Paul

View 1 Replies View Related

Query Regarding Date Format

Jul 20, 2005

select last_name,hire_date,to_char(hire_date,'DAY') DAYfrom employeesorder by to_char(hire_date-1,'d')i wanted to know how the function to_char(hire_date-1,'d') works...its basically a query used to find the day on which a employee washired ,also it requires that the query be sorted by the day of theweek on which the employee was hired.it'll be helpful is someone replies to this

View 2 Replies View Related

Query Format Date

Sep 10, 2007


Hi
I wrote query to get date from database SQL 2000 server. Sometime I get different date format not MMDDYYYY but number as Julian calendar?? Do you know what wrong with this? How can I wrote SQL so that all date will be MMDDYYYY?
Thanks
Daniel

View 1 Replies View Related

Is It Possible To Restore A Database But Preserve The Security Of The Database?

Apr 26, 2007

i have a development database that has updates and changes to a production database. rather than go through individually and alter all relevant tables and stored procedures, id like to back up the database on the development side and restore it on the production side as the production database. is there a way to restore the database on the production server but preserve all the security settings (ie logins and such)? i noticed on our development server, that if i try to restore the database with my development database, it overwrites the users and/or if the user is the same on both, it removes the login name for that user.

View 3 Replies View Related

View The SQL Query Out-put In Horizontal Format.

Jan 10, 2005

I have the following SQL query that I like to view the out put in horizontal format:

Select ID, First_name, Last_name from ABC

Instead of getting out-put like

Id First_name Last_name
1Jim Smith
2Tom Jones

I like to see the out-put like:

Id1 2
First_nameJimSmith
Last_nameTomJones

Please advice.

Thanks in advance,


Abrahim

View 1 Replies View Related

Convert Smalldatetime To Mmm Yy Format In Query

Jan 7, 2004

I am trying to write a simple query that retrieves the data field from a table (stored in the smalldatetime format) and converts the date to mmm yy format. The closest I can get is retrieving the date in the dd mmm yy format using the query below.

select convert(varchar(10),DATA_DATE,06) As DATA_DATE

If there an easy way to parse out the information I want? I also attempted to use the SUBSTR functions, but they always returned error messages.

View 3 Replies View Related

SQL Vs Access Date Query Format

Mar 7, 2004

I am new to SQL server, and am learning as I move an Access db to MSDE2000A. With Access db I run several different queries from a VB6 application in the basic format:

SELECT testdb.*
FROM testdb
WHERE testdb.datefield = #1/01/2004#

When working with the MDSE version of the db, problem is with the "#" delimiter of dates. MSDE is giving a bad query error. If I change the format to: datefield = '1/01/2004' , the query works on MSDE

However, using SQL builder in VB Design Environment I can run the query in either format and get a result.

Any suggests what I am missing? Thanks.

View 2 Replies View Related

Sql Query To Get A Desired Format Of Display

May 23, 2008

Hi Guys,

Below is example of the current structure of table1 I have at run time:

------------------------
GroupName Resourcename Week1 Week2 ..cont.. dynamically

Associates A1 0 80 ......
Assocaites A2 20 40 ......
Associates A3 50 100 ......
Principal P1 20 100 ......
Principal P2 0 0 ......
Principal P3 0 100 ......
------------------------
I want to change the above to something like below table2:
---------------------------
GroupName Status Week1 Week2 ....cont

Associates Assigned 2 3
Associates NotAssigned 1 0
Principal Assigned 1 1
Principal NotAssigned 2 1
---------------------------

I will try to explain how I am deriving table2 from table1. I have to count the number of Resource name against each Groupname for a particular week column(Weeki i 1 to n dynamic) where value of Week column is 0, then use this numbber against NotAssigned and the complementary number to be stored as Assigned.

The table formaating is lost in HTML view but just consider any gaps between fields as next column value.

Am I clear in what i am asking , if not please ask me.

Any help will be highly appreciated.

View 2 Replies View Related

Changing The Format For A SQL Server Query

Apr 3, 2006

Hi,

I have to generate a daily report of survey answers by users? My question is there a way to reformat the query so it generates a table or report with it showing the rows as columns instead.

Here is my initial query.

SELECT

dbo.Reporting_SurveyAnswers.DateCreated AS DateCreated

,dbo.Reporting_SurveyAnswers.questionid AS QuestionID

,dbo.Reporting_SurveyAnswers.surveyid AS SurveyID

,dbo.Reporting_SurveyQuestions.ordernumber AS OrderNumber

,dbo.Reporting_SurveyAnswers.userid AS UserID

,dbo.Reporting_User.LastName1 AS LastName

,dbo.Reporting_User.FirstName AS FirstName

,dbo.Reporting_SurveyQuestions.QuestionText AS QuestionText

,dbo.Reporting_SurveyAnswers.QuestionAnswer AS QuestionAnswer


FROM

dbo.Reporting_Surveys

INNER JOIN dbo.Reporting_SurveyQuestions

ON dbo.Reporting_Surveys.surveyid = dbo.Reporting_SurveyQuestions.surveyid

INNER JOIN dbo.Reporting_SurveyAnswers

ON dbo.Reporting_SurveyQuestions.QuestionID = dbo.Reporting_SurveyAnswers.QuestionID

INNER JOIN dbo.uvwReporting_User

ON dbo.Reporting_SurveyAnswers.userid = dbo.uvReporting_User.userid

WHERE

dbo.uvReporting_SurveyAnswers.surveyid = 1125

Order by dbo.Reporting_SurveyAnswers.DateCreated

,dbo.Reporting_SurveyQuestions.ordernumber

Select

dbo.Reporting_SurveyQuestions.ordernumber AS OrderNumber

, dbo dbo.Reporting_SurveyQuestions.QuestionText AS QuestionText

To complicate matters, some of the users did not answer some of the questions and some of the questions are duplicated in the rows because the database assigned them one answer each.

Example. Question 18 says "Name all the industries you have worked in. Check all that apply.

What happens is lets say the user checks 4 different boxes. In the query results, it will show 4 rows with question 18 with each answer they checked off.

Any help would be appreciated.

Thanks

The Accidental Tourist

View 3 Replies View Related

Data Format Consistency Or Query?

Oct 2, 2006

Hi

I have a table that stores the period and year as two seperate fields the problem that i have is that when the data is entered in the data base the period is sometime entered as 6 or 06, hence i have a table thaat looks like as follows:


Period Year
====== ====
6 2006
06 2005
12 2006
3 2005
2 2005
4 2005
04 2005
03 2005



when i currently query the information using the period i use the LIKE command in SQL which gives me the results but the problem is when the like is done with 2 as the period value it also retrieves the 12, 02, and 2, in that case the period 12 was not that was requested.

I was wondering is there a way to reformat the data so that all the data is in a consistent format?

Or is there a better way of quering the information in the current format?

View 13 Replies View Related

SQL Server Date Format Query

Aug 16, 2007

Dear All,

I'm having a query problem regarding to the date format. From a table, there's a record of patients' birthdate.

In order to identify their age, how should i perform the query?

Select * from patient where BirthDate.Year < 1950

I've tried the above query where i want to extract patients' records who born before 1950, however, it generates error. Can somebody help?

M i K e

View 7 Replies View Related

Query Analyzer Vs Isqlw Different Format

Jul 23, 2005

HelloI have a SQL 2000 server, the server setting is default language :French and all Collation names in FrenchIf i launch the 'Query Analyzer' from the SQL Entreprise Manager on mydatabase, and run a T-SQL my dates are in English.If i do a : DBCC USEROPTIONS, my results arelanguageus_englishdateformatmdyNow if i launch 'Query Analyzer' from the startup menu, my date formatis ok in French, if i do DBCC USEROPTIONS, results are:languageFrançaisdateformatdmyIn the Query Analyzer i checked the option in Tools>Options>Connections(Use regional settings is unchecked) and they are the same in both case.How can i resolve my problem ?Thanks

View 1 Replies View Related

How Can I Format The Date In The SQL Table Using A SQL Query

Aug 23, 2006

Hi

I have a SQL table that contains date in this format :-


2006-07-02 16:20:01.000
2006-07-02 16:21:00.000
2006-07-02 16:21:01.000
2006-07-02 16:22:00.000
2006-07-02 16:22:02.000
2006-07-02 16:23:00.000
 

The date above contains seconds that I dont want, how can I remove those seconds so that the output looks like :-



2006-07-02 16:20:00.000
2006-07-02 16:21:00.000
2006-07-02 16:21:00.000
2006-07-02 16:22:00.000
2006-07-02 16:22:00.000
2006-07-02 16:23:00.000
 

Your help will be highly appreciated.

View 9 Replies View Related

Changing The Number Format In SQL Query

Jan 30, 2008

Hi


I have query

SELECT col1, a.Inv_Amount as Amount
FROM SPS_Oustandings a

I can get the result values for example as 12345.67 as result, but i need it in german format with , used as decimal point and . as thousand seperator

i need output as 12.345,67
My DataGrid (ASP.NET) is directly bound to SP which have this query, i want to show amount in above format in grid.

Please Help,
Thanks

View 6 Replies View Related







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