# sql: Scan error on column index 2: converting NULL to string is unsupported

- **ID:** `go/database-sql-null-value`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Scanning a NULL database column into a non-nullable Go type (e.g., string) without using sql.NullString.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.18 | active | — | — |
| 1.19 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   var s sql.NullString
if err := rows.Scan(&s); err != nil {
    // handle error
}
if s.Valid {
    fmt.Println(s.String)
}
   ```
2. **** (80% success)
   ```
   Use COALESCE in SQL query to convert NULL to default value.
   ```

## Dead Ends

- **** — NULL is not the same as an empty string and can lead to data loss. (70% fail)
- **** — Go does not allow direct casting of NULL to string. (90% fail)
