Programatically Verifying SQL Syntax

Nov 24, 2004

OK, so I'm working on a project that requires the dynamic generation of SQL statements. Now in Visual Studio .NET I'm sure many of you have used that wonderful visual database tool that allows you to magically "verify sql syntax" at the click of a button. It takes a query that looks like this:





"SELECT A.AFFID, A.UserName, A.Pass, A.FirstName, A.LastName, A.Company, A.Street, A.City, A.State, A.ZIP, A.Country, A.phone, P.EMail, A.RecieveEMail, A.SSN, A.JoinDate, A.AffType, P.ProductId, P.BuyerId FROM Affiliates A, Purchases P WHERE (ProductId > 0) ORDER BY 1"





and transforms it into something that looks like this:





"SELECT A.AFFID, A.UserName, A.Pass, A.FirstName, A.LastName, A.Company, A.Street, A.City, A.State, A.ZIP, A.Country, A.phone, P.Email, A.RecieveEMail, A.SSN, A.JoinDate, A.AffType, P.ProductID, P.BuyerID


FROM Affiliates A CROSS JOIN Purchases P


WHERE (P.ProductID > 0)


ORDER BY A.AFFID"





My question is: is there anything in the .NET platform that would allow me to achieve the same kind of result programatically (i.e. transform standard sql to tsql syntax and verify the syntax of the query at run time)?





Any help would be appreciated! Cheers.

View 2 Replies


ADVERTISEMENT

Verifying URL's In Table

Mar 30, 2008

Does anyone have a routine that can verify URL's in a database table.  I have a table with several thousand website addresses and I would like a way to check and see which ones resolve and which return Page Not Found error.  I quess my question is how do you interrogate a URL and what do you look for coming back?  Novitiate for many I am sure but not for me.
Thank you.

View 3 Replies View Related

Verifying A Backup

Jun 27, 2006

Hey Folks...
Very new to SQL Server. I've inherited numorous SQL Servers and wanted to know how I can tell if a backup is scheduled and how I can tell if it completed successfully? Thanks in advance....

Mike D.

View 5 Replies View Related

Verifying Authentication

Nov 14, 2005

Hi guys,

View 4 Replies View Related

Verifying Entry Is Not In DB B4 Inserting

Jun 4, 2007

How do i do that... in sch lab, the lecturer said:    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click        Try            SqlDataSource2.SelectParameters("Title").DefaultValue = txtProductTitle.Text            GridView1.DataBind()            If GridView1.Rows.Count > 0 Then //if no repeated                 Label1.Text = "Existing Record Found. Please enter another Software."            Else                'SqlDataSource1.Insert()                'Label1.Text = txtProductTitle.Text & " successfully added to the database."            End If        Catch ex As Exception            Label1.ForeColor = Drawing.Color.Red            Label1.Text = "An error occured!" & ControlChars.NewLine & ControlChars.NewLine & _            ex.Message.ToString()        End Try    End Sub but its not working for me... the GridView1.Rows.Count is always 0, if there is a repeat, it should be > 0 

View 4 Replies View Related

Need Help In Verifying User Login

Feb 19, 2005

To: All,

Hi, well thanks for reading this thread. Anyway I got a problem where i can't accurately verify whether a user had successfully login to my application.

I got a database to store the user name and password. So whenever a user login, i would use a while loop to read all the user name and password, and an if statement to verify whether the user's name and password matches to the ones stored in the database. This method doesn't work when there are multiple records in my database, because the if statement would compare the user given name and password with all the user name and password in the database. Hence resulting a mismatch.

Well I really hope that you understand what my problem is, really need help with this problem as I'm really clueless. Can somebody please help me, please teach me how to rectify this problem?

Well i think the core problem would be to compare the user name and password with the records in the database one at a time, and once it is found, stop comparing and allow user to enter site.

Yup I think that's all, sorry for the lengthy thread. Anyway thanks a million and have a nice day.

From: iaciz

View 2 Replies View Related

Verifying SQL Server Licensing

Aug 8, 2006

How do I tell what SQL licensing option (processor, device CALS or user CALS) was taken when the server was installed? I have taken over a SQL 2005 server and I would like to check how many CALS (if any) it is licensed for.

View 2 Replies View Related

Verifying Ms Sql Server Desktop Installation

Feb 20, 2005

I am trying to use msde for the startup kits. but i cannot connect to it. How can I do a simple test to verify it is installed and that I can log into the db?

Thanks
Ron

View 1 Replies View Related

Verifying That A Task Completed Successfully

Oct 4, 1999

How can a tell if a tak completed succesfully from a stored procedure?

I have a task which is executed from a stored procedure. The sp_runtask only returns whether the task started successfully. How can I tell if it completed successfully?


Thanks

View 3 Replies View Related

Verifying Connection To 3rd Party Application

Jul 23, 2005

Is there a way that SQL can automatically look at each users'connection and make sure it is still connected through the third partyapplication? The problem is that when a connection to this applicationis not terminated properly, the SQL server is not notified of thedisconnect and the user cannot log back into the application until allthe processes are completed and the original session terminated.Thank you.

View 1 Replies View Related

Stored Procedure For Verifying Data Existence

Jun 26, 2006

Hello All,
I'm trying to develop a stored procedure that would do one of TWO things:
1.  Return a 'status' that a value does not exist, if I were to provide the parameter via an ASP.NET2.0 page
2.  If it does exists, to return the row data associated with that value (id number)
The stored procedure would search a SQL Server table within it self first.  It that fails it would look at an Oracle table (work order table).  And if that fails to return a 'row' to look through another Oracle table (work request table).  If that doesn't occur, then it would throw the result as described in #2.
If the result exists in one of the TWO Oracle tables it would then insert that row into the first SQL Server table that the stored procedure searched through AND would return the row set to the ASP.NET page.
While all this is happening, I was hoping to get some insight as to how to create a "Please Wait..." feedback and then moving to the final result.
Looking forward to the wise words of the many on this forum, as I have experienced in the past!  :)
 

View 2 Replies View Related

Verifying A Table's Column Count Across Servers?

Jan 31, 2005

Hi folks!

The boss has decided that the data from a table we have on one database (containing daily data) needs to be copied to a "history" table on a different database, on a different server.

The transfer will probably be done with a scheduled stored procedure, and all columns will be transferred EXCEPT for two columns in the source table, which are not present in the destination table. This means instead of an "INSERT Dest SELECT * FROM Source" I have to do an "INSERT Dest SELECT yada,yada,yada... FROM Source" in order to disregard the columns we don't care about. NO problem.

I was thinking (you should smell trouble - and sawdust burning at this point) that this leaves us open to a punch below the belt later when a new column is added to the Source table, since we are using a definitive list of columns to move rather than a *, and the new column could be added without the otherwise system-generated, *-sponsored "gentle reminder" that it also needs to be added to the Dest table. I'm not as convinced as The Boss that "Oh, I'm sure we'll remember to add it to the history table when that happens" :lol:

So, long story shorter (nah...too late for that) - I figure I can write a check at each day's historical transfer on the count of columns in one table verses the other, and send an email or fail the job if the count doesn't make sense.

For example, if the Source table has 34 columns, since we don't care about two of them, the Dest table should have 32 columns, if things are still in synch. OK, I think (insert burning sawdust smell here), I can use a SysObjects thang to count rows. BOL points out INFORMATION_SCHEMA.COLUMNS as a possibility.

Here is the code I think (sawdust) can be used:select ((select count(*) from SourceDb.INFORMATION_SCHEMA.columns
where table_name = 'Source') - (select count(*) from HISTSERVER.DestDb.INFORMATION_SCHEMA.columns
where table_name = 'Dest')) as ColumnDiff

Trouble is...this fails because apparently the INFORMATION_SCHEMA thang doesn't do well with remote servers.

Can anyone figure a way around this, or suggest an alternative? I'm still looking, but thought I'd also toss it out onto the board for your generous consideration.

Thanks - and can you BELIEVE the year is already 1/12th of the way OVER?!?!?!
Paul

View 4 Replies View Related

Verifying Column Definitions Across Tables And Views

Aug 22, 2015

Let me explain in simplified terms. We have an ETL process:

1) download data from the iSeries table Cust into SQL table Cust.
2) Tran_Cust is a view created FROM Cust
3) Copy from view Tran_Cust to table ods_Cust
4) v_ods_Cust is a view created from ods_Cust

I want to look for inconsistencies in the column definitions as a column moves from iSeries Cust, SQL Cust, view Tran_Cust, ods_Cust, view v_ods_Cust. The columns generally keep the same names except for v_ods_cust. Here a column like CustName will be created with a more meaningful column name - "CustName as 'Customer Name'.

We have hundreds of tables and we have column definition inconsistences where the host changed their column defintion and we made no changes on the SQL side. Or someone made a SQL column change in one table, but not both tables and the views were not dropped and recreated.

I have the list of tables. Think that I can put together some tsql to loop through the list of tables and create a new table based on the iSeries definition, then compare columns defintion across all the tables and views - except for the v_ods. THis is where columns are given new names - such as "CustName as 'Customer Name'". Need the actual view definition to find that CustName is 'Customer Name' and then compare the definition of ods_Cust.CustName to v_ods_Cust.[Customer Name]

How can I find the view definiton of say v_ods_Cust, seperate out the source column names (CustName) and destination column names (Customer Name) so that I can compare the source column names to another table and fine the differences?

View 3 Replies View Related

Is There A Tool For Verifying Data After Merged Access To Mssqlserver

Dec 24, 2007

hi, all.I want to verify data merged from access in sqlserver.but it has toomany records .so i need a tooldo this.someone maybe has it.thanks

View 1 Replies View Related

Verifying MergeSynchronizationAgent No Longer Requires STA Threading Model

Dec 22, 2006

I've seen a few posts in the MSDN documentation (see links below) stating that the MergeSynchronizationAgent no longer requires the STA threading model in SQL Server 2005 SP1. However, I'm still receiving the following exception message in my synchronization code (where it attempts to access the SynchronizationAgent property):


The MergeSynchronizationAgent class must be instantiated on a Single-Threaded Apartment (STA) thread.

I have Service Pack 1 for SQL Server 2005 installed on both my server as well as my local client (the client is running SQL Server 2005 Express). How can I verify the correct files are there (e.g. are the some specific date/time values for the RMO/COM objects?

Here's the list of MSDN links mentioned above:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=326837&SiteID=1
http://msdn2.microsoft.com/en-us/library/ms146869.aspx
http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.replication.mergesynchronizationagent.aspx
http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.replication.mergepullsubscription.synchronizationagent.aspx

View 3 Replies View Related

Incorrect Syntax Near The Keyword CONVERT When The Syntax Is Correct - Why?

May 20, 2008

Why does the following call to a stored procedure get me this error:


Msg 156, Level 15, State 1, Line 1

Incorrect syntax near the keyword 'CONVERT'.




Code Snippet

EXECUTE OpenInvoiceItemSP_RAM CONVERT(DATETIME,'01-01-2008'), CONVERT(DATETIME,'04/30/2008') , 1,'81350'




The stored procedure accepts two datetime parameters, followed by an INT and a varchar(10) in that order.

I can't find anything wrong in the syntax for CONVERT or any nearby items.


Help me please. Thank you.

View 7 Replies View Related

Programatically Change DBs

Sep 19, 2005

Carlos writes "I am trying to create a sp that would jump from one DB to another using the USE command. I built a string and then I tried to run EXECUTE(@SQLString) with no lock. This is the sample code I am using:

declare @DBName varchar(200)
declare @SQlString varchar(300)
set @DBName='model'
set @SQlString = 'use '+@DBName
execute(@SQlString)

Is there any way I can accomplish that?

Thanks

Carlos"

View 2 Replies View Related

Best Way To Tell If A SP Is A Query Programatically

Sep 16, 2005

Using ADO.NET Or regular queries on SQL Server, is there a good way ofdetermining if a Stored Proc will be returning a result set or if it isa non-query that does all I/O through parameters?Thanks.

View 1 Replies View Related

Subreports Programatically

Dec 27, 2007



Hi

I have a main report and sub report. The subreport has some fields like SYS, LOC, MSG etc.

But the report should display the values filtered basis on system. i.e. I must have a sub report

for SYS1 , SYS2 , SYS3 and so on. I can create a sub report for each system. But I want to create only subreport and

call them from the main report. How do I do this?

Thanks

Sai

View 5 Replies View Related

Incorrect Syntax When There Appears To Be No Syntax Errors.

Dec 14, 2003

I keep receiving the following error whenever I try and call this function to update my database.

The code was working before, all I added was an extra field to update.

Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'WHERE'


Public Sub MasterList_Update(sender As Object, e As DataListCommandEventArgs)

Dim strProjectName, txtProjectDescription, intProjectID, strProjectState as String
Dim intEstDuration, dtmCreationDate, strCreatedBy, strProjectLead, dtmEstCompletionDate as String

strProjectName = CType(e.Item.FindControl("txtProjectName"), TextBox).Text
txtProjectDescription = CType(e.Item.FindControl("txtProjDesc"), TextBox).Text
strProjectState = CType(e.Item.FindControl("txtStatus"), TextBox).Text
intEstDuration = CType(e.Item.FindControl("txtDuration"), TextBox).Text
dtmCreationDate = CType(e.Item.FindControl("txtCreation"),TextBox).Text
strCreatedBy = CType(e.Item.FindControl("txtCreatedBy"),TextBox).Text
strProjectLead = CType(e.Item.FindControl("txtLead"),TextBox).Text
dtmEstCompletionDate = CType(e.Item.FindControl("txtComDate"),TextBox).Text
intProjectID = CType(e.Item.FindControl("lblProjectID"), Label).Text

Dim strSQL As String
strSQL = "Update tblProject " _
& "Set strProjectName = @strProjectName, " _
& "txtProjectDescription = @txtProjectDescription, " _
& "strProjectState = @strProjectState, " _
& "intEstDuration = @intEstDuration, " _
& "dtmCreationDate = @dtmCreationDate, " _
& "strCreatedBy = @strCreatedBy, " _
& "strProjectLead = @strProjectLead, " _
& "dtmEstCompletionDate = @dtmEstCompletionDate, " _
& "WHERE intProjectID = @intProjectID"

Dim myConnection As New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("connectionstring"))
Dim cmdSQL As New SqlCommand(strSQL, myConnection)

cmdSQL.Parameters.Add(new SqlParameter("@strProjectName", SqlDbType.NVarChar, 40))
cmdSQL.Parameters("@strProjectName").Value = strProjectName
cmdSQL.Parameters.Add(new SqlParameter("@txtProjectDescription", SqlDbType.NVarChar, 30))
cmdSQL.Parameters("@txtProjectDescription").Value = txtProjectDescription
cmdSQL.Parameters.Add(new SqlParameter("@strProjectState", SqlDbType.NVarChar, 30))
cmdSQL.Parameters("@strProjectState").Value = strProjectState
cmdSQL.Parameters.Add(new SqlParameter("@intEstDuration", SqlDbType.NVarChar, 60))
cmdSQL.Parameters("@intEstDuration").Value = intEstDuration
cmdSQL.Parameters.Add(new SqlParameter("@dtmCreationDate", SqlDbType.NVarChar, 15))
cmdSQL.Parameters("@dtmCreationDate").Value = dtmCreationDate
cmdSQL.Parameters.Add(new SqlParameter("@strCreatedBy", SqlDbType.NVarChar, 10))
cmdSQL.Parameters("@strCreatedBy").Value = strCreatedBy
cmdSQL.Parameters.Add(new SqlParameter("@strProjectLead", SqlDbType.NVarChar, 15))
cmdSQL.Parameters("@strProjectLead").Value = strProjectLead
cmdSQL.Parameters.Add(new SqlParameter("@dtmEstCompletionDate", SqlDbType.NVarChar, 24))
cmdSQL.Parameters("@dtmEstCompletionDate").Value = dtmEstCompletionDate
cmdSQL.Parameters.Add(new SqlParameter("@intProjectID", SqlDbType.NChar, 5))
cmdSQL.Parameters("@intProjectID").Value = intProjectID

myConnection.Open()
cmdSQL.ExecuteNonQuery
myConnection.Close()

MasterList.EditItemIndex = -1
BindMasterList()


End Sub

Thankyou in advance.

View 3 Replies View Related

Which Is Faster? Conditional Within JOIN Syntax Or WHERE Syntax?

Mar 31, 2008

Forgive the noob question, but i'm still learning SQL everyday and was wondering which of the following is faster? I'm just gonna post parts of the SELECT statement that i've made changes to:

INNER JOIN Facilities f ON e.Facility = f.FacilityID AND f.Name = @FacilityName

OR

WHERE f.Name = @FacilityName


My question is whether or not the query runs faster if i put the condition within the JOIN line as opposed to putting in the WHERE line? Both ways seems to return the same results but the time difference between methods is staggering? Putting the condition within the JOIN line makes the query run about 3 times faster?

Again, forgive my lack of understanding, but could someone agree or disagree and give me the cliff-notes version of why or why not?

Thanks!

View 4 Replies View Related

Converting Rrom Access Syntax To Sql Syntax

Sep 23, 2007


Ok I am tying to convert access syntax to Sql syntax to put it in a stored procedure or view..
Here is the part that I need to convert:

SELECT [2007_hours].proj_name, [2007_hours].task_name, [2007_hours].Employee,
IIf(Mid([task_name],1,3)='PTO','PTO_Holiday',
IIf(Mid([task_name],1,7)='Holiday','PTO_Holiday',
IIf(Mid([proj_name],1,9) In ('9900-2831','9900-2788'),'II Internal',
IIf(Mid([proj_name],1,9)='9900-2787','Sales',
IIf(Mid([proj_name],1,9)='9910-2799','Sales',
IIf(Mid([proj_name],1,9)='9920-2791','Sales',

)
)
)
)
) AS timeType, Sum([2007_hours].Hours) AS SumOfHours
from................

how can you convert it to sql syntax

I need to have a nested If statment which I can't do in sql (in sql I have to have select and from Together for example ( I can't do this in sql):
select ID, FName, LName
if(SUBSTRING(FirstName, 1, 4)= 'Mike')
Begin
Replace(FirstNam,'Mike','MikeTest')
if(SUBSTRING(LastName, 1, 4)= 'Kong')
Begin
Replace(LastNam,'Kong,'KongTest')
if(SUBSTRING(Address, 1, 4)= '1245')
Begin
.........
End
End

end




Case Statement might be the solution but i could not do it.






Your input will be appreciated

Thank you

View 5 Replies View Related

How To Programatically Connect To An SQL Database?

Nov 18, 2006

Can anyone please direct me to an easy to understand Description, Article or Video tutorial that shows an example on how to programatically connect to an SQL database and retrieve data from a collumn using C# and VISUAL WEB DEVELOPER 2005 EXPRESS EDITION. Also, what namespace should be imported to do this? (From what I have gathered out of the help, it seem that System.Web.UI.WebControls is the one)
I am trying to create a "news letter" web page. I have a basic form and when I hit "send" then the code in the background should access the database with all the recipient info, and retrieve all the E-mail addresses, Names, etc. and include it in each e-mail.
( I don't know if it is just me, but the help included with VISUAL WEB DEVELOPER 2005 EXPRESS EDITION is extremely difficult to understand - from a beginner point of view).
Thanks!
Regards
Jan

View 1 Replies View Related

SELECT Columns Programatically

Jul 31, 2007

Hi, I've written a SELECT statement that returns columns dependant on a bitwise parameter @Populate.SELECTCASE WHEN (1 & @Populate) = 1 THEN [Column1] ELSE Null END AS [Column1],CASE WHEN (2 & @Populate) = 2 THEN [Column2] ELSE Null END AS [Column2],CASE WHEN (4 & @Populate) = 4 THEN [Column3] ELSE Null END AS [Column3],CASE WHEN (8 & @Populate) = 8 THEN [Column4] ELSE Null END AS [Column4],etcIs this the most efficient way to acheive this since I am only seeing a small performance gain. It still returns all columns but depending on @Populate will leave some columns with Null values.Any help much appreciated, thanks. 

View 7 Replies View Related

Programatically Get Values From Sqldatasource

Oct 1, 2007

Hi All,
I am having problems getting values out of an sqldatasource.
I have 2 on the page, i am using one to insert into a table and the other to get a couple of values from another table for the insert.
the datasource i am trying to get the values from does a select with a querystring filter i need to grab a couple of fields out of it trhen do the insert on the other datasiource with a button click.
The insert is fine, i just don't know how to get the values out of the first 'select source'
Any pointers or suggestions most appreciated.
Cheers

View 2 Replies View Related

Programatically Create SQL Adapter

Nov 12, 2007

In VS2003 I have a user defaults table that I would call in the OnLoad - No Postback section to get the user defaults and then used some of the fields from that recordset as Parameters for other recordsets that would also load in that same section and might even issue a different Sql statement based on the field. In VS2005 (VB.NET), I can no longer figure out how to accomplish this. I can use the SQLDatasource Control which seems much improved but I cannot even find the generated code which I would use as a quick way to create my own datasources in the OnLoad event. Where is this code now stored and how can I accomplish my objectives in VB.NET 2005 with the current framework or programatically create data sources as necessary as I did before?

View 3 Replies View Related

Generating Tables Programatically

Jun 7, 2008

hi i am trying to gernerate some tables ( first with a script and then with a stored procedure),, in ms server management studio exrress 2005 using the followingcreate table ip(    id int IDENTITY NOT NULL,    ip varchar(15) NOT NULL,    hostname varchar(128) NOT NULL,    primary key(id)) ; i store this in a new query (assume :right click associates the query to the current database ?) and run it and nothing happens  its been a while since i did sql but i think the sql is ok....how or more specifically where is the appropriate place to run this code  thankssimo  stored as a new query     

View 1 Replies View Related

Change SqlDataSource Programatically

Jun 10, 2008

I have a list box populated by a SqlDataSource with a basic statement of Select name where location = @location.       Location is bound to a dropdownlist control.  I want to have a checkbox for the Location dropdownlist and a checkbox for another dropdownlist (for the alphabet) that will select only those people with a last name of the letter selected.  Changing the checkbox would change the sql statement. 
OK so there are two questions here:
1.  How can I write a sql statement that would select only people whos last name begins with a certain letter.  Would it use some sort of convert function to a string with only 1 letter?
2.  How can I programatically change the sqlDataSource's 'select' statement.  I need to switch between sorting by location and sorting by alphabetical last name.  All of my previous experience has had me configuring the datasource in the asp.net code. 
 
Thanks in Advance. 

View 7 Replies View Related

Creating A Table Programatically!

Nov 25, 2003

Hi SQ Gurus,
Please help me with this issue that I am facing. I want to create a table programatically but want to pass its name as a variable. I would like to do something as follows:
CREATE PROCEDURE BS_Create
(@Name nvarchar(25))
AS
CREATE TABLE [dbo].[@Name](
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[Prod_Name] [nvarchar] (75) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
The table name is passed in as a parameter. No matter what I pass as a parameter, the table name is '@Name', which is not what I want. Instead, if the variable contains the value 'Product', I would like to see a table with the name 'Product' to be created.

How can I solve this problem.

Any help is appreciated!
Krish Chandra

View 1 Replies View Related

Programatically Create A Script

Jun 16, 2005

I need some help with the following issue. I need vb.net code that will create a T-SQL script.  For example given the orders table in northwind I would get the following with indexes, RI, ect. :CREATE TABLE [dbo].[Orders] ( [OrderID] [int] IDENTITY (1, 1) NOT NULL , [CustomerID] [nchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [EmployeeID] [int] NULL , [OrderDate] [datetime] NULL , [RequiredDate] [datetime] NULL , [ShippedDate] [datetime] NULL , [ShipVia] [int] NULL , [Freight] [money] NULL , [ShipName] [nvarchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [ShipAddress] [nvarchar] (60) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [ShipCity] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [ShipRegion] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [ShipPostalCode] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [ShipCountry] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY]GO
ALTER TABLE [dbo].[Orders] WITH NOCHECK ADD  CONSTRAINT [PK_Orders] PRIMARY KEY  CLUSTERED  (  [OrderID] )  ON [PRIMARY] GO
ALTER TABLE [dbo].[Orders] WITH NOCHECK ADD  CONSTRAINT [DF_Orders_Freight] DEFAULT (0) FOR [Freight]GO
 CREATE  INDEX [CustomerID] ON [dbo].[Orders]([CustomerID]) ON [PRIMARY]GO
 CREATE  INDEX [CustomersOrders] ON [dbo].[Orders]([CustomerID]) ON [PRIMARY]GO
 CREATE  INDEX [EmployeeID] ON [dbo].[Orders]([EmployeeID]) ON [PRIMARY]GO
 CREATE  INDEX [EmployeesOrders] ON [dbo].[Orders]([EmployeeID]) ON [PRIMARY]GO
 CREATE  INDEX [OrderDate] ON [dbo].[Orders]([OrderDate]) ON [PRIMARY]GO
 CREATE  INDEX [ShippedDate] ON [dbo].[Orders]([ShippedDate]) ON [PRIMARY]GO
 CREATE  INDEX [ShippersOrders] ON [dbo].[Orders]([ShipVia]) ON [PRIMARY]GO
 CREATE  INDEX [ShipPostalCode] ON [dbo].[Orders]([ShipPostalCode]) ON [PRIMARY]GO
ALTER TABLE [dbo].[Orders] ADD  CONSTRAINT [FK_Orders_Customers] FOREIGN KEY  (  [CustomerID] ) REFERENCES [dbo].[Customers] (  [CustomerID] ), CONSTRAINT [FK_Orders_Employees] FOREIGN KEY  (  [EmployeeID] ) REFERENCES [dbo].[Employees] (  [EmployeeID] ), CONSTRAINT [FK_Orders_Shippers] FOREIGN KEY  (  [ShipVia] ) REFERENCES [dbo].[Shippers] (  [ShipperID] )GO
 

View 1 Replies View Related

SQLDatasource - Managing Programatically

Nov 25, 2005

HiI'm trying to access the properties of my datasource programatically so I can change the stored procedure it connects to depending on the value of a querystringIn my page load I have
Dim myMode = Request.Params("mode")Select Case myMode   Case "Category"      sqldatasource1.SelectCommand = "productsbycategory"      sqldatasource1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure      ******'Need to add querystring parameter   Case "Wishlist"      sqldatasource1.SelectCommand = "productsbywishlist"      sqldatasource1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure      ******'Need to add Session variable parameter   Case Else      sqldatasource1.SelectCommand = "allProducts"      sqldatasource1.SelectCommandType = SqlDataSourceCommandType.StoredProcedureEnd SelectThe problem that I have is that I need to pass a parameter to the first 2 procedures above, a querystring to the first and a session variable to the second.How do I add parameters programaticallyMany thanks

View 2 Replies View Related

Checking Services Programatically?

Jul 20, 2001

Hi ,
Could anybody point me to an NT/DOS script ( e.g a batch file ) that could check if the MSSQL Server and SQL Server Agent Services are running ?

I am trying to write the following script to check for the status. Each of the following commands gives a 1 as output if the service is running and 0 if it is not. The problem I am facing is that I am not able to check the output after the command is executed. I am neither able to assign it to a variable or include the whole command in an IF statement.

net start | find /c /i "MSSQLServer"
net start | find /c /i "SQLServerAgent"

Is there any other way to do this programmatically ? Any help is greatly appreciated.

Thank You,
Srini

View 4 Replies View Related

Stop/start SQL Programatically

Apr 11, 2002

What is the best way to programatically stop/start SQL Server? I want to stop it to do backups and then restart it.

I was hoping to do it within SQL Agent but it depends on SQLServer so you can't do a restart.

Any help greatly appreciated.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved