Friday, April 5, 2013

[SQL Server] Want to categorize the salaries of employee.

[SQL Server] Want to categorize the salaries of employee.


Want to categorize the salaries of employee.

Posted: 05 Apr 2013 07:36 AM PDT

Hi Team,I've Table People Where there are n no of employees involved.The salaries of the employee are present in Column 'Salary'So now, i wanted to count the no of Employees in the range of Salaries as below1) >10000 & <300002) >30000 & <800003) >800000Im trying the above logic as per the below code, can any one please help me understand this, why IM getting '0' for the counts even for no error in the query?'Select Count(p2.SALARY)As Range1, Count(p3.SALARY)As Range2,Count(p4.SALARY)As Range3From PEOPLE p1JOIN PEOPLE p2 ON ((p1.pID = p2.pID) AND (p1.SALARY BETWEEN 10000 AND 20000)) JOIN PEOPLE p3ON ((p1.pID = p3.pID) AND (p1.SALARY BETWEEN 20000 AND 80000))JOIN PEOPLE p4ON ((p1.pID = p4.pID) AND (p1.SALARY > 80000))'

auto foreign key generation

Posted: 04 Apr 2013 11:39 PM PDT

I created a table using the statement below in one of my databases (database1). The table is to be updated with information from a table in another database (database2) at a regular interval using an Insert Into statement. When creating the table, in addition to the fields I specified, it created a foreign key called PK_Test_ELE_761abed01e1455b5. I got my intial set of data into the table without a problem using the insert statement below without the where clause, but after that, every time I try to update it using the where clause I would get the following error message: "Violation of PRIMARY KEY constraint 'PK__ELEVATIONS__7B5130AA'. Cannot insert duplicate key in object 'Test_ELEVATIONS'." To get around it for testing in Beta I just deleted the key from the table. Before moving to prod, I wanted to get some additional information. Why was the key created and whats the best way to handle this? Thank in advance for any input.CREATE TABLE Test_ELEVATIONS(ProjectID nvarchar(30) not null Primary Key,ParcelID nvarchar(24) null,Ukey nvarchar(15) null,Location nvarchar(75) not null,AppStatus nvarchar(30) null,AppStatusDate datetime null,Type nvarchar(30) null,Category nvarchar(30) null,Community_Number nvarchar(30) null,Panel nvarchar(30) null,Datum nvarchar(30) null,Base_Flood_Elevation nvarchar(30) null,Lowest_Adjacent_Grade nvarchar(30) null,Lowest_Machinery_Elevation nvarchar(30) null,Date_of_Firm nvarchar(30) null,Firm_Zone nvarchar(30) null,License_Number nvarchar(30) null,Floor_Elevation nvarchar(30) null)Use Database2Insert Into database1.Test_ELEVATIONS(ProjectID,ParcelID,UKEY,Location,AppStatus,AppStatusDate,Type,Category,Community_Number ,Panel ,Datum,Base_Flood_Elevation,Lowest_Adjacent_Grade,Lowest_Machinery_Elevation,Date_of_Firm,Firm_Zone,License_Number,Floor_Elevation)Select .......From ....Where ProjectID NOT IN (SELECT PROJECTID FROM database1.Test_ELEVATIONS)

[MS SQL Server] disk i/o

[MS SQL Server] disk i/o


disk i/o

Posted: 04 Apr 2013 01:48 PM PDT

We have a SQL server with 25 GB RAM, it is used for data warehouse. When the user restores one of their big databases, it slows down the network, and sometimes caused Exchange server down. The data and log, and backup drive are all on the same SAN.What could be the problem? I guess it may be related with disk I/O, how should I start to troubleshooting?Thanks,

Insert into a table when new record

Posted: 05 Apr 2013 05:34 AM PDT

Hello,I would need help from a programming front...I guess this is probably done via trigger but not sure how to start.When [u]table1[/u] gets a new record added , only certain fields from table1 records would need to be inserted into [u]table2[/u]Many thx

SSIS - Database Transfer Wizard - @flags parameters is not valid

Posted: 04 Feb 2013 05:43 AM PST

I'm trying to use copy database wizard to make a copy of a SQL Server 2005 database (9.0.3042) on a SQL Server 2012 machine (11.0.2100). I'm using the "SQL Management Object method" so that the orginal database can remain online. When I get to the final step I recieve the following error:- Start SQL Server Agent Job (Error) Messages * Create failed for JobStep 'CDW_KC4DATABASE_KCCDB_0_Step'. (Copy Database Wizard)The @flags parameter is not valid for a job step of type 'SSIS'. (Microsoft SQL Server, Error: 14545)I can't seem to find anything on the internet regarding "@flags parameter is not valid". Of course the two links provided in the error log that go to microsoft's site are totally useless. The full error message follows:[i]Performing operation- Add log for package (Success)- Add task for transferring database objects (Success)- Create package (Success)- Start SQL Server Agent Job (Error) Messages * Create failed for JobStep 'CDW_KC4DATABASE_KCCDB_0_Step'. (Copy Database Wizard) For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.2500.0+((KJ_PCU_Main).110617-0038+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+JobStep&LinkId=20476 ------------------------------ ADDITIONAL INFORMATION: An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo) ------------------------------ The @flags parameter is not valid for a job step of type 'SSIS'. (Microsoft SQL Server, Error: 14545) For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.00.2100&EvtSrc=MSSQLServer&EvtID=14545&LinkId=20476 - Execute SQL Server Agent Job (Stopped)[/i]Anyone have any insight?Thanks!

Orphaned users

Posted: 04 Apr 2013 09:42 PM PDT

I've 2 sql server instances on my local system.I backed up a database from one instance and restored that database on the other instance.I copied over the logins from the 1st instance to the 2nd instance.Then I ran the following statement on the 2nd instance to check if there are any orphaned users but I got 0 results.sp_change_users_login @Action='Report'GOBut I still cannot login into the newly restored database with any of the sql server logins. Am i missing something?

steps for proper configure in AWE?

Posted: 04 Apr 2013 05:24 PM PDT

Hi,Server OS - Windwos 2008 Enterprise Edition 32 bitDatabase - SQL Server 2008 Standared Edition 32 bitMemory - 32GB.[u]As per current configuration setup as below[/u]1. AWE - enabled in SQL Instance side.. But OS level not enable and not adding /3GB or PAE switch in boot.ini file.2. LPIM - Not Enabled and not added SQL service account in LPIM at local policy.(In windows 2008 if facing error like memory swapping out in error log file then only need to enable at LPIM when configure AWE option)[u]Pl. confirm as below steps for proper configure in AWE.[/u]Step1:Set Max memory - 6144 MB at SQL instance file ( Total 32GB memory assign 6GB in SQL and remain other application & OS side, this server is not dedicated SQL) Step2:C:\> bcdedit /SET IncreaseuserVA /3GB 3078Step3:SQL Service account added into LPIM at local policy (is it require in SQL2K8 standard edition?)Step4:Restart the server for take effect AWE feature.rgdsananda

Growing Log Files

Posted: 04 Apr 2013 10:39 AM PDT

I am intermediate in database admin. Please give me your solution for this issue. Size of my db is growing about 5M every 2 weeks. Now its size is 118G. my db is in full recovery mode, and I do not have log backup.Is this a good solution?1- Perform a full backup2- execute checkpoint3-Perform full Backup4- Perform transactional log backup5- shrink log file type6- schedule transactional log backupAlso, can I do these processes during users are connected ?

[Articles] Insensitivity: A Good Technique?

[Articles] Insensitivity: A Good Technique?


Insensitivity: A Good Technique?

Posted: 04 Apr 2013 11:00 PM PDT

This article explores the place of emotion among knowledge workers doing team-based design activities.

[SQL 2012] Intellisense Enabled Option is Greyed off

[SQL 2012] Intellisense Enabled Option is Greyed off


Intellisense Enabled Option is Greyed off

Posted: 05 Apr 2013 02:11 AM PDT

I installed SQL Server 2012 on my box. Intellisense is not working and when I go to Query menu -- the "Intellisense Enabled" option is greyed off.What could be the problem?Thanks

Clear definition of read-intent connection please

Posted: 05 Apr 2013 12:47 AM PDT

Hi,Can someone please give me a clear definition of a read-intent connection? I've encountered the phrase when reading about SQL server 2012 AlwaysOn set up. When I googled it seemed that everything I read was a circular definition using the phrase to define itself.Read-intent connection is used in the context of Connection modes in secondary replicas. the choices are 1) disallow connection, 2) allow only read-intent connections, and 3) allow all connections (means all connections for read access only).The only thing I've been able to glean so far is that read-intent connections won't work with older clients.Thanks in advance for reading this and hopefully responding.

Making an AppDomain containing SQL CLR Assembly persist in memory

Posted: 04 Apr 2013 03:49 AM PDT

Hi There,I hope this is in the right board, the SQL CLR section seems to be under SQL Server 2005.I have a CLR Assembly that contains methods to encrypt and decrypt a table of fields using AES.We see a large performance hit on the first run of these methods whilst the CLR is loaded into memory. This takes between 15 and 20 seconds. Subsequent calls take < 1 second until the Assembly is unloaded.I have done some reading around AppDomains and it seems that the AppDomain is held in memory 'to improve performance' until such time as SQL Server deems that 'memory pressure' requires it to be unloaded.We will be hitting these methods quite often but not consistently enough to prevent the CLR from unloading.Is there anyway to adjust the server settings or assembly options to make them more persistent?TIA,Chris

[SQL server issues]Commented Issue: AdventureWorksDW2008R2 DimDate table has missing dates [13383]


Hello,
Is this been taken care? If so, please share the latest data for DimDate. I'm working on some POC which requires dates in between 2008 and 2010 as well. If it is not already done, can someone let me know is there is any way I can generate the data for those missing dates in that table?



.

sqlserversamples.codeplex.com

[SQL server issues]Created Issue: New to datawarehousing...and want to know how the Adventurework and AdventureworkDW has been developed [17881]




description



New to datawarehousing...and want to know how the Adventurework and AdventureworkDW has been developed..
how the OLTP data has been extracted to AdventureworksDW..datawarehouse system and need some design documents....what to know how the DIM tables are created...and everything







.

sqlserversamples.codeplex.com

[SQL server issues]Created Issue: SQL Server 2008 Developer edition sample database install error [18174]







description



I'm trying to install Adventureworks sample dB and i get an error.
I successfully downloaded the mdf file however when attach, add and click OK from SSMS I get the error:
 
Msg 5172, Level 16, State 15, Line 1
The header for file 'C:\Program Files\Microsoft SQL Server\AdventureWorks2012_Data.mdf' is not a valid database file header. The FILE SIZE property is incorrect.







.

sqlserversamples.codeplex.com

Search This Blog