sql-server

What does "materializing" temporary table mean?

I have noticed quite a few mentions of the word "materializing" when people are talking about using temporary tables in SQL Server. Can someone expand on what it is that means? I am just trying to get a better understanding of what that means in terms of using temp tables? Thanks! S ...

What indexes will I need to make on this SQL Server table?

Hi folks, I have the following sql query for a SQL Server 2008 db. SELECT TOP(@NumberOfStreetResults) LocationType, LocationId, Name FROM [dbo].[LocationNames] WHERE CONTAINS(Name, @SearchQuery) AND LocationType = 7 Notice how I'm using the CONTAINS keyword? I have an FTS on the Name field. I'm not sure what index(s) I need to ...

Why am I getting this error "Internal connection fatal error" in only one of my stored procedures?

This issue is similiar to here. http://stackoverflow.com/questions/1155263/what-causes-internal-connection-fatal-errors Except it's only happening on one stored procedure and is happening all of the time and is only happening when I access this stored procedure from my website. I've even ran the stored procedure in SQL Server and it s...

Get absolute days away

I want to get the absolute days away a datetime is from today. For example, i would like to know if a date is 2 days away, or 78 days away, or even 5,239 days away (not likely, but you get the idea). I am using an MS SQL database which is returning datetimes where the time components are all 00:00:00. date_diff returns relative values...

index seek while calling the UDF itself, index scan while wrapping the UDF in sp

Hi, I have a UDF that does most of the joins and when I run it, it read about 100-150 pages (from sql profiler) but if I wrap this UDF in sp then the sp will do the read about 243287 pages. Furthermore, the UDF itself performs index seek but the sp performs index scan on one of the searched columns. Can anyone please advise? ...

SQL - Insert query Inside another Insert with updated Identity seed

I have 2 tables T1 AND T2 T1 has 10 unique records with a primary key (Identity Seed) T2 has multiple entires with Foreign Key for each record in T1 T1 has 2 columns : PrimaryKey - DATA T2 has 2 columns : PrimaryKey - FoeignKey (this FK is the Primary Key of T1) I need to write a query which will select all the records from T1 and INS...

Convert Sql Server 2008 to Sql Server 2005 Include Data

How can I Convert the SQL Server 2008 to SQL Server 2005 I need the Data of the database and not only the structure using the generate script ...

Help to Simplify SQL Insert which uses NEWSEQUNETIALID() column default

Hi All I have the following insert stored procedure: CREATE Procedure dbo.APPL_ServerEnvironmentInsert ( @ServerEnvironmentName varchar(50), @ServerEnvironmentDescription varchar(1000), @UserCreatedId uniqueidentifier, @ServerEnvironmentId uniqueidentifier OUTPUT ) WITH RECOMPILE AS -- Stores the ServerEnvironmentId...

Global temporary tables in SQL Server

I have a ##table which can be accessed across all the sessions but sometimes I am getting error There is already an object named '##table' in the database. WHY and how to resolve it. ...

SQL Server query help... need to convert varchar to date

Hi All, I am writing a query to fetch results for all the values in a column which is of varchar type.. are less than '29/08/2010' (date) My Query: SELECT * FROM EMPLOYEES WHERE COLUMN1 < '29/08/2010' Here the column1 is of varchar type. I am using SQL Server 2005 Is there a way to make this possible..?? Pls help me. Thanks in ad...

Access-like editor for SQL Compact Edition

I'd like to find the best editor for flat SQL Server Compact edition databases. Essentially we want to push around arbitrary flat typed datasets of under 4 Gb each and have a good editing experience for manipulating this data. Access isn't the first thing that comes to mind, but I'm looking for a more "de facto" approach rather than the ...

difference between set @flag =1 and set @@flag = 1

Hi What is the difference between set @flag=1 and set @@flag = 1 in SQL Server? Thank you ...

VBscript - SQL Connection fails SQL Server does not exist or access denied

Hi, this is pretty strange. I've got this string that connect to a SQLServer in the same domain as the computers are running and compares username with employeeID. Then takes that row and dumps it into the lokal computers registry. This is working in Windows XP, but not Windows 7 it seems. I get this exact error message: Line:39 Char:...

Some tables in SQL Server require [user].[table] and others don't, why is this and can I force it?

As the title suggests I am confused as to why some tables in my database fall over if you do something like; SELECT * FROM [user].[table] And yet on another tables it works fine. I am testing some code that will eventually be on a server that cries if you don't use [user].[table] so I would really like to force this on my machine. C...

TSQL Trim - Portable Method

I have a string in the following format 'DOMAIN\username'. I wish to trim the domain and the backslash from the string. I cannont simply use RIGHT() as we have multiple domains of varying length. What is the most portable way to do this? Thank you. ...

functionality for a title textbox.

Hi, I am designing a question module. What i want is while i'm typing something in a textbox (called title), it should list titles of other questions that have already been asked. But not done as AutoCompleteText. I'd like those listed questions to pop up near the textbox and be set as a hyperlink, and by clicking on that link will res...

Modify table: not null to null

How to change one attribute in a table using T-SQL to allow nulls (not null --> null)? Alter table maybe? ...

Can I: loop through sql select and then fire off for each loop?

Hi All, I'm probably missing something (looking at it too long), but in a stored procedure can I select all distinct values from one table and then do a for each loop based on each of those returned rows, which themselves build up sql statements based on the distinct values? Cheers. ...

Understanding locking behavior in SQL Server

I tried to reproduce the situation of question [1]. On table, taken and filled with data from wiki's "Isolation (database systems)" [2], in SQL Server 2008 R2 SSMS, I executed: 1) first in first tab (window) of SSMS -- transaction isolation level in first window does not influence results (?) -- initially I thought that second ...

Can i install a new instance on one node of a sql server cluster?

Hi, I have a SQL Server clustering test environment. One domain controller, two nodes. Can I install other instance on the two node beside the clustered instance? Thanks. ...