Posts

Showing posts with the label SqlServer

SQL Server pass parameter to Procedure

Today, My colleague mention his work which how to pass the parameter to the procedure. The workaround as below: 1.Declare a custom table type CREATE   TYPE   dbo . USER_TABLE_TYPE  AS   TABLE   (        USER_NO   VARCHAR ( 8 ) ) 2.C# Declare DataTable and SqlParameter      var   table =   new   DataTable();             table.Columns.Add( new   DataColumn( "USER_NO" , System.Type.GetType( "System.String" )));             table.Rows.Add(table.NewRow());             table.Rows[0][ "USER_NO" ] =   "Abc" ;               var   par =   new   SqlParameter             ...

SQL Wave Char

Today, My colleague asked me a question that Entity Framework will generate SQL and has ESCAPE '~' at the end of the SQL. SELECT * FROM T WHERE Title LIKE 'foo%'  ESCAPE '~' After the survey, some of the article that the only things we knew it is ESCAPE are used to query the data has  Universal characters.There are no articles about "~".Through some of the testing, we found it represented all of the Universal characters.Which means you may be used ESCAPE '%_[^' to query has the data include it then you can just use ESCAPE '~' to replace it. SELECT * FROM T WHERE Title LIKE 'foo%'  ESCAPE '%_[]^' equal SELECT * FROM T WHERE Title LIKE 'foo%'  ESCAPE '~'