Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Validate SQL Syntax

Author  Topic 

samsekar
Constraint Violating Yak Guru

437 Posts

Posted - 2005-11-21 : 04:13:54
Hi All,

I need to validate the SQL Syntax stored in a table without using cursor (SQL Server V7), Can someone throw some light on this please !


Create table testsql (tst_id int, sql_sx varchar(1000))

insert testsql values (1, @code = 'CE1')
GO
insert testsql values (2, @code = 'CE2')
GO
insert testsql values (3, @code = 'CE3' OR @code = 'I45')
GO
insert testsql values (4, @code = 'CE4)

In this example the last value is invalid missing quotes.

Thanks

- Sekar

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2005-11-21 : 04:20:54
From the front end you can handle that in the better way..

just pass the query to the sql Server using ADO or any connections you are using..

if the syntax is correct then connection will not return any error.

other wise it will go in catch block .. and you can invoke that the inccorect syntax.

something like this ..

try
{
String str;
str = "Select * From TableName Where Code = 'CE";
conn.Execute(str)// conn is the connection object
}
catch (Exeception Ex)
{
// there is the error in the code..
}

hope this helps you ..

Sucess Comes to those who Believe in Beauty of their Dream..
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-11-21 : 04:21:16
copy it in query analyzer and do parse query (ctrl+F5) ?

Go with the flow & have fun! Else fight the flow
Go to Top of Page

surendrakalekar
Posting Yak Master

120 Posts

Posted - 2005-11-21 : 04:40:06
Try this
http://sqlforums.windowsitpro.com/web/forum/messageview.aspx?catid=60&threadid=44057&enterthread=y

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_set-set_40c4.asp


Surendra
Go to Top of Page
   

- Advertisement -