sql-server-2005

sql server - select top and bottom rows

Hi, I'm using Sql Server 2005 and i'm trying to achieve something like: In the same select statement i want to get the first x rows and the last x rows. SELECT TOP(5) BOTTOM(5) Of course 'bottom' does not exist so i need other solution. I believe there is an easy and elegant solution that i'm not getting. Doing the select again with...

Non-clustered index in sql server

can i specify more then one column as Non-cluster index, what will it affect? ...

Simple ASP function question

Good Morning, I have got the following function: FUNCTION queryDatabaseCount(sqlStr) SET queryDatabaseCountRecordSet = databaseConnection.Execute(sqlStr) If queryDatabaseCountRecordSet.EOF Then queryDatabaseCountRecordSet.Close queryDatabaseCount = 0 Else QueryArray = quer...

Is this sql where statement correct?

I have 10 rows for today's date but my select statement based on date dosen't seem to work.... SELECT Id,WirelessId,RegNo,DriverName1,MobileNo1,DriverName2,MobileNo1 from DailySchedule where IsDeleted=0 and CreatedDate='2010-05-28' Any suggestion... ...

SQL Server - access to sys.views for a highly privileged user

I have case where I want a database user to have db_owner privileges with regard to one databases on the server, but be able to see absolutely nothing of other databases on the server, including, for example, the sys.databases view. I have tried denying select on this view at the master database level, but this prevents the user even fr...

Construct the scorecard in Excel using CUBE data from SSAS

I want to construct the scorecard having multiple KPI's in it in a similar fashion of beolwo image I will be having my KPI details in Dimesion(KPI Name). So I want the same look in Excel..All KPI names are left side and value, Goal, Status and trend in the top ...

Performance of stored procedure vs scalar-valued function in Microsoft SQL Server

I am wondering about performance difference between stored procedure and scalar-valued function. For now i use mostly scalar-valued functions because i can use them inside other queries (and 99% of time they return 1 value anyway). But there are scalar-valued functions that I never use within other queries and usually i call them with s...

Debugging stored procedures, without using SSMS 2008 Debugger, or the Visual Studio debugger (output variable values?)

I have a SQL Server 2005 database with some Stored Procedures (SP) that I would like to debug...essentially I would just like to check variable values at certain points throughout the SP execution. I have SSMS 2008, but when I try to use the debugger, I get an error that it can't debug SQL Server 2005 databases. And I can't use the Vis...

How can I 'transpose' my data using SQL and remove duplicates at the same time?

I have the following data structure in my database: LastName FirstName CourseName John Day Pricing John Day Marketing John Day Finance Lisa Smith Marketing Lisa Smith Finance etc... The data shows employess within a business and which courses they have s...

Is there any control that take System.Drawing.Image object and view as image ?

I return array of images ( System.Drawing.Image[] ) from database and i want to show them in datagrid or datalist .. Can any tell me how to do that ? ...

Simulating an identity column within an insert trigger

I have a table for logging that needs a log ID but I can't use an identity column because the log ID is part of a combo key. create table StuffLogs { StuffID int LogID int Note varchar(255) } There is a combo key for StuffID & LogID. I want to build an insert trigger that computes the next LogID when inserting log records. ...

How to cope with null results in SQL Tasks that return single rows in SSIS 2005?

In a dataflow task, I can slip a rowcount into the processing flow and place the count into a variable. I can later use that variable to conditionally perform some other work if the rowcount was > 0. This works well for me, but I have no corresponding strategy for sql tasks expected to return a single row. In that event, I'm returning th...

Linked servers SQLNCLI problem. "No transaction is active"

Im trying to execute a stored procedure and simply insert its results in a temporary table, and I'm getting the following message: The operation could not be performed because OLE DB provider "SQLNCLI" for linked server "MyServerName" was unable to begin a distributed transaction. OLE DB provider "SQLNCLI" for linked server "MyServerNam...

Create an Integrity error for an SQL Server Database for the purpose of Testing

How can I manually introduce an integrity error into my database for the purpose of testing, without totally corrupting the database so that I can still run my program. Updating with a more specific question... The actual feature that I am testing runs DBCC CHECKDB and what I am testing is that it reports a failure to the user. ...

Sqlserver 2005 Replication issue

Hi, I have a peer to peer Merge Replication from two Sqlserver 2005. The first Sqlserver is both the publisher and distribuitor. All works fine but if the VPN goes down for a couple of hours the replication goes down too and I need to manually restart the sqlserver agent. In the Sqlserver Agent properties I have set the two option about ...

In SQL Server, how to quickly get a general idea of an instance?

Hi guys, If you are a new sql server dba and you just get an account of an instance. What would you do to know the instance and databases? How to quick get a general idea of this instance and databases? Great thanks. ...

sql server db deployment script ignoring constraints etc until commit

Hi all, I am planning on doing a database deployment script for sql server 2005. Currently we have a tool that will run all of the tables, foreign keys, indexes and then data, each of which is located in a separate file with a certain extension (eg. tab, .kci, .fky) and the tool just runs *.tab, *.kci, *.fky into the db etc. Could I p...

import data from another table with same id

Hi, i have 2 table User (id, name, surname,cod) UserNew (uid, uname, usurname, ucod) The first table has data the second no. I have to copy the data of the User table in the UserNew table. I've tried with a insert query but uid (primary key) value changes. How can i do to mantaince the same values? thanks ...

Force DATABASE ALTER ignoring errors

As the name says, force the alter database to alter its collation ignoring the error message that I get from functions or calculated columns that compare data. Is there a way to do so? Like IGNORE_ERRORS or something like that? Thanks a lot! ...

Dynamically call a stored procedure from another stored procedure

I want to be able to pass in the name of a stored procedure as a string into another stored procedure and have it called with dynamic parameters. I'm getting an error though. Specifically I've tried: create procedure test @var1 varchar(255), @var2 varchar(255) as select 1 create procedure call_it @proc_name varchar(255) as ...