One of my co workers is under the impression that when adding an index to a table in SQL Server 2008 that the PK's index is added to that index as well. Therefore if you are using a wider primary key then that key will also be included in the new index vastly increasing the disk space used above and beyond the penalty already paid for th...
I have a query that goes something like this :
;WITH t as
(
select 1 as RowNumber, 1 as ObjectID, 10 as [Col1], 20 as [Col2], 20 as [Col3], 20 as [Col4] UNION ALL
select 2 as RowNumber, 2 as ObjectID, 20 as [Col1], 30 as [Col2], 40 as [Col3], 50 as [Col4]
)
SELECT RowNumber, ObjectID,
(
SELECT MAX(Amount)
...
I have a stored procedure that will INSERT a record into a table. I have created a unique key constraint on the table to avoid duplicate records.
Regardless of the fact that there is a unique key constraint defined, I am using an IF() condition (prior to the INSERT statement) to check for a duplicate record that may already exist.
How...
I have a table as follows:
colA colB(unique) colC
---------------------------------
1 1449 0.50000000
1 1451 1.03400000
1 2404 5.98750000
1 1454 6.00000000
3 1465 1.40000000
3 1467 1.56000000
3 1476 3.00000000
3 1469 ...
I mean I can't query null values when column type sql_variant
For example docsdate table look like this:
ValID DocID Value <--sql variant column)
1. 488 146 30.10.2007
2. 740 190 31.03.2008
3. 570 161 31.10.2008
4. 242 103 NULL
5. 248 104 NULL
When query like select * from docsdate where value is ...
I have seen people use GO statement between batches of SQL code, but AFAICS it is not mandatory (SQL Server 2008). What are the benefits using GO statements between batches/sets of SQL statements?
...
I tried to execute scripts from [1] in model database and user-defined databases but they give definitions/scripts of only user-defined (non-system) views, i.e. those that I anyway can easily get from GUI.
How can I see/script the definition/script of a system view in SQL Server 2008 R2?
[1]
Answers to question "System Views text i...
I have a server with sql server 2005, 2008 and sql express. This is a dev machine.
When I log onto the server I can get access to all servers as expected
[SERVERNAME] = 2005
[SERVERNAME]\mssql2008 = 2008
When I connect to my vpn connection both sql management 2008 and redgate software see [SERVERNAME] as my 2008 server.
When I try to...
I have a list of words in a text file. Each word separated by a new line. I want to read all of the words, and then, for each word I have to look up the DB and remove rows that contain the words that were read from the text file. How do i do that? I am a newbie to DB programming and I guess we dont have loops in SQL, right?
1 - Read all...
I need to upload a .bak file to SQL Server. How can I downgrade the database from SQL Server 2008 R2 to SQL Server 2008
thanks
...
We have a database Ms
DBCC CHECKDB (MS)
Or
ALTER DATABASE MS SET SINGLE_USER
DBCC CHECKDB(MS,REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE MS SET MULTI_USER
Error message
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
Msg 0, Level 20, State 0, Line 0
A severe er...
Hi,
I have sql server 2008 installed on my dev machine. How I figure out things like, the name of the server, do I connect to it using windows auth or using sql auth. If I connect using sql auth what is my account information. I set it up a while back and I dont know how to read all the sql server install and configuration information....
I have a web application with a SQLExpress 2008R2 database in the AppData folder. I wanted to make an update to the database manually so in IIS I took the site offline.
On the server I opened SQL Management Studio (as Administrator) and attached the database file and made my edits.
I then detached the database dropping all connections...
Hi,
I am using SQL server 2008. If I am working on the Management Studio's query analyser, and I go ahead and create a new table or view, then the SSMS does not see the newly created object for intellisense.
What do I do to make SSMS see and autosuggest from the newly created tables/views too?
...
Does anybody know when those __sync tables are created when performing synchronization between a SQL Server and a SQL Server CE?. I just set up the application that sets up the local and remote provider, and created all sync adapter commands (Insert, incremental Insert...) but when I call the Synchronize() method I get an exception. When...
In SQL 2008, I have a query like so:
QUERY A
UNION
QUERY B
UNION
QUERY C
Will it be slower/faster than putting the result of all 3 queries in say, a temporary table and then SELECTing them with DISTINCT?
...
-Bref history:-
I was using MapServer, everything was working fine except that when I was drawing a marker directly on a layer using a PixMap it was cut between tile. So, I decided to change to GeoServer which looks to work correctly to draw tiles where you have some image/pixmap between tiles.
-End of history-
Ok, I am able to connec...
Hi, I have a problem setting up email notifications in SQL Server 2008.
I am using SQL Server 2008 to build a data cube. This process consists of several jobs, that are all scheduled to run each night at a specific time. To see whether a job was running without any failure, it is possible to set up email notification.
Unfortunately,...
What's going on in the following code after the View is created? Can you give me any thoughts or path to follow?
This code is taken from here.
/****** Object: View [dbo].[vProductImages] Script Date: 04/28/2008 16:59:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[vProductImages]
AS
SELECT dbo....
Hi all,
I wish to know if I have a join query something like this -
Select E.Id,E.Name from Employee E join Dept D on E.DeptId=D.Id
and a subquery something like this -
Select E.Id,E.Name from Employee Where DeptId in (Select Id from Dept)
When I consider performance which of the two queries would be faster and why ?
Also is the...