Quantcast
Channel: Forum Getting started with SQL Server
Viewing all 8979 articles
Browse latest View live

combine columns in sql

$
0
0

i am working on a project that i have to combine City, State Zip Code. i want it to come out as a single line.

City, State ZipCode.

I just can't seem to find an sql command that will do this, or i am just missing it.

thank you for any steps in the right direction


adding data

$
0
0

Hi ,

I have a staging table which have two column...say A and B which have different values.

A                            B

FBAT                    20

TRAINING            30

INPUT                  40

Now I need to get a different view from this...My new table should look like

D                 E

AMP         90

Where AMP is FBAT+TRAINING+INPUT. Also I need only the total value in my new table and not the individual record.

Can someone help me to figure this out?


SPPandey

Removing timestamp from files for remote backup.

$
0
0

To start off, we are running Server 2008 R2 - SQL Server. We are using a remote backup service (gillware) to handle off site backups. Our backup process looks like this Trigger -> Scan -> Local Backup (With timestamps) -> Remote Backup. The problem we are running into, because of timestamps, our remote backup service is filling up quick. Our trigger runs a batch file, that carries out the local backup, is there a way to add a command to this batch file that will pull the newest backups, rename with no timestamp, place them in another folder and then we can just backup that folder?

multiplying time with number of days in sql

$
0
0
FUNCTION [dbo].[GetTotalSalary1_func] 
(
	@emplID int,
	@month VARCHAR(50) = NULL
)
RETURNS int
AS
BEGIN
	Declare @BSalaryHour int, @TotalSalary int, @TotalHoursWorked int
		     Set @TotalHoursWorked = (Select OverallTime from MonthlyRecord where EmplID = @emplID AND Month = @month )
		Set @TotalSalary = @BSalaryHour * @TotalHoursWorked
		--------------------------------------------------------------------------------------
	-- Return the result of the function
	RETURN @TotalSalary

END

select dbo.GetTotalSalary1_func(5,'2013-dec')

it throws error on this line:

Set @TotalSalary = @BSalaryHour * @TotalHoursWorked

when @totalHoursWorked returned are like this 192:22 or 105:01 i guess bcz it can't multiply :22, :01 part with @BsalaryHour.

so how to do it ?

Note: 

OverallTime is basically varchar(13)

SSRS Report

$
0
0

When I run my SSRS report on Internet Explorer then how can I shift control on the next parameter. Using TAB we can shift controls but how to select the parameters without using mouse. I just want to use keyboard

Thanks

SQL Server Config Mgr Error: WMI Provider Error: Cannot find object or property.

$
0
0
I'm using SQL Server Configuration Manager tool with SQL Server 2008 (SQL Express) on local machine.  Went into properties and on the "logon" tab under "Log on as" I briefly changed the value from "local system" to "local service".  When I try to change back to "local system" I get the following error :

"WMI Provider Error"  - Cannot find object or property. [0x80092004] "

Can't get past this.  Stopped everything.  Rebooted. etc.
Can no longer start SQL Server.  Tried googling.  A few hits but no help.

Any ideas on how to fix this?

Many thanks.

Replication not using stated account

$
0
0

I'm creating a snapshot replication to push replication to another machine.  I've set up the Publication and the Subscription jobs using the wizard.  For now, I've set it up to run under the SQL Server Agent service account (although, I understand this is not best practices).  I selected to impersonate the process account to connect to the publisher. 

The problem is that when I run this from my account, I get the Error "Cannot connect to <destination machine>" ... "Failed to connect to <destination machine>" ... "Login failed for user <my account>"

It appears to be trying to do this from my account instead of from the service account I specified. 

Can anyone tell me what I'm doing incorrectly?

Interview Questions for SQL DBA

$
0
0

Hi,

Any one can briefly tell about the basic interview question's for sql dba.

NARESH.


Extending Table Data past 30 days

$
0
0

Hello,

I am having a hard time finding information on how to extend the amount of time a table in SQL stores data. My default, I believe this is set to 30 days, however I would like to retain my data for certain tables to 90 days. Is this possible? Is there an easy way to do this without needing to write custom queries?

Server Disk I/O issue?

$
0
0

I have a server 2008 with 24gb of RAM. On it, there are 5 separate instances; some SQL2008 and some SQL2012.

In my Oracle databases that are in Windows environment, I normally reserve 30% (about 7gb) of RAM for OS. So this is what I'm doing as well for this server.

I allocated 10% of the remaining (about 1.5gb) to the max server memory to each of the default instance, instance 2, 3 and 4.

I allocated 50% of the remaining RAM (11gb++) to the max server memory to instance1 because it has a numerous databases and one particularly huge database (> 5tb) and about 10-15k rows inserted daily.

Question 1: Is that how you allocate RAM? Based on database size and activity?

Question 2: I have a user reporting that when she has bulk insert (1000++ rows) from an 3rd party application; the application hangs and nothing will get inserted. Her database (DBXYZ) is in instance 4. Could this be related to amount or RAMs allocated to instance 4?

Question 3: I was reading http://www.sqlskills.com/blogs/paul/how-to-examine-io-subsystem-latencies-from-within-sql-server/ and executed the 2nd query. The read/write latency forDBXYZ are 111 and 571 respectively. Is that too high?

Question 4: The article mentioned "read and write hot spots are and then drill into a database to see what’s going on, and if nothing out of the ordinary" - what am I suppose to drill on the database and what's out of the ordinary?

Thanks

Ami

checking valid backup

$
0
0

Hi,

What are the ways to check backup is valid or not other than restore verifyonly.

critical issues

$
0
0

Hi,

As I'm facing interviews everyone asking critical issues in career as a sqldba. Can anyone please provide critical issues that you faced in your career.

execution plan

$
0
0

Hi,

How to understand execution plan? What are the things need to observe in output ?

Auto Update statistics

$
0
0

Hi,

How often auto update statistics run when it is on?

Microsoft TechNet Wiki SQL Server Guru - Winners for January!!

$
0
0

The results for January's TechNet Guru competition were posted!

http://blogs.technet.com/b/wikininjas/archive/2014/02/16/technet-guru-awards-january-2014.aspx


Post your FEBRUARY contributions here:

http://social.technet.microsoft.com/wiki/contents/articles/22885.technet-guru-contributions-for-february.aspx


A great big thank you to EVERYONE who contributed an article to last month's competition.

Hopefully we will see you ALL again in this month's listings?

Unfortunately, forum restrictions have prevented me from posting the winners here.

You will find the complete post, comments and feedback on the main announcement post.

Please join the discussion, add a comment, or suggest future categories.

If you have not yet contributed an article for this month, and you think you can write a more useful, clever, or better produced wiki article than last month's winners, here's your chance! :D

Best regards,
Pete Laker

More about the TechNet Guru Awards:



#PEJL

Got any nice code? If you invest time in coding an elegant, novel or impressive answer on MSDN forums, why not copy it over to the one and onlyTechNet Wiki, for future generations to benefit from! You'll never get archived again!

If you are a member of any user groups, please make sure you list them in the Microsoft User Groups Portal. Microsoft are trying to help promote your groups, and collating them here is the first step.


restore database

$
0
0

Full backup of database on Monday.

No backup on Tue all day---No transaction log backup,no full backup

No backup on Wed all day---No transaction log backup,no full backup

No backup on Thursday all day--No transaction log backup,no full backup

How to restore back to 6PM on wed?

Date where Clause

$
0
0

I would like a where clause 

where DataAssigned between 10/1/2012 and 09/1/2013

My DataAssigned Column is date and min format like "2013-05-20 10:56:52.0000"


simam

Login failed for user 'IIS APPPOOL\DefaultAppPool' on SQL Express 2012

$
0
0

I am new to both ASP.NET and SQL Server.

I have IIS8 installed on my Windows 8 PC, together with SQL Server Express 2012. Given my ignorance, I have just set everything up using default values.

I have a very small web site set up in its own folder and set up in IIS 8 as a virtual folder under the default web site. I have also set up a very simple database called 'StockControl' via SSMS, which contains one table called 'Colours' which has two columns.

One page in the website is a simple ASP.NET form which runs on localhost without any problems.

On the second page in the website I added a GridView ASP.NET control, letting Expression Web 4 generate the connection string and place it in a web.config file. I tested the SQL query and the connection as I went along and both came back as successful. So far, so good.However, when I try to run the page in the browser I get the error message:

Server Error in '/' Application.

Cannot open user default database. Login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot open user default database. Login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[SqlException (0x80131904): Cannot open user default database. Login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.]

I have spent two days trying to find out what I have done wrong and even uninstalled and re-installed SQL Server just in case i'd totally messed up and corrupted the database.

I would really appreciate some help please.

query execution

$
0
0

Hi,

When a query is executed what happens internally? How it give results?

Conversion failed when converting the varchar value to data type int.

$
0
0

when i execute my store procedure:

PROCEDURE [dbo].[GetEmailAdd_Sp]
	@emplid int
	AS
BEGIN
	Declare @emplEmail varchar(50)

	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    Set @emplEmail = (Select emailAdd from HrEmployee where EmplID = @emplid)
	return @emplEmail

END



then it throws error when i execute:

Conversion failed when converting the varchar value 'anyemail@precisetech.com.pk' to data type int.

Exec 


Exec GetEmailAdd_Sp 5
Viewing all 8979 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>