Significant Difference Of Using WITH Statement
Apr 30, 2014is there a significant difference of using the WITH statement rather than a Temp Table besides less typing. l
View 1 Repliesis there a significant difference of using the WITH statement rather than a Temp Table besides less typing. l
View 1 RepliesSQL 2000 Connection String:user id=MyUserName;password=MyPassword;initial catalog=MyDB;server=MyServer;Connect Timeout=30 This SELECT statement returns its 10 results nearly instantly:SELECT * FROM MyTableDitto from above, but completes in 30-40 seconds:SELECT * FROM [dbo].[MyTable]Ditto from above, but completes nearly instantly:
SELECT TOP 1000 * FROM [dbo].[MyTable] Obviously I have stopped using the [dbo] syntax in my SqlCommand's (SELECT's and EXECUTE's) but still would like to know why this is.vr, Rich
1. I have a simple JOIN statement between A and B, e.g. Cities A JOIN Countries B:
SELECT A.City_Name, B.Country_Code, B.Country_Area
FROM Cities A
JOIN Countries B
ON B.Country_Id = A.Country_Id
WHERE B.Country_Type='ABC';
That statement works absolutely fine, very fast (less than a second) and returns me 2 records
2. I need to replace Country Area column with 1 for Europe and 0 for all the rest. I implement so in the following way:
SELECT A.City_Name, B.Country_Code, CASE B.Country_Area WHEN 'EUR' THEN 1 ELSE 0 AS Country_Area
FROM Cities A
JOIN Countries B
ON B.Country_Id = A.Country_Id
WHERE B.Country_Type='ABC';
Now to get the same two records it takes 03:55 minutes (!)
I have looked into Estimated Execution Plan, but couldn't spot any difference - all straight forward.
It is SQL 2012 SP1 with compatibility level set to 110
I have a user login scenario where I would like to make sure that they not only exist in the user table, but also make sure there account is "verified" and "active". I'm trying to return 3 output parameters. UserID, verified, active. Is this possible?
Do I need just a select statement to do this? What is the difference between the output and select statements?
Thanks in advance.
Recently, using PERFMON, I've been rather dismayed to find that ourapplication is averaging 3 - 4 lock timeouts per second, andfrequently has extended periods of several minutes where this figurereaches the hundreds.Average LockWaits/sec are less than 0.05, and TableLockEscalations/secare less than 0.5These last two seem very good to me, and as a result I wouldintuitively expect a LockTimeout figure of near-zero.Can anyone suggest why the measured LockTimeout value might be so high?Is the measured value actually considered "high" at all? Doubtlessthis depends on a number of things (transaction rate, number of usersetc), but a rule-of-thumb opinion would be welcomed.
View 4 Replies View RelatedHi all,
I have a problem with alphanumeric codes in SSIS.
I have a sql table with a varchar column which contains codes like '080101000', in my SSIS dataflow I have a lookup against this table and the column whith the code is used as output column for my lookup transformation.
In the advance editor the output column datatype is DT_WSTR, but when the code contains only numbers like the code '080101000' the first '0' is removed! It's like the code is at some point transformed to numeric and then inserted in the output column as a string. This in nonsense!!
Does anyone have an idea how to avoid this ?
I have encountered what I consider to be a significant bug when importing Excel spreadsheets using SSIS.
If in the first data row a particular column does not contain a value (i.e. it is null) then SSIS assumes that every row has a null value in that column. This disfunctional beahaviour has cost me hours and hours of wasted time loading and debugging data.
Hopefully someone from the appropriate area within Microsoft will read this post and get this bug fixed.
Hi all,
I am wondering if anyone has similar experience.
I did the migration by detaching the database from SQL 2000 running on W2K Pro and attaching it to SQL 2005 running on XP Pro. Some queries with simple aggregate functions such as AVG() have been slowed by at least an order of magnitude. I understand that SQL server can intelligently adapt to improve the performance. I am not sure how much it can improve at this point of time.
H
On a SQL Server 2005 x64 Standard Edition cluster I get the error listed below and then the SQL server service restarts. The SQL server is unavailable for 5-10 minutes during that time. Any ideas?
Error:
A significant part of sql server process memory has been paged out. This may result in a performance degradation. Duration: 647 seconds. Working set (KB): 11907776, committed (KB): 28731732, memory utilization: 41%%.
Question is in the subject.
Thanks in advance
-Jamie
I am currently having this problem with gridview and detailview. When I drag either onto the page and set my select statement to pick from one table and then update that data through the gridview (lets say), the update works perfectly. My problem is that the table I am pulling data from is mainly foreign keys. So in order to hide the number values of the foreign keys, I select the string value columns from the tables that contain the primary keys. I then use INNER JOIN in my SELECT so that I only get the data that pertains to the user I am looking to list and edit. I run the "test query" and everything I need shows up as I want it. I then go back to the gridview and change the fields which are foreign keys to templates. When I edit the templates I bind the field that contains the string value of the given foreign key to the template. This works great, because now the user will see string representation instead of the ID numbers that coinside with the string value. So I run my webpage and everything show up as I want it to, all the data is correct and I get no errors. I then click edit (as I have checked the "enable editing" box) and the gridview changes to edit mode. I make my changes and then select "update." When the page refreshes, and the gridview returns, the data is not updated and the original data is shown. I am sorry for so much typing, but I want to be as clear as possible with what I am doing. The only thing I can see being the issue is that when I setup my SELECT and FROM to contain fields from multiple tables, the UPDATE then does not work. When I remove all of my JOIN's and go back to foreign keys and one table the update works again. Below is what I have for my SQL statements:------------------------------------------------------------------------------------------------------------------------------------- SELECT:SELECT People.FirstName, People.LastName, People.FullName, People.PropertyID, People.InviteTypeID, People.RSVP, People.Wheelchair, Property.[House/Day Hab], InviteType.InviteTypeName FROM (InviteType INNER JOIN (Property INNER JOIN People ON Property.PropertyID = People.PropertyID) ON InviteType.InviteTypeID = People.InviteTypeID) WHERE (People.PersonID = ?)UPDATE:UPDATE [People] SET [FirstName] = ?, [LastName] = ?, [FullName] = ?, [PropertyID] = ?, [InviteTypeID] = ?, [RSVP] = ?, [Wheelchair] = ? WHERE [PersonID] = ? ---------------------------------------------------------------------------------------------------------------------------------------The only fields I want to update are in [People]. My WHERE is based on a control that I use to select a person from a drop down list. If I run the test query for the update while setting up my data source the query will update the record in the database. It is when I try to make the update from the gridview that the data is not changed. If anything is not clear please let me know and I will clarify as much as I can. This is my first project using ASP and working with databases so I am completely learning as I go. I took some database courses in college but I have never interacted with them with a web based front end. Any help will be greatly appreciated.Thank you in advance for any time, help, and/or advice you can give.Brian
View 5 Replies View RelatedWhat is the difference between below? And how can I make GETDATE() the same as System.DateTime.Today.ToShortDateString()?
System.DateTime.Today.ToShortDateString()
and
GETDATE()
Hi all,
What is the difference between SQL Server 2000 & SQL Server 2005?
Thanks!
Can anybody tell me what is the difference between backing up database to a file and backing up to backup device.
Thanx in adv.
Hello,
I am transfereing Data into text format.
The datas are about 5 table and has almost 50000 to 2 million rows.
I am using the same query for BCP and DTS. But I find the dreference between those. I mean DTS is taking less memory and more time than BCP to complete the process .
Anybody can share any comment for this issue ?.
Can somebody tell or may refer to a site that show the differences between SQL Server 2000 SP2 and SP3a.
Thanks.
Is there really a difference of approach?
I have several things to consider in an estimating database. Production, Shipping, Field Work, Field Hardware, etc...
All of the above have account numbers. Now I was wondering, would there be any benifit to having one table or several tables?
One Table Example
Account (PK) | Category | Description
or
Multiple tables
tbProduction
Account (PK) | Description
tbShipping
Account (PK) | Description
tbProducts
Account (PK) | Description
etc.....
I like having the tables split up and/or all in one.
Any thoughts, pros / cons?
Mike B
What is the difference between stored procedure and functions ?
thanx in advance
Hi,
What is the difference between Inline-table value function and multi statement table value function?
Thanks In Advance
Hi Experts,
please tell me the difference between BCP and DTS
provide me links if possible.
thankyou very much
hello friends,
i've bee working in DTS just from 2 days.
i've one database like 'x' and now i've exported the data to a newly created database 'y'
but in this y database i got much memory like around 30 mb.
why this happend?
sorry if this is a small question.
thankyou friends
Hi
I want to know the difference between
SQL server Express and
SQL server 2005 Express Edition.
Thanks
Yimoot.
hi, i'm having difficulty figuring out how to implement a set difference between two queries. the only set operator i've been able to come across is union. thanks in advance!
d
Hi all,
May any one tell the differnce between t-sql Stored procedure and the same SP written in CLR compatible?.Will CLR SP really improve the performance?
Your response will be highly appreciated.
Thanks in advance
Hi everyone,
What is the real difference among them ?
CREATE PROCEDURE sp_devamsizlik
@ADI CHAR(20)
AS
SELECT *
FROM OGRENCI
WHERE ADI=@ADI
GO
--------------------------------------------------------------------------------------
CREATE FUNCTION sp_devamsizlik
(@ADI
CHAR(20) )
RETURN TABLE
BEGIN
RETURN( SELECT * FROM OGRENCI WHERE ADI=@ADI )
END
Are SQL Server Express & SQL Server 2005 one & the same thing? Or is the former a part of the latter? Actually when I was downloading Visual Web Developer 2005 Express, I was given the option to download Microsoft SQL Server 2005 Express Edition as well; so I am getting confused between SQL Server Express & SQL Server 2005.
I installed SQL Server 2005 in my WinXP Pro m/c. from the Microsoft website (after re-installing WinXP Pro since XP became corrupt). Earlier I used to login to Management Studio Express using my m/c. name followed by a followed by SQLEXPRESS as the server name. So if my m/c. name is MyPC, then I used to login to Management Studio Express using MyPCSQLEXPRESS as the server name but now when I try to login to Management Studio Express using the above server name i.e. MyPCSQLEXPRESS, then an error gets thrown saying
Cannot connect to MyPCSQLEXPRESS.
Now how do I find out what's the server name so that I can login to create & manage databases in Management Studio Express?
Please note that after re-installing WinXP Pro, my m/c. name has remained the same; I didn't change it.
Thanks,
Arpan
Hi,
I want to know what are the differencve between CONTAINS and LIKE, Which is better to use and in which condition.????
I searched on google but can't able to find out major differnces or any good article realted to this,
Hai,
I want to know what is the difference between views and joins. why we are going for views in sql server.
Ok I have a query "SELECT ColumnNames FROM tbl1" let's say the values returned are "age,sex,race".
Now I want to be able to create an "update" statement like "UPATE tbl2 SET Col2 = age + sex + race" dynamically and execute this UPDATE statement. So, if the next select statement returns "age, sex, race, gender" then the script should create "UPDATE tbl2 SET Col2 = age + sex + race + gender" and execute it.
hiI need to write a stored procedure that takes input parameters,andaccording to these parameters the retrieved fields in a selectstatement are chosen.what i need to know is how to make the fields of the select statementconditional,taking in consideration that it is more than one fieldaddedfor exampleSQLStmt="select"if param1 thenSQLStmt=SQLStmt+ field1end ifif param2 thenSQLStmt=SQLStmt+ field2end if
View 2 Replies View RelatedHi guys,
I have the query below (running okay):
Code Block
SELECT DISTINCT Field01 AS 'Field01', Field02 AS 'Field02'
FROM myTables
WHERE Conditions are true
ORDER BY Field01
The results are just as I need:
Field01 Field02
------------- ----------------------
192473 8461760
192474 22810
Because other reasons. I need to modify that query to:
Code Block
SELECT DISTINCT Field01 AS 'Field01', Field02 AS 'Field02'
INTO AuxiliaryTable
FROM myTables
WHERE Conditions are true
ORDER BY Field01
SELECT DISTINCT [Field02] FROM AuxTable
The the results are:
Field02
----------------------
22810
8461760
And what I need is (without showing any other field):
Field02
----------------------
8461760
22810
Is there any good suggestion?
Thanks in advance for any help,
Aldo.
I've have a need with SQL Server 2005 (so I've no MERGE statement), I have to merge 2 tables, the target table has 10 fields, the first 4 are the clustered index and primary key, the source table has the same fields and index.Since I can't use the MERGE statement (I'm in SQL 2005) I have to make a double step operation, and INSERT and an UPDATE, I can't figure how to design the WHERE condition for the insert statement.
View 2 Replies View Relatedi was tasked to created an UPDATE statement for 6 tables , i would like to update 4 columns within the 6 tables , they all contains the same column names. the table gets its information from the source table, however the data that is transferd to the 6 tables are sometimes incorrect , i need to write a UPDATE statement that will automatically correct the data. the Update statement should also contact a where clause
the columns are [No] , [Salesperson Code], [Country Code] and [Country Name]
i was thinking of doing
Update [tablename]
SET [No] =
CASE
WHEN [No] ='AF01' THEN 'Country Code' = 'ZA7' AND 'Country Name' = 'South Africa'
ELSE 'Null'
END
What is the best way to script this