sql-server

PRINT statement in T-SQL

Why does the PRINT statement in T-SQL seem to only sometimes work? What are the constraints on using it? It seems sometimes if a result set is generated, it becomes a null function, I assumed to prevent corrupting the resultset, but could it's output not go out in another result set, such as the row count? ...

Foreign key referencing composite table

I've got a table structure I'm not really certain of how to create the best way. Basically I have two tables, tblSystemItems and tblClientItems. I have a third table that has a column that references an 'Item'. The problem is, this column needs to reference either a system item or a client item - it does not matter which. System items h...

BCP out Error in SQL2000: SQLState = 37000, NativeError = 4060

Hi, I have created a proc that grabs all the user tables in a local DB on my machine. I want to be able to create a flat file of all my tables using BCP and SQL. Its a dummy database in SQL 2000 connecting through windows authentication. I have set my enviroment path variable in WinXP SP2. I have created new users to access the db, swi...

Asp.net -best place to trap SQL Server sql errors

For Asp.net web applications, is it best to: trap errors within sql stored procedures and test for a return value in the code or just let the error occur in sql (dont handle it) and rely on ado.net raising the errors within the code. What are the best practises here? ...

Can osql.exe run as a standalone?

Hi, I have a program that runs osql.exe from microsoft sql server tools directory and runs a script. The problem is that on computers that don't have an installation of sql server, this tool is missing. So my question is whether or not is possible to run it as a standalone( along with any dll that may be required ) meaning that run th...

Generate Random values from SQL

It appear that SQL Server like most other products Random Function really is not that random. So we have this nice little function to generate a 10 char value. Is there a better way to accomplish what the following does. I am betting there is. DECLARE @SaltCount INT; SELECT @SaltCount = COUNT(*) FROM tmp_NewLogin; PRINT 'Set Salt val...

SQL 2005 sql login ip restriction

Is there a way to restrict a specific sql 2005 login on a Microsoft SQL Server 2005, standard version (sql is in mixed mode) to specific IP adresses, while other logins, windows authentated ones, are unaffected? ...

How can you detect on runtime if your sql-server 2005 instance is a 32 or 64 bit instance?

How can you detect if your sql-server 2005 instance is a 32 or 64 bit instance from C# code? If you know some documentation on this issue, please let me know.. Thanks! ...

What are some useful third-party SSIS components (data flow or control flow)?

The number of products out there right now still seems to be slim. ...

What is the connection string for odbc connections?

I've always done web apps and now I need to do a console app. I need to use both an odbc connection and a regular connection. In the past I would have used: <add name="LinkConnectionString" connectionString="Data Source=SERENITY\SQLEXPRESS;Initial Catalog=Link;Integrated Security=True" providerName="System.Data.SqlClient"/> In the w...

Sql Server Management - Option to avoid scripting the collation?

I have databases with different collations. I want to be able to script out tables from one database and create them in another. However, when I script out the tables, it includes the collation in the column definitions. Is there a way to exclude the collations from the generated table creation scripts? ...

Finding Unique Table/Column Combinations Across SQL Databases

I have 4 databases with similar schema's, and I'm trying to create a query to return just the table, column pairs that exist ONLY in database 1 and do not exist in database 2, 3, or 4. Currently I can return the symmetric difference between database 1 and 2 via the following query... select table_name, column_name from ( select ta...

SQL Reporting Services cannot configure virtual directories

I have an issue where we tried to upgrade our TFS 2005 server to 2008. During the install we encountered the error that it could not configure SQL Reporting Services. The log files showed that during the creation/configuration of the virtual directories for SQL Reporting Services (the Reports directory to be exact) a FileNotFoundExceptio...

SQL - querying via a textbox which could take different values

Developing a website and just trying to get back into the swing of (clever) SQL queries etc, my mind had totally gone tonight! There is a website http://www.ufindus.com/ which has a textbox allowing you to enter either a place name or a postcode/zipcode. I am trying to do something similiar but I am rubbish at SQL - so how do you const...

3rd Party Password Management with Complete Integration

I use C#, IIS, ASP.NET, SQL Server. Is there a third-party platform I can easily integrate into my system, to handle password management? It would have to integrate 100% (no OpenID), so that the users would not notice. ...

How would I go about figuring out the maximum load my server(s) can handle?

In Joel's article for Inc. entitled How Hard Could It Be?: The Unproven Path, he wrote: ...it turns out that Jeff and his programmers were so good that they built a site that could serve 80,000 visitors a day (roughly 755,000 page views) How would I go about figuring out the maximum load my server(s) can handle? ...

Should I drop and create indexes on my tables that SQL Server created?

In an effort to get rid of some fragmentation left from rebuilding and defraging we thought that we would drop and create indexes so I went to write a script. It identifies a clustered index that needs work and drops indexes and primary keys and rebuilds the indexes and primary keys for a table. Here is the problem I ran into: SQL Serv...

Should I install SQL Server 2008 on my DEV machine?

I'm wondering if I'll have trouble installing SQL Server 2008 on my development machine whilst our production server is 2005? E.g. is something change so that my 2005 databases/sps/functions/views will not work correctly or other issues I should think about? Would like to do this just to test drive the new SQL Server but still be able t...

Designing a Stored procedure to create XML tree

I need to write a Stored procedure in SQL server whose data returned will be used to generate a XML file. My XML file to be in structure of <root> <ANode></ANode> <BNode></BNode> <CNode> <C1Node> <C11Node></C11Node> <C12Node></C12Node> </C1Node> <C2Node> <C21Node></C21Node> <C22Node></C22Node> </C2Node> <C3No...

Getting Dates between a range of dates

Hi All, I need to get all the dates present in the date range using SQL Server 2005 ...