Friday, March 23, 2012
running .sql file
Sure, check out the advice given by Thona in this thread:http://forums.asp.net/613349/showpost.aspx.
|||thank you
Wednesday, March 7, 2012
Run a query that I have stored in a table cell
This is embarasing.
I'm creating a 500 line query from XML, CSV's, etc. and I can't fingure this out.
I'm building a very complex "SELECT" query and then shoving it into the [Select] column in a SQL 2005 table. I want to call a stored procedure that just "executes" that query and returns the results...
Any help would rock.
Gah, can't believe I didn't get it.
I was trying:
EXECUTE ((SELECT [Select] FROM [Item].[Filters] WHERE FilterID = @.FilterID))
And it needed to be:
DECLARE @.Select VARCHAR(5000)
SET @.Select = (SELECT [Select] FROM [Item].[Filters] WHERE FilterID = @.FilterID)
EXECUTE (@.Select)|||
I dont know if i have interpreted your query correctly but is this what you are looking for:
CREATEPROCEDURE [dbo].[uspMyDynamicQuery]
(
@.ColumnsASVARCHAR(400)--pass the columns in like field1, field2, field3 and etc.
)
AS
SETNOCOUNTON;
DECLARE @.SQLASVARCHAR(4000)
SET @.SQL= N'SELECT '+ @.Columns+ N' FROM tbl'
EXEC(@.SQL)
|||
Thanks for the reply :)
I have it working in the 2nd post. I basically did the same thing you did, but rather than build @.SQL, I just retrieve it.
Saturday, February 25, 2012
Rules and defaults
Hi,
Can any one provide me information on creating rules and defaults in SQL Server2005, when i tried right clicking rules or defaults in management studio instead of new option i'am getting only refresh option.
This feature was working smoothly in sql2000.....I'am trying this on Microsoft SQL Server2005 Standard Edition.
thanks in advance
Mat
Rules and defaults are deprecated in 2005. You should now use constraints, which you define in the table designer. Rules and defaults are still supported, but you have to create them manually by writing the code yourself. You cannot create them in Management Studio because you should not be using them any more.
This comes from the 2000 documentation
"Rules are a backward-compatibility feature that perform some of the same functions as CHECK constraints. CHECK constraints are the preferred, standard way to restrict the values in a column."
"Defaults, a backward compatibility feature, perform some of the same functions as default definitions created using the DEFAULT keyword of ALTER or CREATE TABLE statements. Default definitions are the preferred, standard way to restrict column data because the definition is stored with the table and automatically dropped when the table is dropped."
And this from the 2005 documentation
"CREATE RULE will be removed in a future version of Microsoft SQL Server. Avoid using CREATE RULE in new development work, and plan to modify applications that currently use it. We recommend that you use check constraints instead."
"CREATE DEFAULT will be removed in a future version of Microsoft SQL Server. Avoid using CREATE DEFAULT in new development work, and plan to modify applications that currently use it. Instead, use default definitions created using the DEFAULT keyword of ALTER TABLE or CREATE TABLE."