sql-server

MS SQL SERVER: sql queries compared to general programming

i'm just starting out with ms sql server (2008 express) and spent the last hour or so trying out some basic queries. how does sql scripting (correct term?) compare to general computer programming? is writing sql queries as involved, lengthy to learn, needs as much practice, etc. as software development? is writing advanced sql queries co...

Setting indexed columns on a custom SQL table

Hi, I've read about primary, unique, clustered indexes etc. But I need to understand it via an example. The image below is the auto-generated aspnet_Users table captured from SQL Server Web Admin Panel. Taking this as a model; I will create a custom table called Companies and let's say the fields are: ID, Name, ShortName, Address,...

Setting the UpdateCheck.Never mode by default in Visual Studio 2010 DBML designer (MS SQL/ASP.NET MVC)

In my web application I do a lot of updates. And therefore the only acceptable UpdateCheck mode for all columns except for the primary key one is "NEVER". But unfortunately the DBML designer automatically sets the "ALWAYS" mode. So I have to go through dozens of columns to change it manually, and when I have to update the DBML file... ...

How can I add stored function to Entity Framework

Hi to all. I'm trying to add a sql (stored) function to Entity Framework, but unsuccessfully. I tried with right clicking on a table in .edmx and "Function Import", but the function is not shown there, although I added it (updated model from the database). Does anyone have solution for this? ...

SQL Server: invalid object name in query execution

I'm trying to execute an Insert statement, but keep getting a Invalid object name error. Here's my code: public string addNewComment(int userID, int pageID, string title, string comment) { string query = "INSERT INTO dbo.nokernok_kommentarer (userID, pageID, commentTitle, comment) " + "VALUES ("+ userID +", "+ pageID +", '"+ ti...

Zend Framework and MSSQL database

Hi, Is it possible to take advantege of MSSQL in Zend Framework? I tried run my zend server with pdo_mssql, sqlserver and odbc and failed each time. Did you menage to use Microsoft database in your project? Kind Regards, ...

ssis - INSERT variable values into a table

I have several variables in an SSIS package that I would like inserting into a table. example:- @financialMonth, @Status, @Comments The Variables have been populated along the way with values based on lookups, filename, dates, etc, and I want to store them in a results table. Is using the execute SQL task the way to do this ? Do I ...

How can I specify the database password when running database unit tests during the build?

I'm trying to integrate database unit tests into the build process (Visual Studio 2005, TFS, VS for Database Professionals, MS SQL Server 2005). The build is running on a dedicated build server. When the tests (that work perfectly locally) start running on the server, I get a "login failed" error because the database password I save in T...

How should I rename many Stored Procedures without breaking stuff?

I've inherited an ASP.NET website with C# behind, pulling in data from MS SQL Server. The database has had several successive maintainers over the years and any naming guidelines that may have once been in place have been ignored. I'd like to rename the stored procedures to a consistent format. Obviously I can rename them from within ...

Linq 2 SQL Syntax Help

I am almost done converting a MySQL app to Linq2SQL but struggling to get my head round this last SQL query SELECT a.URL, b.URL AS DuplicateURL FROM Pages a INNER JOIN Pages b ON a.MetaDescription = b.MetaDescription AND a.PageID <> b.PageID WHERE a.DomainID = @reportid AND b.DomainID = @reportid AND LENGTH(TRIM(a...

query with join of 3 tables.

I want a single query to produce the following results.. To result in records that are in table1 and in table2 and were not in table3. There are more than 10,000 records in each table..so i am looking for an efficient one. In all the table Cono is the primary key.. In detail with tables. TABLE 1:- Cono th-123 th-124 th-125 T...

Version Controlling Database that is used by multiple projects

Hi Everyone, I'm currently working on a project that has several 'Visual Studio Solutions'. One is for the main application and the others are component-based projects which will be reused in other applications. The problem is that all three solutions need to access data from the same database. Each component has its own set of views...

Tough T-SQL to display org chart (hierarchy / recursion)

Please do not point me to an article on how to create tree structures, or CTEs in SQL I've read plenty!!! I think this may not be so tough for the t-sql at heart but it is definitely tough for me :). Here is the situation, I have to create a report that looks like this: This works great when the parameter to my stored procedure (SQL...

Obtaining / resetting password from an MS SQL .BAK file?

Hi, We have a client who wants us to extract data from their MS SQL bak file. I've gone to restore it, but I'm just getting: TITLE: Microsoft SQL Server Management Studio Express An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo) ADDITIONAL INFORMATION: Access is ...

Validation against to database

I have several textboxes and users are entering same data in one of these fields. I have another table which is store machine_no. I would like to restrict user for possible wrong entries. Example if there is no machine_no #4 on table, user will be warn with message box. Machine_no Value1 In first day 1 500 2 ...

How do I retrieve and image datatype from SQLServer 2005 without programmatic access from some other language.

I have a SQL Server 2005 table with an image datatype as on of the table fields. I have a specific row I am interested. I'd like to write the binary data in the image field to a file on a network share. Let's call the share \server\sharename ...

Large Data Service Architecture

Everyday a company drops a text file with potentially many records (350,000) onto our secure FTP. We've created a windows service that runs early in the AM to read in the text file into our SQL Server 2005 DB tables. We don't do a BULK Insert because the data is relational and we need to check it against what's already in our DB to make ...

What is the significance of 1/1/1753 in SQL Server?

Why 1753? What do they have against 1752? My great great great great great great great grandfather would be very offended. ...

SQL Connection Methods and best practices

So normally I just put my sql connection string in my asp.net web.config and reference it whenever I need to open a database connection, however this leaves me with referencing it all over my project. This also exposes my sql connection username and password in my web.config if it isn't encoded. What are you best practices as far as kee...

Create SQL job that verifies daily entry of data into a table?

Writing my first SQL query to run specifically as a SQL Job and I'm a little out of my depth. I have a table within a SQL Server 2005 Database which is populated each day with data from various buildings. To monitor the system better, I am attempting to write a SQL Job that will run a query (or stored procedure) to verify the following: ...