sql-server-2005

SmoApplication.EnumAvailableSqlServers returns server names but not instance names (but only on one machine)

Hi, There are a number of questions about this and a number of possible causes and thus far ive tried them all with no success. situation: i have an app that needs a db to work, onstartup it does a SmoApplication.EnumAvailableSqlServers(false) to get all the instances on the network, shows the user a dropdown, they pick one and i go con...

Need help with a SQL CTE Query

I have a table that I need to get some specific data from for a view. Here's the base table structure with some sample data: | UserID | ReportsToUserID | Org ID | ------------------------------------- | 1 | NULL | 1 | ------------------------------------- | 2 | 1 | 1 | -----------------------...

Power error handling inside of sql function

I have a power function call inside of a sql function. What is the correct way to handle overflow and underflow conditions since I cannot use a Try Catch inside of a function. I am also trying to avoid modifying the ARITHABORT, ANSI_WARNINGS, and ARITHIGNORE settings in the calling code. GO CREATE FUNCTION TestPow() RETURNS DECIMAL(30,...

Unattended Install of SQL Server 2005 Express with LOCAL Server InstanceName

I'm creating an install package using InnoSetup and installing SQL Server 2005 Express. Here's the code below that appears in my RUN section: Filename: "{app}\SQL Server 2005 Express\SQLEXPR.exe" ; Parameters: "-q /norebootchk /qn reboot=ReallySuppress addlocal=all INSTANCENAME=(LOCAL) SCCCHECKLEVEL=IncompatibleComponents:1;MDAC25Versio...

Child sProc cannot reference a Local temp table created in parent sProc

On our production SQL2000 instance, we have a database with hundreds of stored procedures, many of which use a technique of creating a #TEMP table "early" on in the code and then various inner stored procedures get EXECUTEd by this parent sProc. In SQL2000, the inner or "child" sProc have no problem INSERTing into #TEMP or SELECTing data...

How to use bigint data type for primary keys in Rails 2.3 using activerecord-jdbc

Hi all I have a Rails app that I'm porting from Rails 1.2 to 2.3. I'm also moving from the Ruby MRI to the latest version of JRuby as well. In the existing (Rails 1.2) app I use the mysql_bigint plugin to provide support for 64-bit ints as primary keys. I need to to the same thing for the new application running against a MS SQL 2005 ...

SQL query that returns columns form table A plus a bit column that specifies with the PK of table A exists in table B

How can I write an efficient SQL query that returns columns form table A plus a bit column that specifies whether the PK of table A exists in table B? I am using MS SQLServer 2005. Thanks. ...

How do you extract just date from datetime in T-Sql?

I am running a select against a datetime column in SQL Server 2005. I can select only the date from this datetime column? ...

Assign the results of a stored procedure into a variable in another stored procedure

The title of this question is a bit misleading, but I couldn't summarize this very well. I have two stored procedures. The first stored procedure (s_proc1) calls a second stored procedure (s_proc2). I want to assign the value returned from s_proc2 to a variable in s_proc1. Currently, I'm calling s_proc2 (inside s_proc1) in this manner:...

Is this select possible in sql?

Consider a table, Id columnA 1 a 2 b 3 c Select ColumnA from table gives the result as below, columnA a b c Is it possible to get ColumnA a,b,c ...

varchar comparison in SQL Server

I am looking for some SQL varchar comparison function like C# string.compare (we can ignore case for now, should return zero when the character expression are same and a non zero expression when they are different) Basically I have some alphanumeric column in one table which needs to be verified in another table. I cannot do select A...

Update or Insert Row depending on whether row is present in Microsoft SQL Server 2005

Hi, I am passing a XML document as a input to a stored procedure in Microsoft SQL Server 2005. This is the sample XML being passed as input <Strategy StrategyID="0" TOStrategyID="8" ShutdownQtySell="1" ShutdownQtyBuy="1"> <ParameterRange ParameterSetID="6" ParameterRangeID="1" ParameterRangeFrom="0" ParameterRangeTo="20" Paramete...

How do I provide a string with a list of values to an "IN" statement

I am creating a string that is a list of comma-delimitted values by looping through the selections in a CheckBoxList. I am able to display this value, so I know that it is creating what I expect. I am attempting to pass this list to an IN statment in a SELECT query: SelectCommand="SELECT ThisDate, DATEPART(dw, ThisDate) AS Expr1 FROM ...

SSIS 2005 - How to figure out what job a sysdtslog90 entry was run under?

Given a entry in a sysdtslog90 table in SQL Server 2005 from an SSIS package, how do you figure out what database agent job the entry was run under? ...

Unexpected behaviour of Order by clause

I have a table which looks like Col1 col2 col3 col4 col5 1 5 1 4 6 1 4 0 3 7 0 1 5 6 3 1 8 2 1 5 4 3 2 1 4 The script is declare @t table(col1 int, col2 int, col3 int,col4 int,col5 int) insert into @t select 1,5,1,4,6 union all select 1,4,0,3,7 union a...

Multiple column sorting (SQL Server 2005)

I have a table which looks like Col1 col2 col3 col4 col5 1 5 1 4 6 1 4 0 3 7 0 1 5 6 3 1 8 2 1 5 4 3 2 1 4 The script is declare @t table(col1 int, col2 int, col3 int,col4 int,col5 int) insert into @t select 1,5,1,4,6 union all select 1,4,0,3,...

multi-part identifier could not be bound error

Here is my query: IF OBJECT_ID('NPWAS1513.dbo.usp_MSPEX_QLK_Billing_Fact_Load') IS NOT NULL DROP PROCEDURE dbo.usp_MSPEX_QLK_Billing_Fact_Load; GO CREATE PROCEDURE usp_MSPEX_QLK_Billing_Fact_Load @create_timestamp datetime, @update_timestamp datetime, @create_user varchar(50), @update_user varchar(50), @dbProdServ varchar(...

sql select statement based on distinct column values....

select distinct * from Drivers where IsDeleted=0 gives me this, I want select * based on distinct DriverMobNo column ...

Stored procedure in scheduler in SQL Server 2005

Hi All, I am using SQL Server 2005. I have a stored procedure [say Sp_GetAllMaterialInfo], I want to put it in a scheduler that everyday this stored procedure execute on 2 P.M. daily. Please let me know the steps I have to follow to achieve in SQL Server 2005 Thanks in advance. ...

Do I need to drop index on temp table?

Hi, Fairly simple question, but I don't see it anywhere else on SO: Do indexes (indices?) on a temporary table get automatically deleted with the temporary table? I'd imagine they do but I don't really know how to check to make sure. Thanks, Phil ...