sql-server-2008

How it is possible to create clustered index on a view.

How it is possible to create clustered indexes on a view in SQL Server 2008. View is not a real table so there is no sense in physical arrangement of the data that clustered index creates. Where do I miss the point? ...

Distinct Record Issue in MS SQL Server 2008 query

Hello, I have this query to fetch the total OrderStatus that have values 1 and 5. How do I Sum only distinct OD.OrderStatus=2 as there can be multiple records in Orderdetails table with OrderStatus as 2. Please help SELECT O.OrderDate, Sum(Case When OD.OrderStatus = 2 Then 1 Else 0 End) AS OrdersOffered, Sum(Case When OD.OrderStatus =...

select into issue of SQL Server

Hello everyone, I am using SQL Server 2008 and I need to select all data from one table of one DB into another table of another DB on the same SQL Server instance. Here is my script using. The server will run out of memory. The data is big -- table is about 50G size on disk. Any easy alternative solution or any solution to lower memory...

differences between INSERT select and insert into select?

Hello everyone, I often see two styles, INSERT select and insert into select, what are the differences? Are they the same? I am using SQL Server 2008 Enterprise. Here are two samples. INSERT california_authors (au_id, au_lname, au_fname) SELECT au_id, au_lname, au_fname FROM authors WHERE State = 'CA' http://www.sqlteam.com/article...

SQL Server heap v.s. clustered index

Hello everyone, I am using SQL Server 2008. I know if a table has no clustered index, then it is called heap, or else the storage model is called clustered index (B-Tree). I want to learn more about what exactly means heap storage, what it looks like and whether it is organized as "heap" data structure (e.g. minimal heap, maximum heap)...

file system not supported error while adding a file to sql filegroup with filestream

hi i am a beginner with sql server 2008, i was trying to add a file to a filegroup so that i an create a table which uses filestream, but i keep getting an errors. here is the code that i am trying: ALTER DATABASE dbtry1 ADD FILEGROUP dbtry1_fg_filestream CONTAINS FILESTREAM GO ALTER DATABASE dbtry1 ADD FILE ( NAME= 'dbtry1_files...

SQL Server Stored Procedure store return value

Helo, My question is I have one Stored Procedure in SQL Server that returns counts of a field. I want to store the results of this Stored Procedure in a variable (scalar?) of a different stored procedure. sp_My_Other_SP: CREATE PROCEDURE [dbo].sp_My_Other_SP @variable int OUTPUT -- The returned count AS BEGIN -- SP SET NOCOUNT ON; ...

Querying Active Directory from Sql Server 2008

I cannot query AD via SQL Server. I add the linked server referencing the active directory both via SQL (see below) and through the SSMS GUI but I cannot figure out the security issues. EXEC sp_addlinkedserver @server = 'ADSI', @srvproduct = 'Active Directory Services 2.5', @provider = 'ADSDSOObject', @datasrc = 'adsdatasource' ...

Are SQL Server 2008 Spatial Data features useful for mapping queries?

I have an app where basically I have a huge table (100 million records) of information, with each row containing a lat/long value. I'm constantly querying this table to get all the records that fit within a radius around a certain point. For example, "all records within 5 miles of 39.89288,-104.919434" For this, I have an index over th...

SSIS timestamps

Can anyone provide details on what the three of these mean? System::ContainerStartTime System::CreationDate System::StartTime The documentation for these three is virtually non-existent. ...

Not sure if I understand what an Indexed View does behind the scenes, in SqlServer

Hi folks, I'm using sql server 2008 and have started to find using Indexed Views are helping me speed up some of my queries ... as my schema isn't basic. So, if i have a table that is the following... **ParentTable ParentId INT PK IDENTITY Name VARCHAR(MAX) **ChildTable ChildId INT PK IDENTITY ParentId INT (FK to the table above) Nam...

Get FileNotFoundException error when call a ActiveX in SSIS script task

I need call a ActiveX in my SSIS package, so I use script task and write the following C# script: public void Main() { clsAptFdbReader objFdbReader = new clsAptFdbReader("UnitedStates20000830.fdb"); objFdbReader.OpenFdb(false); Dts.TaskResult = (int)ScriptResults.Success; } Get a error: Error: System.Reflection.Targe...

Can I create a "Covering, Spatial" index in SQL Server 2008?

I currently have a site with a table that has Lat/Long float columns, and an index over those 2 columns plus another one I need to retrieve. I'm constantly querying this table to get the rows that fall within a radius from a certain point (I'm actually getting a square for speed), but I only need the fields that are already indexed, so ...

Which method is faster in SQL Server? Returning XML data or raw data that is consumed via a DataTable??

Hi there, The server scalability is a major concern for us. I am trying to do as much of the processing on the client as possible and since SQL server 2008 does not have native support for JSON but it does for XML... I thought if I return my data (using FOR XML EXPLICIT), and then in C# (BRL Layer), I can just use one SqlDataReader ca...

What data-type should I use to store monetary values?

I've read I should use money, but in todays fast paced world maybe that's obsolete now. What should I use? ...

Using the Web.Config to set up my SQL database connection string?

Can anyone help me out please? I'm confused. I want to set up my connection string so I can just call it from my Web.Config file. I need a way to call it from my code, please make a little example. :( I also need help on setting up the Web.Config file. I don't know what properties to use. Here's a screenshot of what my credentials a...

SQL Server 2008 - Help writing simple INSERT Trigger

This is with Microsoft SQL Server 2008. I've got 2 tables, Employee and EmployeeResult and I'm trying to write a simple INSERT trigger on EmployeeResult that does this - each time an INSERT is done into EmployeeResult such as: (Jack, 200, Sales) (Jane, 300, Marketing) (John, 400, Engineering) It should look up for the Name, Department...

Table-Valued Parameters to CLR Procedures in SQL Server 2008 - possible?

This page from SQL Server 2008 BOL, talks about CLR Stored Procedures and has a section labelled, "Table-Valued Parameters", which talks about how they can be advantageous. That's great - I'd love to use TVPs in my CLR procs, but unfortunately this seems to be the only reference in the universe to such a possibility, and the section does...

How can I see the code to my created Stored Procedure?

Right now, to see the code of an existent stored procedure I have to RightClick -> Modify it, is there a way for me to just see the code? ...

Code for SQL Server Management Studio 2008 plugin

I am looking for some reference code implementing a SSMS 2008 plugin. Can somebody point me to the right direction? ...