sql-server

output parameter

how to get output parameter from stored procedure of one table and by using that value how to insert data in another table which is in realation with that table? ...

Does SQL Server transform text in any way when performing a BULK INSERT?

I'm trying to use a BULK INSERT statement to populate a large (17-million-row) table in SQL Server from a text file. One column, of type nchar(17) has a UNIQUE constraint on it. I've checked (using some Python code) that the file contains no duplicates, but when I execute the query I get this error message from SQL Server: Cannot inse...

SORTING Hierarchical Queries in SQL Server 2005

I have following issue: I have a table for maintaining the hierarchical data. I'd like to use CTE from SQL 2005. WITH tree (id, parentid, code, name) AS ( SELECT id, ofs.ParentID, ofs.code, ofs.name FROM OrganizationFeatures ofs WHERE ofs.ParentID IS NULL UNION ALL SELECT ofs.id, ofs.ParentID, ofs.code, ofs.name...

SQL Server - Combining OUTER and INNER joins

I have 3 tables and I have to inner join Table A with Table B but a left outer between Table A and Table C. Can I combine outer and inner join in the same query? I can nest queries and attain the desired result but I am unable to do both the joins in the same query. It appears that in other SQL languages, the order of joining is import...

SQL queries to test query building capabilties

I was thinking of building a small application to help fellow developers to learn advanced query concepts with a Q&A applications. I need some SQL expert to list a bunch of tough queries and also provide the sample table schemas used. ...

What are the concerns of having Temp/variable tables inside a view?

a friend of me is asking if i know any reasons why he should not included Temporal or variables tables inside a View in SQL-Server 2000. i could only think that a new table will be created everytime the view is accessed but i am wondering is there are any other concerns. Thanks, EDIT: This is not Possible ...

Typical SQL Server authentication approach for Internet-facing app server

I work on an Internet-facing, ASP.NET-based product that uses SQL Server 2005. Most customers deploy our software using the traditional approach with the app server (IIS) located in a DMZ, and SQL Server behind a secondary firewall. We would like to pick one type of SQL Server authentication. From a security perspective and/or a custome...

SQL 'Or' operator. How does it work in the following scenario?

I've been working on optimizing a query and have ran into a situation that's making me question how I've always used SQL's OR operator. (SQL Server 2000 also) I have a query where the conditional (WHERE) clause looks something like this: WHERE (Column1 = @Param1 or Column1 LIKE @Param1 + '%') AND (@Param2 = '' OR Column2 = @Param2 OR C...

Static Port Assignment in SQL Server 2008 Does not save

I have two named instances of SQL Server 2008 and am trying to set static ports for each instance. I open the SQL Server Configuration Manager _> expand "SQL Server Network Configuration" -> click the instance I want to change -> and select TCP/IP. From here any configuration changes that I make are not persisted after I hit OK. I've ...

Sql SMO: How to get path of database physical file name?

I am trying to return the physical file path of a database's mdf/ldf files. I have tried using the following code: Server srv = new Server(connection); Database database = new Database(srv, dbName); string filePath = database.PrimaryFilePath; However this throws an exception "'database.PrimaryFilePath' threw an exception of type 'Mi...

NULL vs Default Value in SQL Server Database

Are there any implications to using default values, such as empty strings, when inserting rows into a database. The problem with using nulls that they have to be checked for when using the data in an application, whereas a default value can be handled much easier. ...

Disadvantage of choosing large MAX value for varchar or varbinary

What's the disadvantage of choosing a large value for max when creating a varchar or varbinary column? I'm using MS SQL but I assume this would be relevant to other dbs as well. Thanks ...

What is the build number of SQL Server 2008 Web Edition that RTMed?

My title is the full question: What is the build number of SQL Server 2008 Web Edition that RTMed? ...

Sql server Database Suspected marked ?

My sql server marked one database as suspected , on checking i found my mdf,ldf files are missing, but no errors on chkdsk, what it means some virus ? ...

How can I update a small field in a big SQL table if another field in the same row is changed by an external process?

I'd like to call Update ... Set ... Where ... to update a field as soon as that evil ERP process is changing the value of another. I'm running MS SQL. ...

if exists statement in sql to linq

What is the linq equivalent of the following statement ? IF NOT EXISTS(SELECT UserName FROM Users WHERE UserName='michael') BEGIN INSERT INTO Users (UserName) values ('michael'); END also can you suggest any sql-to-linq converters? I am currently using LINQPad which does a great job in terms of writing linq code where you can also see...

SQL Server to mySQL converter

Hai Techies, I have some stored procedure which was written in SQL server.Now i want to migrate this to mysql.Is there any freeware tools which can do this for me. ...

Is it possible to execute a stored procedure over a set without using a cursor?

I would like to execute a stored procedure over each row in a set without using a cursor with something like this: SELECT EXEC dbo.Sproc @Param1 = Table1.id FROM Table1 I am using T-SQL in SQL Server 2005. I think this might be possible using a function, but I'd like to use a stored procedure if possible (company standards) ...

How does normal SPs handle exception thrown by managed SPs

I read that SQL exceptions are treated as normal exceptions in managed SPs; I would like to know how is following scenario handled w.r.t to this. I have a normal t-SQL SP that calls a managed SP. managed SP throws exception due to some issue. How does normal T-SQL handle this. I have not tried this scenario yet as I do not have SQL s...

SQL Server column relationships

I've got two tables. One is "Corporations" (e.g., one record is for Taco Bell). The index and PK for this table is named "Id". I've got another table: "Branches" (e.g., one record is for Los Angeles). The Branch table has a column named "Corporation". This column should only accept an "Id" value that corresponds with an "Id" in the "Co...