I have a Access database which has a address field with multiple data sets in it. I am new to writing code and am having trouble finding a example which will help me split these values out into three seperate fields.
Notice how there is no good order in how they are placed.... Some entry's have commas and some don't. Some have periods and some don't.
EX:
[BILL_ADDR3]
AMHERST, WI. 54406
ASHLAND, WI 54806
ASKOV MN 55704
I then need to convert the state to a state code ie:
2 AK
3 AL
4 AR
5 CA
6 CO
7 CT
8 DC
9 DE
10 FL
11 GA
12 HI
13 IA
14 ID
15 IL
16 IN
17 KS
18 KY
Any good sources of information would be greatly appreciated..... Thank You
One of the primary parts of my job is working with the SQL database of our Enterprise ERP software. One of my primary responsibilities is writing reports based on it's data and since it is not well documented and this is one of my biggest challenges. To top it all off, it's hard to even use their reports to learn the links between tables as the reports run completely in Visual Foxpro.
Is there reasonably priced software that will analyze the database for me and make it easier for me to figure out the relationships between certain tables and such?
I am new to Microsoft SQL and have been dumped right into the deep end with an anchor around my ankles.
The problem I am experiencing is about 6 months back a guy setup a Microsoft SQL server at my client. He then took his bags and left. Then a developer developed an application which uses a database on this sql server. Everything worked well for around 4 months.
Yesterday IBM Director notified me that I am running dangerously low on disk space on the server. By the time I came in to work this morning I had 12mb free disk space. The evil thing here is the transaction log for the downtime database. It has grown to over 60gb, all because the correct measures were not implemented to prevent this.
The problem that is occuring is no one can do anything on the database now due to the lack of free space. I have tried reading the sql books online but due to my lack of sql experience and knowledge I am stuck.
Can someone please help me? What I would like to do is pull my transaction log down to an acceptable size.
I was thinking of creating a new database and then importing all the data from the current database and then just deleting the current database however am slightly concerned that this may result in some data being lost.
I've registered with GoDaddy for my site. I've used Visual Web Dev 2005 with SQL Server Mgmt Express 2005 to create my database etc. Now with GoDaddy, I need to "recreate" the database on their server again, but I don't want to go throug the whole process again. I just want to use their query editor to generate the database online.GoDaddy mentions a "personal-sql" file that SQL Server 2000 generates, but I can't find anything like that with what I have. Thanks.
I'm running the same query on two computers but getting a different query plan. On one of the servers, the query returns in 10 seconds, on the other server it takes over a minute. What the heck!
1. same hardware configuration on both computers 2. same user databases on both computers 3. same NT setup on both computers 4. same software installed on both computers
I can only imagine that MSSQL7 was setup differently and the query optimizer is making a stupid choice. I've compared numerous SQL server options and they are both the same.
1. sp_configure (same on both computers) 2. properties sheet on each server from enterprise manager (same on both computers)
I'm working with a database that is poorly normalized and am doing my best to increase the speed of our queries (changing the database itself is not an option right now). Any help with the following situation would be very much appreciated.
In the DataTable, the columns named ColA, ColB, ColC, etc., are described in the NameTable where Abbr would be A, B, C, etc., and FullName would be a "nice" text version describing what's stored in that column. For instance, a record in the NameTable might include Abbr = 'A' and FullName = 'Computer Science', and that means that ColA in the DataTable refers to 'ComputerScience'.
The table I'm trying to optimize the creation of in our ASP.NET application needs to have column headings that could be retrieved like this: SELECT DISTINCT CodeB, CodeC FROM DataTable WHERE CodeA = @CodeA (Note that CodeC is really just a different representation of CodeB--think 4-digit year vs. 2-digit year--for any given CodeA.)
The row headings for the table could be retrieved like this: SELECT FullName FROM NameTable
The cells of the table at any given intersection of a row heading and a column heading can be retrieved like this: SELECT Col? FROM DataTable WHERE CodeA = @CodeA AND CodeB = @CodeB (this selects a single value) Where the ? of Col? is determined by the Abbr version of FullName shown in the row heading, and @CodeB is determined by CodeB from the column heading.
Right now this table is generated using a lot of loops in the code of the page that require it to query the database for nearly every cell in the table. Even with this poor database design, there has to be a better way than that. I'm hoping there is a way to create a stored procedure that uses temporary tables and joins, or views, or something like that to create the table on the SQL Server and just send the data to the ASP.NET page in a form that can be directly databound to a GridView.
I am new to SQL Server 2005. I have tried to be a good student and learn on my own about designing the database. However, I am facing a blockage of getting data into the database. I want to verify I have setup the relationships correctly. Here is the tables.
1. A Manufacture has an Address. 2. A Manufacturer has one or more Distribution Points. 3. A Distribution Point has an Address.
The Manufacturer --> Address is a one-to-one relationship. The Distribution Point --> Address is a one-to-one relationship. The Manufacturer --> Distribution Point is a one-to-many relationship.
The manufacturer table has a FK to the address id (PK). The distribution table has a FK to the address id (PK). The distribution table has a FK to the Manufacturer id (PK). Address has several other FK, but not used in this scenario.
The INSERT and UPDATE Specification for the Delete Rule and Update Rule is set to "No Action" for the Manufacturer and Address tables. In the Distribution Point table, the relationship for the update rule involving the relationship with the Address and Manufacturer tables is set to CASCADE. What this tells me is SQL Server 2005 will update the table should changes occur in Address and Manufacturer table.
Is there anything else I can check to be sure the issue I am facing is NOT the deisgn of the database?
Everyone thinks that CSVs are awesome to transport data. I mean after all, SSIS defaults to Comma Delimited files. Even Excel defaults to it. Microsoft is supposed to be our leader! They should get this right. And get the terminology correct too. How many people describe the file as comma separated? It's delimited! Even SQL server calls it delimited by the "delimited" drop down.
CSVs suck and i will tell you why:
When you transport any text field (especially Address) it has the possibility of containing a comma. This causes data to be parsed into the wrong fields. Why in God's grace would you EVER get in the habit of choosing a delimiter that SOMETIMES doesn't work?
I'll tell you a little short story:
I have been waiting (at work) for like a month for a guy to export data and give me this file. Well today i finally got that file. He was in a hurry and used the Defaults to export this file. I don't blame him for being in a hurry and using the defaults. Well the defaults made the import NOT work because the data parsed into the wrong columns. Comma delimited would work if there was a text qualifier. But the default is comma delimited and NO text qualifier. What idiot thought that would be good. Or it was the separation of duties that eff'd this one up? Who knows?
I am working on an application with a number of tables (which I can't change) that have data of the form a1, b1, c1... a2, b2, c2...a3, b3, c3... The tables contain 5 to 10 sets of data in each row.
I want to create a stored procedure to return a cursor with a row for each set of data for a row of the table. I know I can use unions:
select a1 as a, b1 as b , c1 as c... from sometable where pk=@pk
union
select a2, b2, c2... from sometable where pk=@pk
union
select a3...
Is there a way that is more efficient (eliminates requerying the table and all the unions)?
I have built the reports that I need using Visual Studio and the SQL 2005 Reporting Server, but now I need a way to view the reports via a web browser.
I am not much of a web/programming expert, so any help that could walk me through the process of publishing the .rdl files that I have created via a web browser would be much, much appreciated. Again, I am a novice in the the web arena, so the more straight forward the steps the better.
Hi folks, I'm trying to collapse a column on a report that's designed in table mode. I was trying to mimick what happens in a matrix where you have a column that has a '+' in it that makes toggles the visibility of a column to its immediate right (The reason I'm not using Matrix mode is I continually get "out of memory" errors on the report I'm generating.).
When I select the column and mark visible to 'false' in the properties, it of course asks me for a TextBox. My problem is that I am unable to find a scenario where the textbox is "in the proper group". Is this something that's supported, and if so, I'd appreciate some pointers to lead me in the right direction.
Hi everyone. I am having difficulties with a cursor that I am trying to write. The purpose of the cursor is to loop through all tables in a selected Database and revoke "Select" access to that table for the indicated role (RoleToRevoke). I am getting the error on the @name variable within the REVOKE statement. I have placed a comment indicating where I am getting the error. Is there a way to have sql server interpret this @name variable within the REVOKE statement? Thanks for your help.
Code Snippet
USE [Database_Name];
Declare cursorExample Cursor for Select TABLE_NAME from information_schema.tables Where TABLE_TYPE='Base Table' and TABLE_SCHEMA='dbo'
Declare @name as varchar(255) Declare @ErrorSave as int Declare @ErrorCount as int
Open cursorExample
Fetch Next from cursorExample into @name
SET @ErrorSave = 0 SET @ErrorCount = 0
Begin Tran
While @@Fetch_Status=0
Begin
--Getting Error on Line below on @name REVOKE SELECT ON OBJECT::@name FROM RoletoRevoke;
IF (@@ERROR <> 0)
BEGIN
Print 'Error Revoking Access to Table: ' + CAST(@name AS varchar(75)) SELECT @ErrorCount = @ErrorCount + 1 END IF (@@ERROR = 0)
BEGIN
Print 'Successful Revoking Select Rights on Table: ' + CAST(@name AS varchar(75))
SELECT @ErrorSave = @ErrorSave + 1 END Fetch Next from cursorExample into @name
End
IF @ErrorCount = 0
BEGIN
COMMIT TRAN PRINT 'COMMITTED TRANSACTION' PRINT 'Total Tables Affected:' + CAST(@ErrorSave AS varchar(75)) END ELSE
In Past, I created DTS package on 2000 version, that import TXT file into SQL 2000 table.
Now I migrated the DTS to DTSX (SSIS) package, and all is working fine. but I can not find how can I edit or modify the target table name in DTSX(SSIS) package in BI Studio.
I'm developing a database-driven program using SQL server 2000 and Visual Basic 2005.
Most of the guys say professional programming is doing the validation stuff (such as the constraints and data integrity stuff like" [0-9][1] " and the use of LIKE IN keywords etc.) in the databse itself.
say i did the data validation contraints in SQL server itself. and now i connect the database with the interface made in 2005. and say a person enters some invalid data through the interface. but the error messages are generated by SQL server. how am i to display the SQL server generated error messages in the VB made interface??
PLS HELP ME .. if the question is not clear pls tell so that i can explain it further.
I'm developing a database-driven program using SQL server 2000 and Visual Basic 2005.
Most of the guys say professional programming is doing the validation stuff (such as the constraints and data integrity stuff like" [0-9][1] " and the use of LIKE IN keywords etc.) in the databse itself.
say i did the data validation contraints in SQL server itself. and now i connect the database with the interface made in 2005. and say a person enters some invalid data through the interface. but the error messages are generated by SQL server. how am i to display the SQL server generated error messages in the VB made interface??
PLS HELP ME .. if the question is not clear pls tell so that i can explain it further.
I have used backup and restore method to upgrage 2000 databases to 2005 database. What do i need to do in order to for my application or users to use databse in 2005 and remove 2000
Hi I want to transfer a database from one PC to another. (Both running SQL Server 2005 express) I have copied the files (SQL Server Database Primary Data File and SQL Server Database Transaction Log File) from the C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLData folder of the source PC to the destination PC (Same folder). I was under the impression that using Microsoft SQL Server 2005 - SQL Server Management Studio Express these files would be picked up and could be used, do I infact need to do something to attach the files/database so that they will appear in SQL Server management?
I have an SQL database running on an old server and i am upgrading the server, but i am having some problems moving my SQL database over. Has any one got a work through they could mail me to give me a hand!!
I'm very new to SQL Server 2005, so please be kind.We had a vendor in and they loaded their software and the databasethat was created is sittingon the root (c:) drive. On this server we have another drive wherethe database should reside, isthere a way to move this database to the correct drive? Thank you forany help that you couldprovide.Dave Schaeffer
I have two computers, both with SQL Express 2005 and SQL Server Management Studio Express. I created a database on one computer, and need to copy it to the other computer. I'd like to do it all through the Management Studio interface, without using SQL commands, since I only need to do this manually.
I detached the two files, copied them to the second computer, and tried to attach them. This is generating lots of messages about not having the necessary permissions of various sorts. I think the main problem is that I don't know how to set up the database's users in a way that allows the second computer to attach the database.
I've tried Windows authentication, using a Windows user that has the same name and password on both computers, and I've defined that Windows user as a user within the database. I've connected to SQL when logged in as that user. I've tried SQL authentication also, defining the same SQL user within both SQL Servers, as db_owner. But when I try to attach the database, I see no place to specify the user that I intend it to use, and it still fails. If I connect to SQL as that user, then SQL doesn't have permission to look at the file system to find the MDF file.
I'd appreciate the help in learning how to do this with both Windows authentication and SQL authentication, via the Management Studio's GUI. Most of the documentation I've seen covers how to do it by using SQL language commands, and I'd like to avoid that.
Hi all, I have an Ms Access table and a MsSql table. I am running a windows service in my localhost where the data from Ms access table will be copied to Ms sql table for every one minute. Before copying the data, the Ms sql table will be flushed inorder to avoid replicates. Now i want to copy only the latest records updated within 1 min in Ms access table, to Ms sql table. My Ms access table Name Id jas 100 meena 101 viji 102
My Ms sql table Name Id jas 100 meena 101 viji 102
After 1 min, say 2 records are added to my Ms access table like, Name Id jas 100 meena 101 viji 102 bhuvana 103 pinky 104 Now i want to insert only the latest records from Ms access to Ms sql like, Name Id jas 100 meena 101 viji 102 bhuvana 103 pinky 104 how to do this? thanx in advance. Jasmeeta.
I have a SQL Server 2005 Express database on my local machince called OpenAssess.mdf. The server we host with has a file extension of .mdb. How can I go about getting my database to the server? I tried changing the extension to mdb on the local machine but then it tried opening the database in MS Access and didn't work. I just need to connect to the database in my web pages. Here is my connection string and then the error which is visible at the botton of openassessment.org. *********************************************connection string************************************************* OPEN_Conn = "Provider=SQLOLEDB;Data Source=connectionToHostServer;Network Library=DBMSSOCN;Initial Catalog=OpenAssess.mdb;User ID=myuserid;Password=mypassword" *****************************************************error********************************************************* Microsoft OLE DB Provider for SQL Server error '80004005' Cannot open database requested in login 'OpenAssess.mdb'. Login fails.
On 11/10/01 I posted a question on how to move passwords from one sql2000 box to another. The response to this question worked perfectly.
I also need to copy over the user or database access information from one box to another. I tried to use dts but it only copied over the users and the database roles but did not copy over the Database user properties which allows the user access and places the user into security groups.
I want to move my tempdb database to another drive by moving the mdf and ldf files . Is it possible to shift the tempdb once it is created ? I am shifting the database since there is no space on the current drive and the database might grow in the near furure .
I have a machine where the SQL "data" directory was installed on the smaller drive instead of the larger drive. What do I have to do to move the existing databases? (Backup/restore, or detach - move it physically, then attach?)
How can I move the Model database to another location (i.e. from one drive / file location to another)?
I tried sp_detach_db (to be followed up with a sp_attach_db statement) but it rejected it because Model is a "system" database. I tried (and it failed with a "Modify file command failed" message): ALTER DATABASE model modify file (NAME='modeldev',FILENAME='f:MSSQL7DATAmodel.MDF')
I could not locate any help about moving model in books online (BOL). Any ideas?
i got few questions. i need to move a databases from old server to new server. old server has 25 user databases total datafile around 300GB. heres the questions.
1. what is the fastest way to move all the data to new server? and what's the best way to do it? (DTS? MDF copy over/attach? bak copy over/restore? other theres other way?)
2. i got alot of job and user need to transfer over. i know DTS can do the user.. how about the jobs?
3. do i need to move the master and msdb over too?
4. beside all 3 questions above... do i miss anything that need to be move too?
Hi, I have a database that resides on a server that`s become too old. It spans 2 devices that sit on 2 different drive letters - D: and E:. I bought a new server, installed and configured NT4.0 and SQL6.5. Initially I restored the database to the new server from a dump .It worked fine, however all the login information was lost. Then I tried partitioning the new server the same way as the old one and copying all the DAT files over. Thus I was hoping to retain the information contained in the MASTER.DAT, drop the database, repartition to create 1 physical drivewith 1 database device, and restore from a dump to it. After copying the DATs, though, SQL Server would not start. Help Please!