I once needed the lines of the stored procedures, to be able to trace whether i have a reference to some function, procedure or table, or sometimes to try to find something inside of the sp's code. Where does the sql server stores the procedures's code?
In SQL, can we always write an inner join statement as a main query and subquery or vice versa if we only want to find the intersection?
For example,
select * from gifts g where g.giftID in (select giftID from sentGifts);
can do a join and show the gifts sent in the sentGifts table, but it won't be able to show the sentTime because that is inside the subquery. But if all we care is to find the intersection, without caring what is being displayed, then we can always convert one to the other?
I have a fairly simple MS Access Database that contains some metadata about a bunch of documents and a hyperlink field that links to the document on our network drive.
However, when I use a SQL INSERT statement to populate the hyperlink field, the value I give it only becomes the display text, not the actual link.
How can I make the value a functional hyperlink? I'd think that the hyperlink data type would actually create hyperlinks.
I'm using Access 2002 SP3.
I am aware of other solutions like System.Data.Sqlite or Firebird through Dblinq, but since nothing beats SQL Compact Edition (integration-wise) with Visual Studio, I would like to use it and to know if its license allows its usage in Open Source projects.
Thanks.
i.e. if I create a VARCHAR(50) field, what happens if I try to assign it a value that's 100 characters long?
Will SQL Server let me do this? Is it somehow less efficient?
Which is faster in SQL, While loop, Recursive Stored proc, or Cursor?
I want to optimize the performance in a couple of spots in a stored procedure.
The code I'm optimizing formats some strings for output to a file.
I have an MySQL table with 25000 rows.
This is an imported CSV file so I want to look at the last ten rows to make sure it imported everything.
However, since there is no ID column, I can't say:
SELECT * FROM big_table ORDER BY id DESC
What SQL statement would show me the last 10 rows of this table?
The structure of the table is simply this:
columns are: A, B, C, D, ..., AA, AB, AC, ... (like Excel)
all fields are of type TEXT
I was learning this ORM because think this is good technology for most projects. But most employers required acquirement of ADO.NET andSQL.
This ORM not will use in high-loaded system (like popular web-sites)? In which types of projects this ORM will be useful? Are highly loaded projects using ORM?
Can you create a linked server in SQL Server 2008 and then refer to it with an alias.
So, I create a linked server to "SalesServer", but I give it the alias "Sales", so I can use it like this:
SELECT * FROM Sales.DB1.dbo.DailySales
Sql 2008 is telling me to include the Primary Key in an index in the Included Column field. I thought the PK was automagically returned with all indexes?
In SQL Server, is there any way to check whether the changes in the schema will impact Stored Procedures (and/or Views)?
For example a change of the column name in one table, may break some Stored Procedures; how to check the impacted stored procs?
How can I find out if a Linq to SQL entity has grandchildren or not?
Pseudo-code below:
Return From p In dc.Processes Where p.Signers.Count > 0 and p.Signers.Signatures.Count > 0
Obviously I can't run the code above but I need to make sure that all the returning Processes have at least one Signer and that all of those Signers have at least one Signature.
TIA!
I am trying to write an aggregate udf for using Sql Server 2008 and C# 3.5 that implodes an aggregation of data. The kind of syntax I am looking for is:
SELECT [dbo].[Implode]([Id], ',') FROM [dbo].[Table] GROUP BY [ForeignID]
where the second parameter is the delimiter for the aggregate function. And example return value would be something like:
1,4,56
Is there a way to have multiple parameters in an aggregate udf?
I'm trying to compare the schemas of two tables that exist in different databases. So far, I have this query
SELECT * FROM sys.columns WHERE object_id = OBJECT_ID('table1')
The only thing is that I don't know how to use the sys.columns to reference a database other than the one that the query is connected to. I tried this
SELECT * FROM db.sys.columns WHERE object_id = OBJECT_ID('table1')
but it didn't find anything.
I'm using SQL Server 2005
Any suggestions? thanks!
I need to write a function to delete the login in the database if it does not have any users to map to using SQL Server Management Objects (SMO). How can I achieve this ?
How to automatically generate documentatation of stored procedures of SQL Server 2008 like doxygen does to codes? I read about hyperSQL but it doesn't work nice with Windows.
Thanks!
Gil.
I have a developer that is having trouble connecting to a SQL Server instance by entering the server name (local)\HIS_SERVER_INSTANCE into Visual Studio-Server Explorer. If he replaces (local) with his machine name, it connects fine. I have had similar issues before but they seemed to fix themselves. Does anyone know a fix for this?
The scenario is I want to get the users who has less than 2 photos.
There are two table:
[Users] (UserId, UserName)
[UserPhotos] (PhotoId, PhotoName, UserId)
UserId is a Foreign Key but I do not want to use association like user.Photos.
A user may have none photo in the [UserPhotos] table.
How to use Linq To Sql to get List<User> who has less than 2 photos?
I do like the SQL editor now bundled with Eclipse but I can't seem to find a way for it to format my code like eclipse will with my java.
Did I miss something, or does anybody have any alternatives?
Thanks
====EDIT====
I'd also be happy if there was an alternate plug-in that someone could recommend.
I need a test database to practice joins and other kinds of data retrieval operations in SQL.
What's a good free test database and RDBMS system to use on Windows?
Why is it necessary to remove and then re-add a user to a SQL Server database after restoring it from a file?
If I don't do this, I get a "User login failed" when trying to access the database using this username from apps.
I am testing out my scripts to see if they will prevent xss andsql injections. Can someone provide me with some basic but good scripts that would "hack" into my programs. I want to test my scripts before it goes online.
I am aware of:
SELECT @@ERROR
but it will give me only an ERROR CODE (a number) and I need a full text message like:
Cannot insert duplicate key row in object 'dbo.TABLE_NAME' with unique index 'IX_ID_unique'.
The statement has been terminated.
How can I do that in MS Sql Server 2005 ?
I'm working with an existing database where all dates are stored as integers in the following format: yyyy[3 digit day of year].
For example:
2010-01-01 == 2010001
2010-12-31 == 2010356
I'm using the following SQL to convert to a datetime:
DATEADD(d,
CAST(SUBSTRING(
CAST(NEW_BIZ_OBS_DATE AS VARCHAR), 5, LEN(NEW_BIZ_OBS_DATE) - 4
) AS INT) - 1,
CAST('1/1/' + SUBSTRING(CAST(NEW_BIZ_OBS_DATE AS VARCHAR),1,4) AS DATETIME))
Does anyone have a more concise way to do this?