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.
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.
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.)
[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
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)
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?
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
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
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)
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?
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.
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)?
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 , however it reads this as &nbsp;.
I am using asp.net 2.0 and SQL serer 2005 reporting services.
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)
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
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?
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.
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') ?
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
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
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.
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.
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.
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.
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.
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?
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