Tuesday, August 27, 2013

[SQL Server 2008 issues] Assist me the merge statement performance in sql server..

[SQL Server 2008 issues] Assist me the merge statement performance in sql server..


Assist me the merge statement performance in sql server..

Posted: 26 Aug 2013 01:30 AM PDT

Hi Everybody,Im using following query, is there any other alternative way? MERGE DistinctData AS TARGETUSING DataTable AS SOURCE ON (TARGET.msisdn = SOURCE.Charged_party_number)WHEN NOT MATCHED BY TARGET THEN INSERT (msisdn) VALUES (SOURCE.Charged_party_number);Assist me the merge statement performance in sql server..

Display last label value on x axis always

Posted: 26 Aug 2013 08:55 AM PDT

I dont want to display each and every value on xaxis, i want to set interval to 'auto' but want to Display last label value on x axis always

Change SQL Data Root Directory

Posted: 26 Aug 2013 01:33 PM PDT

I am hoping there is a way to change the "data root directory" after a SQL 2008R2 install. I gave someone the wrong drive information during the install and they have already completed a bunch of servers and installed service packs.It will take them the entire day to re-install what they have setup so far, so I'm trying to offer some help.I would like to know how critical this mistake is.Will losing the drive that we have setup as the data root directory make SQL Server not function anymore?http://social.msdn.microsoft.com/Forums/sqlserver/en-US/98b97adb-80e9-42e2-8099-cc17dd985b9f/how-to-change-default-database-root-directory-I found the link above, has anyone tried this to see if it works? Is there a way to re install without re installing service packs? Hope someone can throw me some idea's as a scour the internet. Thanks....

Stress Test Tool - SQL Server 2008R2 - Possibly freeware ?

Posted: 26 Aug 2013 07:55 AM PDT

My goal is to run a script in multiple concurrent sessions on the same db, today i can do that in a not-so neat way using while loop. I was wondering if there a tool which will just take my script as a input and just throw the execution timings in a table or somewhere?

Track username and time of action on delete for rows

Posted: 26 Aug 2013 05:53 AM PDT

I've been trying on this one for a while. I implemented change data capture, but I found interpreting some of the columns difficult (even after reading through several articles online). Since I only need to track deletes on one or two tables, I decided to try an on delete sql trigger. Well, I'm having a hard time with this one too. Here is what I would like to capture:1. The row that was deleted2. When the row was deleted3. What user deleted the rowHere is some sample data for anyone that can lend a hand. Thanks for any help!CREATE TABLE #attend(attendID int,lname varchar(100),fname varchar(100));INSERT INTO #attend (attendID, lname, fname)VALUES (1, 'Smith', 'Joe'), (2, 'Black', 'Sam'), (3, 'Williams', 'Ralph');EDIT: I guess I should note that specifically I'm having a hard time with capturing which user did the deleting.

Google Analytics SQL Import

Posted: 08 May 2012 09:07 PM PDT

Hi AllI was just wondering if anyone has ever done a Google Analytics import to SQL via SSIS?A quick google brought up some C# scripts, a PHP web scraper and using the java client to export to CSV and then import it, but was wondering if anyone has managed to query the API and load it direct in SSIS to the DB?This was a task which was done a couple of years ago and I have been asked to re-ignite the flame to get it moving again and the previous way was to use xp_cmdshell to execute a file which loads it to CSV and imports it, which I have no trouble with, just wondering if anyone has a better solution.Thanks

Linked Server weirdness to Sybase

Posted: 26 Jul 2011 07:08 AM PDT

This is for a linked server on SQL 2008 R2.Here are the facts:SQL 2008 R2 on Microsoft Windows Server 2003 R2 (SP2)I created a Sybase Linked server and it works fine for me. When one of the developers try to use it, SELECT * FROM OPENQUERY(mylinkedserver, 'select * from table1'), he gets this message: Cannot create an instance of OLE DB provider "ASEOLEDB" for linked server "mylinkedserver".The developer AD login is also setup as a sysadmin on the sql server instance.The developer has no problems using an Oracle linked serverWhen I make the developer an administrator to the server itself, the linked server works for him.Any ideas why? We cannot make the developer an admin to the server itself so we took him out of the "Administrators" group and the linked server no longer works.Edit: Here's the script to create the linked server. Names, Dates, Ports, Places, and other stuff have been change to protect the innocent.[code="sql"]EXEC master.dbo.sp_addlinkedserver @server = N'mylinkedserver', @srvproduct=N'Sybase', @provider=N'ASEOLEDB', @datasrc=N'sybaseServer,8888'EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'mylinkedserver',@useself=N'False',@locallogin=NULL,@rmtuser=N'username',@rmtpassword='########'GOEXEC master.dbo.sp_serveroption @server=N'mylinkedserver', @optname=N'collation compatible', @optvalue=N'false'GOEXEC master.dbo.sp_serveroption @server=N'mylinkedserver', @optname=N'data access', @optvalue=N'true'GOEXEC master.dbo.sp_serveroption @server=N'mylinkedserver', @optname=N'dist', @optvalue=N'false'GOEXEC master.dbo.sp_serveroption @server=N'mylinkedserver', @optname=N'pub', @optvalue=N'false'GOEXEC master.dbo.sp_serveroption @server=N'mylinkedserver', @optname=N'rpc', @optvalue=N'false'GOEXEC master.dbo.sp_serveroption @server=N'mylinkedserver', @optname=N'rpc out', @optvalue=N'false'GOEXEC master.dbo.sp_serveroption @server=N'mylinkedserver', @optname=N'sub', @optvalue=N'false'GOEXEC master.dbo.sp_serveroption @server=N'mylinkedserver', @optname=N'connect timeout', @optvalue=N'0'GOEXEC master.dbo.sp_serveroption @server=N'mylinkedserver', @optname=N'collation name', @optvalue=nullGOEXEC master.dbo.sp_serveroption @server=N'mylinkedserver', @optname=N'lazy schema validation', @optvalue=N'false'GOEXEC master.dbo.sp_serveroption @server=N'mylinkedserver', @optname=N'query timeout', @optvalue=N'0'GOEXEC master.dbo.sp_serveroption @server=N'mylinkedserver', @optname=N'use remote collation', @optvalue=N'true'GOEXEC master.dbo.sp_serveroption @server=N'mylinkedserver', @optname=N'remote proc transaction promotion', @optvalue=N'true'GO[/code]

Client Error "[DBNETLIB][ConnetionWrite (WrapperWrite()).]General network error. Check your network documentation."

Posted: 26 Aug 2013 06:07 AM PDT

Small Network, 1 DC which runs Server 2008 Std and SWL Express 2008 with 10 Workstations all running XP Pro SP3. We run a Dispatch Application that is SQL based on the DC and 4 of the Workstations runn a Dispatch Client app that communicates with teh Server App. 1 Workstation with the Client (mine by chance) has no problems at all. The other 3 periodically get this error: "[DBNETLIB][ConnetionWrite (WrapperWrite()).]General network error. Check your network documentation." I have further tracked this down to being some sort of inactivity or loss of connection error. If you have the Client App open for quite a while during the day, but don't use it (sitting minimized on the Taskbar, then when you pull it up and do any action, it gives this error and shits the Client down forcing you to relaunch it. I have researched this for days and can not come up with a fix. I have found a way to duplicate the error immediately and that is to have the Client up, unplug the Network Connection from the PC and wait until the Icon shows no connection then pkug it back in and wait until the connection shows good again. The very first action done in the App after this causes the error and the Client shuts down. This wull duplicate it on the 3 machines getting the error, but NOT on mine. Nothing I have tried will cause mine to fail....yet. Any one know hot to fix this???

Drive mapping Between VM and Local Desktop -Tricky Issue to work around.

Posted: 26 Aug 2013 03:10 AM PDT

Our company has VM's that users access by remote access (RDP). This solution, even though the number of connections is limited, has been fine for many years. Now that the company has grown this presents a problem. I want developers to Test a Developer SSIS packages on their local desktops; however, if they create a connection to a flat file, they'll have to change the connection once they move it back to the VM since the paths to the flat files will change.Example: I have a package I'll call "MoveData" that pulls flat files from a drive mapped as F: with the folder of "LOAD" this "F:\Load" is where the package gets it's flat files. We have literally hundreds of packages with multiple connections like this. Since there are limited connections to this VM (3 I think), I want developers to put the packages together on their local desktops; however, the path to the Flat will will be different.Any way I can either set up a standardized drive mapping on the developer's computer that matches the UNC path on the VM, Or bulk Change all the Flat File mappings once the package is migrated back to the VM?I can't change the VM. WAY too much effort involved.ThanksCrusty.

Failure to calculate super-latch promotion threshold

Posted: 18 Sep 2012 12:26 AM PDT

I saw this error message in the error log of one of my SQL Server 2008 R2 servers today (with SP2 installed, v10.50.4000).[b]"Warning: Failure to calculate super-latch promotion threshold."[/b]I've never seen that message, can't find anything online about it, and don't know what the impact is.The only other relevant information I can give is that there was a series of DBCC CHECKDB commands occurring at the time (our nightly database checks).Any additional information would be appreciated.Thanks,John

How do you know how much RAM you need?

Posted: 26 Aug 2013 04:21 AM PDT

Running the System Diagnostics Report (a Performance Monitor built in report) on a Windows Server 2008 R2 running SQL Server 2008 shows "The system is experiencing excessive paging" each monring for a few hours. This time frame is when we are doing a database 'load' from a different database (not MSSQL).The server has 16 GB RAM and is capable of 64 GB. There are other servers that may be available that can have a lot more RAM (like 384 GB).How do you know how much RAM is needed to avoid performance issues?

Procedure Cache and Data Cache

Posted: 25 Aug 2013 11:37 PM PDT

What is Plan Cache and Procedure Cache and Data Cache?Why these are used for ?

Monday, August 26, 2013

[how to] mysql.sock missing

[how to] mysql.sock missing


mysql.sock missing

Posted: 26 Aug 2013 06:52 PM PDT

I started my MYSQL database this morning but failed. And I tried all means I can think of:

chown -R mysql.mysql /var/lib/mysql  chmod g+w /var/run/mysqld  chgrp mysql /var/run/mysqld  chmod -R 755 /var/lib/mysql/  service mysqld stop; mysqld_safe --user=mysql &  

but the file is still not there (/var/lib/mysql/mysql.sock). I checked the file /var/log/mysqld.log, it says:

130827 07:49:25 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql  130827  7:49:26  InnoDB: Initializing buffer pool, size = 8.0M  130827  7:49:26  InnoDB: Completed initialization of buffer pool  130827  7:49:26  InnoDB: Started; log sequence number 0 44233  130827  7:49:26 [ERROR] /usr/libexec/mysqld: unknown option '--qviheadfv<F4><F4>--bdcvadsfefa'  130827  7:49:26 [ERROR] Aborting    130827  7:49:26  InnoDB: Starting shutdown...  130827  7:49:31  InnoDB: Shutdown completed; log sequence number 0 44233  130827  7:49:31 [Note] /usr/libexec/mysqld: Shutdown complete    130827 07:49:31 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended  

I got totally lost. What is the option '--qviheadfv--bdcvadsfefa'? Any suggestion?

Oracle 12c: Invalid username/password while logging in via sqlplus

Posted: 26 Aug 2013 05:32 PM PDT

I got a version of Oracle 12c installed, I setup the $ORACLE_HOME and $ORACLE_SID to the proper value.

When connecting to the database with sqlplus:

sqlplus /nolog  connect / as sysdba  

I got the following error:

ERROR: ORA-01017: invalid username/password; logon denied

I didn't got a chance to setup password during oui installation, for both sys and system. In this case, how can I login to the database?

MySQL Performance Issues

Posted: 26 Aug 2013 06:33 PM PDT

Over the past 3 weeks we have been having bottle-necking issues at our MySQL server. I have been using MonYOG to watch the processlist in an attempt to get a grasp on the issues. We are aware that some of the queries and processes we are running in our code is less than optimized, but I am not completely convinced that is the main source of our issues. I feel our server should be able to overcome these issues.

Our tables are a mix of innodb and myISAM. I am by no means a DBA and do not pretend to be one so I am not sure what engine is the best in our current environment. We are pretty read heavy, but mix in a great deal of updates and inserts as well. I was seeing a lot of locked tables which made me think innodb might be better since it does row lock instead of table lock. I converted a few of our tables from MyISAM over to innodb to take advantage of some of the settings that are available. The developers are using a great deal of complex joins as well.

Here is what we are running in our my.cnf:

  [mysqld]  datadir=/var/lib/mysql  port=3306  socket=/var/lib/mysql/mysql.sock  user=mysql    key_buffer_size=512M    innodb_file_per_table  innodb_buffer_pool_size=6GB  #the following line is causing some odd errors when doing db dump  #innodb_log_file_size=128M  innodb_log_buffer_size=8M  innodb_additional_mem_pool_size=32M    max_allowed_packet=16M  join_buffer_size=8M  sort_buffer_size=8M  max_connections=500  wait_timeout=500  skip-name-resolve  thread_cache=256  table_cache=256  tmp_table_size=48M  max_heap_table_size=48M    query_cache_size=64M    #logging of slow queries  log-slow-queries=/var/log/mysql-slow-query.log    # Default to using old password format for compatibility with mysql 3.x  # clients (those using the mysqlclient10 compatibility package).  #old_passwords=1    # Disabling symbolic-links is recommended to prevent assorted security risks;  # to do so, uncomment this line:  # symbolic-links=0    [mysqld_safe]  log-error=/var/log/mysqld.log  #pid-file=/var/run/mysqld/mysqld.pid  

I changed the current "innodb_buffer_pool_size" to 6GB last week and that made a huge improvement to the bottle-necking. We have actually only really started seeing issues again today. Traffic has increased this week since we have schools starting and football season starting as well.

I have all kinds of statistical information I can supply you if needed. I am not sure what else to supply at this time.

If I cannot get this figured out I will be forced to call in a consultant. I am hoping someone will be able to give me a hand with some of these settings.

Thanks in advance.

------------------ EDIT--------------------

Here is some additional information requested:

MySQL Version - 5.0.95
OS version - CentOS 5.6 (will be upgrading to 6.4 in the coming weeks)

Server - Dell PowerEdge R710
CPU - Dual Quad Core 2.8GHz
RAM - 12GB
This is a dedicated machine. The only thing running on this box is MySQL

Maintain a data warehouse with old data that were removed with new data that is added

Posted: 26 Aug 2013 06:16 PM PDT

i want to make a datawarehouse for a postgres database. For that i have read i need to use an ETL data warehouse, which is responsible for transforming the data into a format more suitable for the reports and pass them to the target database (the datawarehouse itself). for the ETL i chose kettle from pentaho, using spoon and kitchen to build and run the transformation jobs

but I can't find how to take the changes made to a date from the last transformation in the ETL.

For example I have the invoices table has the following data:

  • Data prior to 2012 that are no longer used for transactions, but are still used for reports
  • Data after the 2012 can be modified or deleted, and must be updated to reports

Therefore, the data warehouse must have data prior to 2012, even if i delete it from the transaction database, and the data after 2012 updated

is this possible? How I can do this?

Need Help Executing a Remote Task from SQL Server Agent

Posted: 26 Aug 2013 05:50 PM PDT

There is a scheduled task running on a batch server via the Windows Task Scheduler that sometimes overlaps with other scheduled jobs in the SQL Server Agent causing CPU issues. We can solve this if we can have SQL Server Agent execute the .exe on the remote server to ensure the schedules never conflict.

Is there any way to do this with SQL Server Agent, perhaps with a Powershell command? If so, can you please give me the steps?

The .exe on the remote server is a data importer for SQL. It is a stand alone .exe. We want it to run on the batch server so it doesn't cause resource contention on the DB server. We are running SQL 2008 R2 Enterprise.

Please let me know if any additional information is required to answer this question.

What steps are necessary to safely restart a machine hosting Microsoft SQL Server?

Posted: 26 Aug 2013 03:46 PM PDT

Are there any special steps necessary to prevent data corruption when restarting a server hosting an MS SQL instance?

For example, I recently encountered the recommendation of stopping the SQL service manually. My understanding is that this is handled by the shutdown process.

I'm sure there are a zillion steps which individual people may recommend, like that I just mentioned, but are there any recommended by Microsoft, or widespread industry standards?

Database Design - Global Asset

Posted: 26 Aug 2013 12:40 PM PDT

We are trying to implement a "global" asset depreciation system in our company. One of my pet-peeves is overengineering and we seem to be doing quite bit of that lately. We oversee two very disconnected businesses... one dealing with automobiles and the other trains/rail cars. I've explained to them keeping these separate will provide them most flexibility. Personally I hardly see any value in combining their systems... very little these two businesses can share. Also, not sure why we're reinventing the wheel on asset depreciation when it's been beaten to death already... just buy something. But that's besides the point.

There are really 3-4 specific types of assets. And these assets, predictably, have very different attributes. Sure, there are a few common ones they share between all of them. ie. PurchaseDate, PurchasePrice. Our business has not changed in over 80 years... in fact, they didn't have a true IT department until this year. Yet, they want their asset management system to be super flexible. Assets should be self referencing so that they can maintain ParentAsset/ChildAsset to the N-th degree.

They also want to treat all their assets the same... so we are design a system where Servers are stored in the same table as train engines and automobiles. I've exhausted all my reasons why this is a terrible idea... can someone help me articulate why this is a bad idea????

Designing a user table, FName LName v.s Username

Posted: 26 Aug 2013 02:56 PM PDT

I did some research on different ways of getting user's name. Some database designers prefer to have a username that contains first name and last name with space separator, and some other designers have it in two separate fields such as fname and lname. When it comes to searching using mySql, which approach makes it easier to search for a user based on his full name, or only either his last name or first name ? Any advice on the design approach ? My application is probably going to have about 5,000,000 users registered, I'm a bit concerned about in what way to approach user full name.

This is how I'm doing it, assuming that the user enter "alex coner" in one input textbox and press enter, then I parse the string based on space separation and then run the query like this which doesn't know which one is fname and lname :

select * from User   where UserFName in ("alex", "coner")      OR UserLName in ("alex", "coner")   

is there a way to run this and then get the one that matches the closest ? Assuming there is these users as below:

alex buche  coner johnson  alex coner  david rudd    and the result appears as :    alex coner  alex buche  coner johnson  

Enabling LOAD DATA LOCAL INFILE in mysql

Posted: 26 Aug 2013 12:52 PM PDT

LOAD DATA LOCAL INFILE is not enabled by default. Normally, it should be enabled by placing local-infile=1 in my.cnf. But it does not work for all installations. In my experience, it worked for Debian 7, but not Debian 7 minimal, though both installations come from the same precompiled deb package. Both on OpenVZ VPS.

How to debug why local-infile=1 does not work for an installation, and how to safely activate LOAD DATA LOCAL INFILE?

xtrabackup prepare - after dump or before restore?

Posted: 26 Aug 2013 10:43 AM PDT

i have doubts about xtrabackup --apply-log. is there any difference when use it? should it be done right after dump or before restore (even few months later)? seems stupid, but maybe i missing something.

documentation says this:

Prepare a backup in BACKUP-DIR by applying the transaction log file named xtrabackup_logfile located in the same directory. Also, create new transaction logs. The InnoDB configuration is read from the file backup-my.cnf created by innobackupex when the backup was made.

thanks for help :)

Oracle - Clause where in case when

Posted: 26 Aug 2013 05:31 PM PDT

all! I want to know how wrote this code of SQL, I already trying but i get message error. I wrote two way different this SQL. See you below

SELECT *    FROM tabela   WHERE coluna IN (CASE WHEN 1 = :parametro THEN 1 WHEN 0 = :parametro THEN (2, 3) END)  

And

SELECT *    FROM tabela   WHERE (CASE WHEN 1 = :parametro THEN coluna = 1 WHEN 0 = :parametro THEN coluna <> 1 END)  

I tried to run but it get error. Please! you help to tick or fix this code.

Thank a lot.

Regards, Jeison Pereira

Linked server query failures, fixed by scheduled query?

Posted: 26 Aug 2013 09:36 AM PDT

For a while now, I'm getting seemingly random failures in a couple of stored procedures that contains a linked server query. I got lucky and was able to determine that when the linked query fails, it fails everywhere (Access Client app, SSMS etc). These failures last from 2-10 minutes or so.

Error says something like ConnectDB Lib: SQL Server does not exist or Access Denied

So I setup a SQL Agent job on both servers, each asking the other server for 10 rows and then logging whether the select worked or not. I set this to run every minute for each server. Trying to map duration and time of failures to see what's happening at those times.

Now for the strange part. Since I set this up, I'm getting WAY LESS FAILURES! I'm trying to understand why this is working, because it seems like I'm doing a clumsy operation that is keeping the communication "fresh" between the servers, but I feel like there must be an actual SQL Server or Windows setting that is the right way to control this.

Any idea what this effect is? If a scheduled query works, is there some timeout setting that I've missed which governs it? Any suggestions are appreciated.

What is the best practices to backup and restore full and partial database with SQL Server 2012 and C#?

Posted: 26 Aug 2013 05:19 PM PDT

How can I do the following with C#:

  • Completely backup an existing database.
  • Partially backup an existing database.
  • Completely restore an existing database from a backup file.
  • Partially restore an existing database from a backup file.

My database saves images on the HARDDISK sometimes I need to backup and restore the database without the stored Images (might be 50 GB).

I need partially backup that execluding the FILESTREAM data (The saved files should be not included in the backup file).

I need partially restore that retrive the database without FILESTREAM data (The stored files should be not restored).

What is the best practices to do that?

Recover the disk space after deleting rows from table

Posted: 26 Aug 2013 12:24 PM PDT

I deleted millions of rows from one of the table with innodb engine. I know that I need to run optimize table to recover the space. But running that will cause lock on the table, which will affect the production queries. Is there any other way to recover the space without affecting the production queries.

replication required to configure - central office must be able to read and modify all customer data [on hold]

Posted: 26 Aug 2013 09:34 AM PDT

Each office must be able to enter its own customer data and to read customer data at other offices. The central office must be able to read and modify all customer data. what type of replication do i configure?

isql*plus crashes when multiple users run queries

Posted: 26 Aug 2013 12:11 PM PDT

In my workplace, multiple users are using isql*plus (Oracle 9i) to access a single database through server url. But after some time isql*plus crashes and its services need to be restarted.

Server is a desktop with 2 GB of RAM and 2.5Ghz AMD processor; 25 users.

  1. isql*plus is installed in pc in which main database access is provided (like proxy server). Here is the main problem and you can say isql*plus services crashes in proxy server.
  2. If services run correctly then it is routed to database and database gives result to proxy server.
  3. user see the result in isql*plus browser(url = ip address of proxy).

MySQL probelm in port: 3306

Posted: 26 Aug 2013 04:46 PM PDT

All websites on my VPS getting very slow, after dedcting the problem found that there are a line take 99.9% of the CPU:

        /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/lib/mysql/cd.49.be.static.xlhost.com.err --pid-file=/var/lib/mysql/cd.49.be.static.xlhost.com.pid  

Opened this file found nothing, everything goes right in this file.

EDIT:

etc/my.cnf

[mysqld] innodb_file_per_table=1

tried to know more, and closed all the content of my domains, also removed each database, one by one and nothing change still the same problem !

Could you help to know from where this error

Finding swap causes of MySQL

Posted: 26 Aug 2013 01:36 PM PDT

In my centos 6.3 server I have a MySQL 5.5.33 database.
It has 17 tables (15 InnoDB, 2 MyISAM) and total records 6.7M rows. I refactored my schemas and added indexes for my slow logs. My average query time is 20-30 ms. And my database performs well.

But I have some cron queries that runs every 3 hours. They don't use any index, they runs very slow and every query runs nearly 1500-2000 ms. I don't plan to add new indexes for them, because in that case I have to add many indexes and that queries run very rare.

When I restart my database server, -normally- swap is zero. After some time swapping becomes large gradually. After 13 days, I get 650MB swap of MySQL. I want to find what causes this swapping and try to reduce the swap without performance grade.

I want to be sure that the cause is cron queries or some other thing causes this swap size.

My top results:

top - 13:33:01 up 13 days, 11:04,  1 user,  load average: 0.77, 1.02, 1.07  Tasks: 148 total,   1 running, 147 sleeping,   0 stopped,   0 zombie  Cpu(s): 27.4%us,  5.3%sy,  0.0%ni, 59.1%id,  7.8%wa,  0.0%hi,  0.3%si,  0.0%st  Mem:   1020564k total,   854184k used,   166380k free,    73040k buffers  Swap:  2097144k total,   643036k used,  1454108k free,    94000k cached      PID USER        PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP COMMAND   9573 mysql       20   0 2336m 328m 3668 S  7.3 33.0 349:14.25 554m mysqld  15347 examplecom  20   0  219m  32m  10m S  2.7  3.2   0:02.66    0 php-cgi  15343 examplecom  20   0  215m  28m  10m S 10.0  2.9   0:05.80    0 php-cgi  15348 examplecom  20   0  215m  28m  10m S 12.3  2.8   0:03.62    0 php-cgi  15346 examplecom  20   0  215m  28m  10m S  9.6  2.8   0:06.39    0 php-cgi  15350 examplecom  20   0  212m  25m  10m S 10.0  2.6   0:02.19    0 php-cgi  15345 examplecom  20   0  211m  24m  10m S  6.6  2.5   0:04.28    0 php-cgi  15349 examplecom  20   0  209m  22m  10m S  5.3  2.2   0:02.66    0 php-cgi  12771 apache      20   0  334m 5304 2396 S  0.0  0.5   0:02.53  10m httpd  12763 apache      20   0  335m 5224 2232 S  0.3  0.5   0:02.33  11m httpd  

Edit: I restarted mysql server 2 days ago, so swap is low now. But with time passes it again will become bigger. When I make top I get this now:

top - 23:30:46 up 15 days, 21:01,  1 user,  load average: 0.35, 0.42, 0.42  Mem:   1020564k total,   931052k used,    89512k free,    76412k buffers  Swap:  2097144k total,   280528k used,  1816616k free,   233560k cached      PID USER        PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP COMMAND  23088 mysql       20   0 1922m 311m 3440 S  1.0 31.3  50:04.53 143m mysqld  10081 examplecom  20   0  216m  28m  10m S  4.0  2.8   0:01.67    0 php-cgi  10069 examplecom  20   0  215m  27m  10m S  3.3  2.7   0:04.81    0 php-cgi  10070 examplecom  20   0  215m  26m  10m S  8.3  2.7   0:04.75    0 php-cgi  10062 examplecom  20   0  215m  26m  10m S  6.0  2.7   0:06.26    0 php-cgi  10060 examplecom  20   0  214m  25m  10m S  5.3  2.6   0:07.51    0 php-cgi  10074 examplecom  20   0  214m  25m  10m S  6.6  2.6   0:03.01    0 php-cgi  10080 examplecom  20   0  212m  23m  10m S  6.0  2.4   0:01.58    0 php-cgi  

When I make free -m I get this:

             total       used       free     shared    buffers     cached  Mem:           996        927         68          0         76        219  -/+ buffers/cache:        631        364  Swap:         2047        273       1774  

My /etc/my.cnf file contents:

[mysqld]  datadir=/var/lib/mysql  socket=/var/lib/mysql/mysql.sock  user=mysql  symbolic-links=0  skip-name-resolve    slow_query_log=ON  long_query_time=1.2    innodb_file_per_table    max_allowed_packet=32M  thread_stack=256K  max_allowed_packet=32M  thread_stack=256K  max_connect_errors=100000000  max_connections=600    key_buffer=256M  sort_buffer_size=2M  read_buffer_size=2M  read_rnd_buffer_size=2M    thread_cache_size = 8  tmp_table_size=128M  max_heap_table_size=128M  query_cache_size = 209715200  query_cache_limit = 52428800  join_buffer_size=4M  table_cache=2400  low_priority_updates=1  tmpdir = /var/tmp    query_cache_type = 1    innodb_buffer_pool_size=256M  innodb_additional_mem_pool_size=512K  innodb_log_buffer_size=500K  innodb_thread_concurrency=8    [mysqld_safe]  log-error=/var/log/mysqld.log  pid-file=/var/run/mysqld/mysqld.pid  

Problems migrate database from 4 to 5.5 mysql

Posted: 26 Aug 2013 05:10 PM PDT

I have a server with 4.0 mysql version innodb engine.

i need to migrate to other server with 5.5 version (linux) ok

i dump the full database using mysqldump, when i try to restore on the 5.5 server it has a problem, because the file generate in the 4.0 set the variable on the sql scritp TYPE=INNODB and mysql 5.5 accepts only ENGINE=INNODB format on the time table creation and it abort the process.

i search on google, call any friends and nothing! the sql file has 16 gigabytes. is not possible edit with an file editor.

error exemple: CREATE TABLE tabadi ( nAdicao char(3) default '0', nSeqAdic char(3) NOT NULL default '', cFabricante varchar(60) NOT NULL default '', vDescDi varchar(15) NOT NULL default '', xPed int(6) NOT NULL default '0', nItemPed int(6) NOT NULL default '0', nDI varchar(12) NOT NULL default ''

) TYPE=InnoDB

ERROR 1064 (42000) at line 19: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=InnoDB' at line 9

Ps: i did try to change TYPE TO ENGINE and its solve the problem.

can anybody help me?

Thanks a lot.

Michel

SQL*Plus default output format

Posted: 26 Aug 2013 05:39 PM PDT

I have noticed that using the same SQL*Plus client to connect to different Oracle database result in different outputs for the same SQL query.

Database 1:

C:\Oracle\instantclient_10_2>sqlplus user/passwd@'(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=1521))(CONNECT_DATA=(SID=SID1)))'    SQL*Plus: Release 10.2.0.5.0 - Production on Fri Aug 23 11:54:45 2013    Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.      Connected to:  Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production  With the Partitioning, OLAP and Data Mining options    SQL> select 'XXXX ',to_char(UniqueSequenceNumber,'xxxxxxxxxxxxxx') from mytable where rownum < 2;    'XXXX TO_CHAR(UNIQUES  ----- ---------------  XXXX          300f483  

Here the output is on one line, the headers are truncated.

Same thing on an other database:

C:\Oracle\instantclient_10_2>sqlplus user/passwd@'(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=1521))(CONNECT_DATA=(SID=SID2)))'    SQL*Plus: Release 10.2.0.5.0 - Production on Fri Aug 23 11:58:15 2013    Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.      Connected to:  Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production  With the Partitioning, Data Mining and Real Application Testing options    SQL> select 'XXXX ',to_char(UniqueSequenceNumber,'xxxxxxxxxxxxxx') from mytable where rownum < 2;    'XXXX'  --------------------------------  TO_CHAR(UNIQUESEQUENCENUMBER,'XXXXXXXXXXXXXX')  --------------------------------------------------------------------------------  XXXX          3a1393b  

Here the output is split on two lines.

I am not looking for SQL*Plus formatting options like linesize, column format, etc. that just impact the current session. What I need to understand is what is making the output different even when I don't specify any options.

Is there some default settings on the server side? Is it depending on the Oracle server version (10.2.0.1 in one case, 10.2.0.5 in the other)?

Note: column UniqueSequenceNumber is of type NUMBER

Note 2: Tried on a Server version 10.2.0.3, same result as on 10.2.0.1 (one liner)

In reply to miracle173 :

C:\Oracle\instantclient_10_2>sqlplus /nolog    SQL*Plus: Release 10.2.0.5.0 - Production on Mon Aug 26 09:32:02 2013    Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.    SQL> connect user/passwd@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=1521))(CONNECT_DATA=(SID=SID1)))  Connected.  SQL> select 'xxxx' from dual;    'XXX  ----  xxxx    SQL> connect user/passwd@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=1521))(CONNECT_DATA=(SID=SID2)))  Connected.  SQL> select 'xxxx' from dual;    'XXXX'  --------------------------------  xxxx    SQL> connect user/passwd@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=1521))(CONNECT_DATA=(SID=SID1)))  Connected.  SQL> select 'xxxx' from dual;    'XXX  ----  xxxx    SQL> connect user/passwd@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=1521))(CONNECT_DATA=(SID=SID2)))  Connected.  SQL> select 'xxxx' from dual;    'XXXX'  --------------------------------  xxxx  

How do I maintain more audit history?

Posted: 26 Aug 2013 09:50 AM PDT

I created a SQL Server audit and when I view the audit logs I only see today's audit. I am saving it to a file and I want to store audit for one year. Is there a way to store database and server audit for one year? Does SQL Server store audits for only a day?

CREATE SERVER AUDIT [Audit-20130618-142022] TO FILE   (    FILEPATH = N'C:\Documents\Audit\Audit' ,    MAXSIZE = 0 MB ,    MAX_ROLLOVER_FILES = 2147483647 ,    RESERVE_DISK_SPACE = OFF   )   WITH   (     QUEUE_DELAY = 1000 ,    ON_FAILURE = CONTINUE   );  

SQL Server: subscriber as publisher and hierarchical replication

Posted: 26 Aug 2013 04:16 PM PDT

In Oracle Streams one way replication from one DB to another is a basic block for many replication topologies (N-way, hierarchical, combined and so on), and changes could be captured and applied for the same table at the same time.

But I can't find anywhere in SQL Server documentation whether table (article) could be a source (publisher) and destination (subscriber) simultaneously. Is it possible, for example, to setup bidirectional replication using two pairs of publisher->subscriber transactional replication?

Naturally I am more interested in multi-level hierarchy: for example one table is replicated from root node through intermediate nodes to leaves, second one - from leaves to root, and third one - bidirectionally, and for all tables intermediate nodes could perform DMLs to be replicated too. With Oracle Streams it is easy to achieve, and even more sophisticated configurations are possible, but are they with SQL Server?

UPDATE: It seems it is with use of merge replication and republishing (http://msdn.microsoft.com/en-us/library/ms152553.aspx), but what about transactional replication?

Cannot see Green Button with white arrow in object explorer; DTC config problems?

Posted: 26 Aug 2013 01:16 PM PDT

I have SQL Servers across locations setup for replication. One of the SQL Server instances that I installed, running locally I can see the green button with the white arrow in the object explorer when I connect to it. However, when I connect to it from any other location, I cannot see that or neither can I start or Stop the SQL Serer Agent; even though locally I am able to do that.

Additionally, the MDTC doesn't has only 2 items sent both with were rejected, where as other servers have 100's committed and sent. Is there something wrong with the DTC settings?

Please help.

Server permissions of an activation stored procedure of a Server Broker queue

Posted: 26 Aug 2013 11:42 AM PDT

I have a stored procedure that queries the sys.dm_exec_requests view. In the stored procedure the view only returns one row, while the stored procedure needs to see all of them. The MSDN article on the view says that what is returned depends on the user permission:

If the user has VIEW SERVER STATE permission on the server, the user will see all executing sessions on the instance of SQL Server; otherwise, the user will see only the current session.

The stored procedure is actually an activation stored procedure of a broker queue:

CREATE QUEUE test_queue    WITH     STATUS = ON,    RETENTION = OFF ,    ACTIVATION (      STATUS = ON,      PROCEDURE_NAME = test_procedure,      MAX_QUEUE_READERS = 1,       EXECUTE AS SELF ),  POISON_MESSAGE_HANDLING (STATUS = ON)   ON [PRIMARY]  

When I read the MSDN article, I changed

EXECUTE AS SELF  

to

EXECUTE AS 'dbo'  

which did not make any difference. sys.dm_exec_requests would still return a single row.

Also I tried to do

EXECUTE AS OWNER  

Which made no difference either. As I understand the stored procedure owner is who created it, which was me. And as I'm in a sysadmin role that should be working, but it does not. I'll appreciate any troubleshooting tips.

In particular I would like to know how to list a server permissions for a given user so I could check if they include 'VIEW SERVER STATE' permission as per the article.

The confusing part is that user as I understand it is on database level, so it's unclear to me how it can have server permission. If you could clarify that, it would be great too.

MySQL failover - Master to Master Replication

Posted: 26 Aug 2013 05:16 PM PDT

My company is trying to implement a MySQL failover mechanism, to achieve higher availability in our webservices tier - we commercialize a SaaS solution. To that end we have some low-end VMs scattered through different geographical locations, each containing a MySQL 5.5 server with several DBs, that for the time being are merely slave-replicating from the production server - the objective up until now was just checking the latency and general resilience of MySQL replication.

The plan however is to add a Master-Master replication environment between two servers in two separate locations, and these two instances would handle all the DB writes. The idea wouldn't necessarily imply concurrency; rather the intention is having a single one of the instances handling the writes, and upon a downtime situation using a DNS Failover service to direct the requests to the secondary server. After the primary comes back online, the b-log generated in the meantime in the secondary would be replicated back, and the DNS Failover restored the requests back to the first one.

I am not an experienced administrator, so I'm asking for your own thoughts and experiences. How wrong is this train of thought? What can obviously go wrong? Are there any much better alternatives? Bash away!

Thanks!

multi-master to single-slave replication at table level with PostgreSQL or MySQL

Posted: 26 Aug 2013 12:16 PM PDT

Here is my scenario

Master1 hosting DB1  Master2 hosting DB2  ...  MasterN hosting DBN    replicate to:    Slave1 hosting DB1,DB2... DBN  

I've read similar questions and they recommend to start different instances at Slave1 and simply do MasterN-Slave1(instanceN) replication, as instructed here:

Single slave - multiple master MySQL replication

That would be piece of cake, but running different instances might be a waste of resources.

I really want to achieve this with an single DBMS instance at Slave1, and if possible with PostgreSQL; but can try with MySQL if there is a solution for this.

Any help is appreciated.

How to search whole MySQL database for a particular string

Posted: 26 Aug 2013 12:08 PM PDT

is it possible to search a whole database tables ( row and column) to find out a particular string.

I am having a Database named A with about 35 tables,i need to search for the string named "hello" and i dont know on which table this string is saved.Is it possible?

Using MySQL

i am a linux admin and i am not familiar with databases,it would be really helpful if u can explain the query also.

SQL Server account delegation setup

Posted: 26 Aug 2013 11:16 AM PDT

I am try to run bulk insert command on SQL Server 2008 but I am having issues with the security. after researching via internet, the problem has something to do with account delegation and impersonation.

However all solutions seems to point to an Active Directory setup which my setup is not.

My setup is SQL Server 2008 Express on Windows Server 2008 Standard configured as a workgroup.

Despite a SQL Server user account, assigned all the user mappings and server roles and ensuring security set to SQL, I am getting this error:

Msg 4861, Level 16, State 1, Line 1
Cannot bulk load because the file "\server_name\file_name.txt" could not be opened. Operating system error code 5 (Access is denied.).

So, how does one setup SQL Server account delegation and impersonation on a workgroup environment?

Thanks in advance

Trouble setting up Nagios to monitor Oracle services

Posted: 26 Aug 2013 03:16 PM PDT

I've got an install of Nagios XI that doesn't seem to want to talk to any of my Oracle services here. I've pulled out the monitoring command and am running it manually, after setting ORACLE_HOME and LD_LIBDRARY_PATH of course, but it keeps generating the following error:

/usr/local/nagios # libexec/check_oracle_health --connect "oracle-server:1551" --username user --password "pass" --name OFFDB1 --mode tablespace-can-allocate-next --warning 20 --critical 30  CRITICAL - cannot connect to oracle-server:1551. ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA (DBD ERROR: OCIServerAttach)  

I'm still fairly new to Oracle, but my googlings seem to indicate that SERVICE_NAME should match the GLOBAL_DBNAME in listener.ora, which is OFFDB1. Do I need to do something else here like modify the connect string?

As a note, there are multiple instances of oracle sharing the target box, but each seems to be intalled to separate partitions and are running their own listeners or various ports.

What is difference between Oracle Apps and Oracle Application Server?

Posted: 26 Aug 2013 06:49 PM PDT

I am very new to oracle, could anybody tell me what Oracle Apps and Oracle Application Server are.

[SQL Server] Where Statement

[SQL Server] Where Statement


Where Statement

Posted: 26 Aug 2013 01:42 AM PDT

I want to do a "where statement" using "OR". When I try to run it, the right info does not come out. Can you see what I am doing wrong.thank youSELECT SV00300.Service_Call_ID ,SV00300.Service_Description,SV00300.DATE1 ,SV00300.LOCATNNM ,SV00300.CUSTNAME ,SV00300.CUSTNMBR ,SV00300.ADRSCODE,SV00300.Type_Call_Short,SV00300.Contract_Number ,DAM_TechEE_Info.FRSTNAME,DAM_TechEE_Info.TechnicianFROM SV00300 FULL OUTER JOIN WS30702 ON SV00300.Service_Call_ID = WS30702.WS_Job_Number INNER JOIN DAM_TechEE_Info ON WS30702.EMPLOYID = DAM_TechEE_Info.EMPLOYIDWHERESV00300.DATE1 Between (@Start_Date) and (@End_Date)and SV00300.CUSTNMBR in (@CUSTNMBR)or SV00300.DATE1 Between (@Start_Date) and (@End_Date)and SV00300.LOCATNNM in (@LOCATNNM)or SV00300.DATE1 Between (@Start_Date) and (@End_Date)and SV00300.Contract_Number in (@Contract_Number)

[Articles] Physical Security

[Articles] Physical Security


Physical Security

Posted: 25 Aug 2013 11:00 PM PDT

The physical security of our systems might be a bigger problem in the future as more and more hackers are finding ways into secure areas.

[MS SQL Server] The TEMPDB

[MS SQL Server] The TEMPDB


The TEMPDB

Posted: 25 Aug 2013 11:57 AM PDT

Dear All, I have run into a situation wherein some maintenance is required on the Cluster disk that hosts this TEMPDB. So iam having to temporarily move the files residing in there to elsewhere during this downtime. Once the physical disk maintenance is complete I would put back the files to where they were. What are the things to be considered and how can I go about it completing it smoothly :) ? One other question is doing such a maintenance on the sqls tempdb, will it affect the other system or other databases? Many thanks, Jai

Site Hand-Over Documentation

Posted: 25 Aug 2013 02:14 PM PDT

Hi all.I am new to the contracting world (coming from inhouse environments) and attempting to document a client site. I was wondering if there were standard documents that most DBAs use/like to have/demand when taking on a new customer/project.What am I looking for? A list of document titles/templates that describe the architecture/configuration/maintenance procedures/policies of a SQL Server site.I have my own ideas but I thought that I should ask about to see what others use.Thanks in anticipation.

[SQL 2012] Does this sound like a reasonable plan for an in-place upgrade to SQL2012?

[SQL 2012] Does this sound like a reasonable plan for an in-place upgrade to SQL2012?


Does this sound like a reasonable plan for an in-place upgrade to SQL2012?

Posted: 26 Aug 2013 02:49 AM PDT

First, before anyone yells at me that in-place upgrades are crazy talk and just install SQL2012 clean, I have *NO* control over these machines, and likely little input into the process anyways. This is for a migration of our in-house Sharepoint to another facilitys' SQL infrastructure, and one of the Sharepoint guys asked me about upgrading.Anyways.The plan the SP guy suggested would be for the new facility to snapshot their SP SQL server (presuming it's a VM,) then take backups of all the DBs on the SQL, then in-place upgrade. The bail-out plan would be to (if needed) restore the VM snapshot, then if needed restore the DBs from the backups taken just after the snapshot.To me, this sounds like a reasonable plan presuming a clean load of a new SQL Server isn't an option. You've got backups of the DBs, plus you can restore the VM back to how it was before you did anything.Thanks,Jason A.(as for why I'm worrying about this if I'm not going to be involved? If someone asks me a question I want to give them the best answer I can.)

Running SQL 2005 SSIS packages that read FoxPro files in SQL 2012

Posted: 26 Aug 2013 02:44 AM PDT

We are in the process of upgrading to a new SQL 2012 server but we have many packages that load data from dbf files created with FoxPro into one of our databases. We have not converted the packages and run them with DTS but we get the following error:Error: 2013-08-26 11:05:27.36 Code: 0xC0209303 Source: BenchmarkLoad Connection manager "OLEDB NPIONE.Investment.middleTierSQL" Description: The requested OLE DB provider SQLNCLI.1 is not registered. If the 64-bit driver is not installed, run the package in 32-bit mode. Error code: 0x00000000.An OLE DB record is available. Source: "Microsoft OLE DB Service Components" Hresult: 0x80040154 Description: "Class not registered".End ErrorError: 2013-08-26 11:05:27.36 Code: 0xC020F42A Source: BenchmarkLoad Connection manager "OLEDB NPIONE.Investment.middleTierSQL" Description: Consider changing the PROVIDER in the connection string to SQLNCLI11 or visit http://www.microsoft.com/downloads to find and install support for SQLNCLI.1.End ErrorI searched for OLEDB and ODBC drivers for SQL 2012 64 bit but cannot find any that is newer than the 2005 that we have. What can I do short of changing the source files to overcome this issue?Thanks in advance,Eduardo

SQL Server 2012 install failing on home laptop

Posted: 25 Aug 2013 06:54 AM PDT

SQL Server 2012 install is failing on my home laptop, which is running Windows 7 Home Premium SP1.I've attached a Word doc containing screenshots of each dialogue window as I progress through install. You'll see the window where install fails has green process bar 1/3 over and status is: Install_sql_engine_core_inst_loc_Cpu64_1033_Action.The main error message is:TITLE: Microsoft SQL Server 2012 Service Pack 1 Setup------------------------------Windows Installer error message: The system cannot read from the specified device.Windows Installer file: D:\1033_ENU_LP\x64\setup\sql_engine_core_inst_loc_msi\sql_engine_core_inst_loc.msiWindows Installer log file: C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\20130825_104925\sql_engine_core_inst_loc_Cpu64_1033_1.logDoes this point to bad iso image on DVD? (I wish it was possible to install directly from web), or is this pointing to some other problem anyone has encountered before?

[T-SQL] Gettin Error while Inplorting data from excel file to Table in sqlserver.

[T-SQL] Gettin Error while Inplorting data from excel file to Table in sqlserver.


Gettin Error while Inplorting data from excel file to Table in sqlserver.

Posted: 26 Aug 2013 12:59 AM PDT

some column in excel has lengthy data so,im gettin the following error while importing Data from sqlserver2008: - Executing (Error)MessagesError 0xc020901c: Data Flow Task 1: There was an error with output column "Description" (33) on output "Excel Source Output" (9). The column status returned was: "Text was truncated or one or more characters had no match in the target code page.". (SQL Server Import and Export Wizard) Error 0xc020902a: Data Flow Task 1: The "output column "Description" (33)" failed because truncation occurred, and the truncation row disposition on "output column "Description" (33)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component. (SQL Server Import and Export Wizard) Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "Source - 'Request Tracking$'" (1) returned error code 0xC020902A. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure. (SQL Server Import and Export Wizard) -------------------------plz suggest im using import wizard from sqlserver2008

Which trigger should choose?

Posted: 26 Aug 2013 12:06 AM PDT

Hi all,I have a scenario:There is 2 tables tableA and tableB. If I insert any record in tableA that is not exist in tableB then that record should get insert into tableB also, else if a record exists and any value is updated for that record than that value should also get updated in tableB.I have written MERGE statement for this in an trigger... But I am confused which should I use for this please suggest

Select first row

Posted: 26 Aug 2013 12:35 AM PDT

Hi, I'd really appreciate if someone can help, beforehand, thank youI have sites with contact list table where every contact has a "cs_seqno" number; every contact has a phone numberSample:Table name: contactSite 50 has a contact list with six contacts where the order to display them start by cs_seqno 1Contact tablesite Name cs_seqno phone50 Amy Benh 1 91658452050 John Smith 10 38825812550 Carl Denver 20 64064012050 Ed Coleman 30 9864012050 Ben Harmon 40 621621001site Name cs_seqno phone60 John Sunny 1 96663852060 Aaron Davis 10 46025282560 Phil Waitman 20 54065612260 Ron Ellis 30 61928863060 Don Willet 40 621621001I need get the first contact that has a phone number starting by 6, so for the upper list i need select and get the cs_seqno 20 & 30 site Name cs_seqno phone50 Carl Denver 20 64064012060 Ron Ellis 30 619288630Thanks for your help.Cphspain

Can we create Sequence to the environment?

Posted: 26 Aug 2013 12:42 AM PDT

HelloI know we can create a sequence on any particular column/ columns in a table. someone was asking me that can we create a sequence to the environment(Dev/Test).Thanks

Dynamic SQL - What's wrong with sp_executesql ?

Posted: 25 Aug 2013 02:46 AM PDT

Hi,the following Script builds a perfect SQL-Statement to Truncate multiple Tables.Print shows the Script, but EXECUTE sp_executesql @sql doesn't exec the Script. What's wrong? I want to truncate each Table with GV%.RegardsNicole ;-) DECLARE @sql NVARCHAR(MAX) ; DECLARE @TableNameStartsWith AS NVARCHAR(50)= 'GV' SET @sql = 'SELECT ''Truncate table '' + TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE ''' + '%' + @TableNameStartsWith + '%' + '''' PRINT @sql EXECUTE sp_executesql @sql

HOW TO CREATE LINKED SERVER FOR CSV

Posted: 25 Aug 2013 11:27 PM PDT

Hi EverybodyPlease help me to write a query for creating linkedserver to read csv files.Thanks

Changing Select Case used in Function to TSQL Query

Posted: 25 Aug 2013 07:13 PM PDT

Hi,I want to change the following function to a TSQL Query. Please help me in this regards.[code="vb"]Public Function TranslatedVal(SecCashHedge as String, ReturnType as String, Local as Decimal, BaseUnhedged as Decimal, BaseHedged as Decimal) as Decimal Dim Val as Decimal Val = Local Select Case ReturnType Case "Local" Val = Local Case "Base" Val = Local Case "Base Unhedged" Val = BaseUnhedged Case "Base Hedged" Val = BaseHedged End Select Select Case SecCashHedge & ReturnType Case "AcctBase" Val = BaseHedged Case "AcctHedgingBase" Val = BaseHedged Case "AcctTranslationBase" Val = BaseHedged Case "IndexBase" Val = BaseHedged Case "IndexHedgingLocal" Val = 0 Case "IndexHedgingBase" Val = BaseHedged Case "IndexHedgingBase Unhedged" Val = 0 Case "IndexHedgingBase Hedged" Val = 0 Case "IndexTranslationLocal" Val = 0 Case "IndexTranslationBase" Val = BaseHedged Case "IndexTranslationBase Unhedged" Val = 0 Case "IndexTranslationBase Hedged" Val = 0 Case "AcctHedging & Translation Gains/LossesBase" Val = BaseHedged Case "IndexHedging & Translation Gains/LossesBase" Val = BaseHedged End Select Return ValEnd Function[/code]

LTRIM,RTRIM

Posted: 21 Oct 2011 12:29 AM PDT

hii have this code in where clause RTRIM(LTRIM(ODER_ID))= ' ',WHAT THis do

Search This Blog