sql-server

Need help with Scalar-valued function in SQL Server 2008

Hello, I need help with this scalar-valued function. What I want to do is to return the value I get in MaxValue on the line max(Value) AS MaxValue. The query works and will only return 1 value if ItemId and ListPropertyId exists, but I am not able to create a function of it. CREATE FUNCTION GetLpivMax ( -- Add the parameters for ...

Getting a significant amount of data into a SQL Server (Express) database at time of deployment

For most database-backed projects I've worked on, there is a need to get "startup" or test data into the database before deploying the project. Examples of startup data: a table that lists all the countries in the world or a table that lists a bunch of colors that will be used to populate a color palette. I've been using a system where ...

Equivalent of sp_helptext for tables in SQL Server

When we need the query of stored procedures we use 'Sp_Helptext procedurename' Can something similar be done for tables? ...

Creating A Search System from a SQL Server Database

I have recently created a search system at my company using the Regain Search based on Lucene to search through all software support tickets. I run some queries in SQL to extract my data, export to Excel, import to Access, run some additional queries, create a report, export the report to .txt files, and use a file splitter to split the ...

SQL Database Project in Visual Studio

Hi, I have a database ready which I am maintaining manually, I would like to now use that database to create an SQL project. I am creating also but not able to import the existing Tables, Views, Stored Procedures or any other object. Is there any way to do it. If yes please let me know. Thanks, Piyush ...

How might I import data from MS-Excel into Sql Server using ASP.NET?

I need to import data from Excel to Sql Server using ASP.NET. How can I do this? ...

Pass an array as value in an ado.net DBParameter

The project I'm working on has a lot of IN-queries like: SELECT something, anotherthing FROM atable WHERE something IN (value1, value2, value3) This is an example of a queru with 3 parameters in the IN-part but the same query could be executed with 1 or 2 or 5 or 10 or ... parameters. The problem is that each query has an other execut...

Using sets as inparameters to function/sproc in SQL Server 2008?

Hello! Is it possible to use a set, like (1, 2, 3, 4, 5) for example, as inparameter to a Sproc, function or view in SQL Server 2008? What should I use of Sproc, function or View for this pice of SLQ? WITH Scores AS( SELECT ItemId, SUM(Score) AS Score FROM [Presenta].[presenta].[LpivScores] WHERE // HERE ...

How much minimum rows require for eligibility to create index?

I have created script to find selectivity of each columns for every tables. In those some tables with less than 100 rows but selectivity of column is more than 50%. where Selectivity = Distinct Values / Total Number Rows So, are those column are eligible for index? Or, can you tell, how much minimum rows require for eligibility to create...

Saving changes after table edit in SQL Server Management Studio

If I want to save any changes in a table, previously saved in SQL Server Management Studio (no data in table present) I get an error message: "Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled t...

SQL Server 2005: converting smalldatetime to varchar behaves differently in view and 'normal' query

Hi, I have a view that basically just returns all records from a table, and adds a column 'isodate' which is supposed to be the date in ISO-Format. CREATE VIEW [dbo].[v_bedarfe] AS SELECT *,convert(varchar(16),datum,20) As isodat FROM bedarfe GO The "datum"-field is smalldatetime. The results of a query on isodat were...'surprisi...

SQL Server user-defined aggregate returns an error if aggregating 0 rows.

I have this SQL Server user-defined aggregate: [SqlUserDefinedAggregate(Format.UserDefined, Name="median", IsInvariantToDuplicates=false, IsInvariantToNulls=true, IsInvariantToOrder=true, IsNullIfEmpty=true, MaxByteSize=8000)] public class MedianCalculator : IBinarySerialize { private List<double> values; public void Init() { ...

Generating Excel from SQL Server

IF @hr=0 EXEC @hr=sp_OACreate 'Excel.Application', @objExcel OUT The above line for creating excel is giving errorcode "-2147221005" ...

Good online resources for Microsoft Dynamics SL?

Does anyone know of good online resources for Microsoft Dynamics SL (Solomon)? I'm interested in general support information and back end SQL support information, as well. Thanks. ...

How I could assign a preset set of string values to a field of table in SQL Server 2008?

I want a field in a table of SQL Server 2008 to contain a preset number of string values for user to be able then to select one value from a dropdown listbox in my WPF front-end app. Is it possible only through assigning a numeric int type in a SQL Server table field and then doing all the stuff through C# front-end coding, or are there...

Filter search query

Hello, I have a table with the columns City and ZoneCode. I have a dropdown list where I can select just one City or all. And another dropdownlist for the ZoneCode. Basically they are filters that only filter if I select a value from the dropdown lists. Is there any recommended technique to do this? edit: this table is only an example...

Problem using Query Analyzer to debug stored procedure

I am attempting to debug a stored procedure using the Debug option is SQL Query Analyzer (Version 8.00). However, the debugger run through the whole stored procedure as soon as I start and if add a break-point and try re-executing the sp, the break-point is ignored. What do I need to do to enable debugging? The server is SQL Server 2000 ...

Get Sql Server instance name using Adodb conncection object

I need SQL server 2005 instance name from Adodb connection object in c#. Please Help for my query. Thanks in advance ...

SQL Server: Doing a DELETE with a complex VIEW.

I have a complex VIEW and would like to use the DELETE verb against it. Can this be done? Will the DELETE verb only affect the FROM table used in the SELECT statement? I have about 8 joins. Will any of these joined tables be affected? I am using SQL Server 2005. ...

Is there a way to change permissions for all the tables in SQL-server database at once?

I want to change the permissions for all the tables in a SQL-Server database at once. Is there a way to do this? ...