Differences in SQL syntax between SQL Server 2005 and ADO.Net?

I was wondering if there was a compilation of any known differences in the accepted SQL syntax structure between running the query directly in SQL Management Studio and creating the SQL query as a string in the .net application and sending it through SQLCommand and Connection? I was going to ask about a specific problem that I had with one specific query, but as it turned out, I am having several problems with multiple queries. I basically take a set of queries written by someone else and embed them in the .Net parts that I implement, but I believe that I need to configure most of the queries (for example, Table1.Column1 does not work, just Column1 works fine)

I was wondering if there are problems that I am facing, known differences between the two environments, or is the problem related to database / schema / query structure problems?

EDIT EXAMPLE:

The following 4 queries work in SQL Management Studio but are not transferred to the SQL connection in the .net web part. By not working, I mean that the web part will not load on the asp page (this is actually a SharePoint page), and, as I was told by SharePoint, this creates a problem. I am not sure about the correct sharepoint logs to look at them ... (PAY ATTENTION. I know that these queries do not make sense, for example, the meaninglessness of the FROM clause, but they are debug queries that I played with try to identify problems)

5- SQL Management Studio, - .NET, , .

//-----------------------------------------------

    SELECT DISTINCT 
            '2011' AS Yr, '01' AS PerNbr, 1 AS Amount 
             FROM Submissions AS s INNER JOIN 
            JurisdictionalData  AS j ON re_KeyTbl = Keytbl AND s.jurisdiction <> REPLACE(j.JurisdictionTxt, 'Jurisdiction', '')

//-----------------------------------------------

SELECT DISTINCT 
        '2011' AS Yr, '01' AS PerNbr, 1 AS Amount 
         FROM Submissions AS s INNER JOIN 
        JurisdictionalData  AS j ON j.re_KeyTbl = s.Keytbl AND s.jurisdiction NOT IN (REPLACE(j.JurisdictionTxt, 'Jurisdiction', ''))

//-----------------------------------------------

SELECT DISTINCT 
        '2011' AS Yr, '01' AS PerNbr, 1 AS Amount 
         FROM Submissions AS s INNER JOIN 
        JurisdictionalData  AS j ON j.re_KeyTbl = s.Keytbl AND s.jurisdiction NOT IN (j.JurisdictionTxt)

//-----------------------------------------------

SELECT DISTINCT 
        '2011' AS Yr, '01' AS PerNbr, 1 AS Amount 
         FROM Submissions AS s INNER JOIN 
        JurisdictionalData  AS j ON j.re_KeyTbl = s.Keytbl AND s.jurisdiction <> j.JurisdictionTxt

//-----------------------------------------------
SELECT DISTINCT 
        '2011' AS Yr, '01' AS PerNbr, 1 AS Amount 
         FROM Submissions AS s INNER JOIN 
        JurisdictionalData  AS j ON j.re_KeyTbl = s.Keytbl AND s.jurisdiction = j.JurisdictionTxt

# ( ):

:

//sql db connection string
private string _cnString =
"Server=_server;" +
"Database=_db;" +
"User ID=_user;" +
"Password=_password;" +
"Trusted_Connection=False";

//sql query
    private string query = "SELECT DISTINCT " +
    "'2011' AS Yr, '01' AS PerNbr, 1 AS Amount " + 
     "Submissions AS s INNER JOIN " +
    "JurisdictionalData  AS j ON j.re_KeyTbl = s.Keytbl AND s.jurisdiction = j.JurisdictionTxt ";

CreateChildControls:

 SqlConnection sqlConn = new SqlConnection(_cnString);
 //run SQL query and store results in a dataset
        SqlCommand sqlCmd = new SqlCommand(query, sqlConn);
        SqlDataAdapter adp = new SqlDataAdapter(sqlCmd);
        DataSet ds = new DataSet();
        adp.Fill(ds);
+3
3

, , , SharePoint, . , SharePoint.

-, / . ASP.NET. , , .

, ADO.NET try/catch catch . . System.Diagnostics .

, , , . , . , SharePoint, ?

+2

, .

SQL Server SQL- .

- , ?

0

If you speak directly with SqlCommand (and not with an abstraction, as with a data adapter), it should be identical - it's just TSQL sent to the te server. The only differences may be the set SET parameters, perhaps the account , the default scheme, etc.

0
source

Source: https://habr.com/ru/post/1783427/


All Articles