I am trying to get the first part of a Guid Field with the TSQL substring function as follows
SELECT SUBSTRING(Guid, 1, 8) AS Gu FROM MyTable
but all i get is this error.
Argument data type uniqueidentifier is invalid for argument 1 of substring function.
So what is going on here? Should i treat the Guid as pure string first or...?
...
My current view produces this kind of output...
Product1 Product2
Jet Ski
Water Polo
Could i use a computed column in a view, in order getting results like these?
Product1 Product2 Computed
Jet Ski Jet Ski
Water Polo Water Polo
...
With some slower machines that our application runs on (which is in the windows startup folder), when the machine is Rebooted and autologged on, the SQL Server service is still in a starting up state when my application is launched. (SqlServer 2005)
What I've done to counter this is to Check the Service state (MSSQL$idealsql) and wait ...
Is there any tool available by which one can calculate the size or a single row in sqlserver. This would really help in calculating the expected size of DB. Further one option can be to use sp_spaceused but it gives the details of the whole table... what we want is the size of a record (maximum size) in a table.
Further is there any to...
Hi All,
i am storing images to the database. How to retrieve all the images from the database.
Eg: select images from imagetable
Problem:
Data Logic:
while (dr.Read())
{
///Check for null
if (!dr.IsDBNull(0))
{
try
{
///C...
hi,
how can i write the store procedure for searching particular string in a column of table, for given set of strings (CSV string).
like : select * from xxx where tags like ('oscar','rahman','slumdog')
how can i write the procedure for that combination of tags.
...
I'm currently trying to build a High-Availability and load-balanced web application with Sql Server Replication technologies. Automatic fail-over is built into the application logic. Basically, there are two groups of app servers running the same, each with its own Sql instance. They are set to use the other instance in case of failure. ...
How can you create a new job in SQL Server 2005 with the use of code? And not in SQL Server Management Studio.
...
I have this query:
select id from table where date >= @idate
I want to set the time of the date attribute in the where = 00:00
How can I do it?
...
I've been investigating making performance improvements on a series of procedures, and recently a colleague mentioned that he had achieved significant performance improvements when utilising an INNER JOIN in place of EXISTS.
As part of the investigation as to why this might be I thought I would ask the question here.
So:
Can an INNER...
I am having an issue with SQL Server 2005's BCP utility. I am running SQL Server Express 2005 on Windows Vista. I am trying to create a non-XML format file for some tables in my database.
I run the following code:
bcp 'jProd_000-1'.users format nul -T -f users.fmt
I get the following error:
An Error occurred while processing the...
Given the SQL Statement:
SELECT *
FROM MY_TABLE
WHERE SomeNumberField in (0,99999)
If I can guarantee that the majority of rows in MY_TABLE have SomeNumberField set to 99999, and can project that this will remain the case indefinately, is it better to write the above query like this:
SELECT *
FROM MY_TABLE
WHERE SomeNumberField in ...
I need to fetch top first row out of each duplicate set of records from table given below.
I need to use this query in view
please no temp table as I have already done it by adding identity column and min function and group by. I need solution without temp table or table variable
This is just sample data. Original has 1000s of records...
If I have a set of SQL (ie. a script containing arbitrary SQL statements), is there any way of finding out what the minimum permissions are required to execute the SQL?
(I'm thinking of something similar to the "Permissions required by the application" area in Visual Studio when viewing the Security tab on the project properties page of...
While executing the following statement to bind my database to my datagridview, I get this error:
Cannot find table 0.
How can I determine if Tables[0] exists prior to executing this statement? :
myDataView = myDataSet.Tables[0].DefaultView;
I am using SQL Server 2005 Express.
...
I've got a really large table (10+ million rows) that is starting to show signs of performance degradation for queries. Since this table will probably double or triple in size relatively soon I'm looking into partitioning the table to squeeze out some query performance.
The table looks something like this:
CREATE TABLE [my_data] (
...
I know my title isn't exactly worded well, so let me clarify. I'm using SQL Server 2005 Express.
I have a table that basically stores a "template," if you will. Using a car as an example, the fields would be something like:
TemplateID
Color
Make
Model
Now, I have another table that represents an "instance" of the template. It cont...
Hi:
We have the ability to execute stored procs from the middle-tier. Basically, in a database table called "SQLJobStep" we have -- among other things -- a varchar(300) column called "StoredProcedure" which holds something like this:
usp_SendReminderEmails @Debug=0, @LoginID
Via the middle-tier, a user clicks on a link to run the pro...
I'm storing data in a varbinary(max) column and, for client performance reasons, chunking writes through the ".WRITE()" function using SQL Server 2005. This works great but, due to the side effects, I want to avoid the varbinary column dynamically sizing during each append.
What I'd like to do is optimize this by pre-allocating the varb...
How do you add a unique constraint in SQL Server 2005 to two columns? So lets say that I have:
PK, A, B ...
x1 1 1
x2 1 2
x3 2 1
x4 2 2
I should not be able to add another row 'x5' and have the values for A and B be 1,1 as they are already in the database in x1?
Ok we managed to get it to work and thanks to OMG. Go to the t...